// replicate the entry at the slaves
List<SlaveClient> slaves;
try {
slaves = participantsStates.getAvailableParticipants();
} catch (Exception e) {
return new ReplicateResponse(le, e);
}
final ReplicateResponse result = new ReplicateResponse(le,
slaves.size() - participantsStates.getLocalSyncN());
// make the replicate call at the clients
if (slaves.size() == 0) {
Logging.logMessage(Logging.LEVEL_DEBUG, this,
"There are no slaves available anymore! " +
"BabuDB runs if it would be in non-replicated mode.");
} else {
// serialize the LogEntry
ReusableBuffer payload = null;
synchronized(checksum) {
CRC32 csumAlgo = checksum.get();
try {
payload = le.serialize(csumAlgo);
} finally {
csumAlgo.reset();
}
}
// send the LogEntry to the other servers
for (final SlaveClient slave : slaves) {
slave.replicate(le.getLSN(), payload.createViewBuffer()).registerListener(
new ClientResponseAvailableListener<Object>() {
@Override
public void responseAvailable(Object r) {
// evaluate the response
participantsStates.requestFinished(slave);
}
@Override
public void requestFailed(Exception e) {
participantsStates.markAsDead(slave);
result.decrementPermittedFailures();
Logging.logMessage(Logging.LEVEL_INFO, this,
"'%s' was marked as dead, because %s",
slave.getDefaultServerAddress().toString(),
e.getMessage());