/*
* Start the acknowledgment loop. It's very important that this
* loop be wait/contention free.
*/
while (!checkShutdown()) {
Message response = protocol.read(feederReplicaChannel);
if (checkShutdown()) {
/*
* Shutdown quickly, in particular, don't update sync
* VLSNs.
*/
break;
}
masterStatus.assertSync();
lastResponseTime = System.currentTimeMillis();
if (response.getOp() == Protocol.HEARTBEAT_RESPONSE) {
/* Last response has been updated, keep going. */
HeartbeatResponse hbResponse =
(Protocol.HeartbeatResponse)response;
replicaCBVLSN.updateForReplica(hbResponse);
continue;
} else if (response.getOp() == Protocol.ACK) {
/*
* Check if a commit has been waiting for this
* acknowledgment and signal any waiters.
*/
long txnId = ((Ack) response).getTxnId();
if (logger.isLoggable(Level.FINE)) {
LoggerUtils.fine(logger, repImpl, "Ack for: " + txnId);
}
final VLSN commitVLSN =
repNode.getFeederTxns().noteReplicaAck(txnId);
if ((commitVLSN != null) &&
(commitVLSN.compareTo(replicaACKVLSN) > 0)) {
replicaACKVLSN = commitVLSN;
}
continue;
} else if (response.getOp() == Protocol.SHUTDOWN_RESPONSE) {
LoggerUtils.info(logger, repImpl,
"Shutdown confirmed by replica " +
replicaNameIdPair.getName());
/* Exit the loop and the thread. */
break;