if (log.isTraceEnabled()) {
log.trace("Configuring the embedded registry.");
}
DataAccessManager dataAccessManager = registryContext.getDataAccessManager();
if (!(dataAccessManager instanceof JDBCDataAccessManager)) {
String msg = "Failed to configure the embedded registry. Invalid data access manager.";
log.error(msg);
throw new RegistryException(msg);
}
NodeGroupLock.init(dataAccessManager);
Transaction.init(dataAccessManager);
try {
if (log.isTraceEnabled()) {
log.trace("Obtaining a cluster wide database lock.");
}
NodeGroupLock.lock(NodeGroupLock.INITIALIZE_LOCK);
if (log.isTraceEnabled()) {
log.trace("Cluster wide database lock obtained successfully.");
}
if (registryContext.isSetup()) {
if (!dataAccessManager.isDatabaseExisting()) {
// mean the database tables are needed
if (log.isTraceEnabled()) {
log.trace("Creating database tables.");
}
try {
dataAccessManager.createDatabase();
} catch (Exception ex) {
String msg = "Error occurred while creating the database";
log.error(msg);
throw new RegistryException(msg, ex);
}