* 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,
ComponentRegistry.class, TransactionProxy.class
},
directory, properties, systemRegistry, txnProxy);
dbTxn = env.beginTransaction(Long.MAX_VALUE);
Databases dbs = DbUtilities.getDatabases(env, dbTxn, logger);
infoDb = dbs.info();
classesDb = dbs.classes();
oidsDb = dbs.oids();
namesDb = dbs.names();
nodeId = DataStoreHeader.getNextId(
DataStoreHeader.NEXT_NODE_ID_KEY, infoDb, dbTxn, 1);
useAllocationBlockPlaceholders =
env.useAllocationBlockPlaceholders();
freeObjectIds = new FreeObjectIds(useAllocationBlockPlaceholders);
removeUnusedAllocationPlaceholders(dbTxn);
done = true;
dbTxn.commit();
logger.log(Level.CONFIG,
"Created DataStoreImpl with properties:" +
"\n " + DIRECTORY_PROPERTY + "=" + specifiedDirectory +
"\n " + ENVIRONMENT_CLASS_PROPERTY + "=" +
env.getClass().getName());
} 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");
}
}
}