InetSocketAddress master;
try {
master = dbMan.getReplicationManager().getMaster();
} catch (InterruptedException e) {
throw new BabuDBException(ErrorCode.INTERRUPTED,
"Waiting for a lease holder was interrupted.", e);
}
boolean isMaster = dbMan.getReplicationManager().isItMe(master);
if (isMaster || !dbMan.getReplicationPolicy().lookUpIsMasterRestricted()) {
// this service is allowed to retrieve the local database for lookups
if (isMaster || !dbMan.getReplicationPolicy().dbModificationIsMasterRestricted()) {
localDB = dbMan.getLocalDatabase(name);
// existence of the database has to be verified at the master
} else {
try {
dbMan.getClient().getDatabase(name, master).get();
localDB = dbMan.getLocalDatabase(name);
} catch (BabuDBException e) {
throw e;
} catch (ErrorCodeException e) {
throw new BabuDBException(mapTransmissionError(e.getCode()), e.getMessage(), e);
} catch (Exception e) {
throw new BabuDBException(ErrorCode.IO_ERROR, e.getMessage(), e);
}
}
return null;
}