@Override
public BabuDBInternal start(BabuDBInternal babuDB, String configPath)
throws BabuDBException {
// load the plugins configuration
ReplicationConfig configuration;
try {
configuration = new ReplicationConfig(configPath, babuDB.getConfig());
} catch (IOException ioe) {
throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,
"Replication configuration is broken.", ioe.getCause());
}
// replay the backup, if available
try {
new FileIO(configuration).replayBackupFiles();
} catch (IOException io) {
Logging.logMessage(Logging.LEVEL_ERROR, this, "Could not retrieve" +
" the slave backup files, because: ", io.getMessage());
}
// initialize the replication services
ReplicationManager replMan;
try {
replMan = new ReplicationManager(babuDB, configuration);
} catch (Exception e) {
if (e.getMessage() == null) Logging.logError(Logging.LEVEL_ERROR, this, e);
throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,
e.getMessage(), e.getCause());
}
// initialize the BabuDB proxy interface
return new BabuDBProxy(babuDB, replMan, configuration.getReplicationPolicy());
}