* Use an absolute path to avoid problems on Windows.
* -tjb@sun.com (02/16/2007)
*/
directory = new File(specifiedDirectory).getAbsolutePath();
txnInfoTable = getTxnInfoTable(TxnInfo.class);
DbTransaction dbTxn = null;
boolean done = false;
try {
File directoryFile = new File(specifiedDirectory).getAbsoluteFile();
if (!directoryFile.exists()) {
logger.log(Level.INFO, "Creating database directory : " +
directoryFile.getAbsolutePath());
if (!directoryFile.mkdirs()) {
throw new DataStoreException("Unable to create database " +
"directory : " +
directoryFile.getName());
}
}
env = wrappedProps.getClassInstanceProperty(
ENVIRONMENT_CLASS_PROPERTY,
DEFAULT_ENVIRONMENT_CLASS,
DbEnvironment.class,
new Class<?>[]{
String.class, Properties.class, Scheduler.class
},
directory, properties, scheduler);
dbTxn = env.beginTransaction(Long.MAX_VALUE);
Databases dbs = getDatabases(dbTxn);
infoDb = dbs.info;
classesDb = dbs.classes;
oidsDb = dbs.oids;
namesDb = dbs.names;
useAllocationBlockPlaceholders =
env.useAllocationBlockPlaceholders();
freeObjectIds = new FreeObjectIds(useAllocationBlockPlaceholders);
removeUnusedAllocationPlaceholders(dbTxn);
done = true;
dbTxn.commit();
} catch (RuntimeException e) {
throw handleException(
null, Level.SEVERE, e, "DataStore initialization");
} catch (Error e) {
logger.logThrow(
Level.SEVERE, e, "DataStore initialization failed");
throw e;
} finally {
if (dbTxn != null && !done) {
try {
dbTxn.abort();
} catch (RuntimeException e) {
logger.logThrow(Level.FINE, e, "Exception during abort");
}
}
}