boolean noQueue = true;
// Recovered queues disappear once finished, so definitely not finished as long as those are around
if (replicationStatus.getRecoverdQueues().isEmpty()) {
for (String peerId : replicationStatus.getPeers()) {
for (String server : replicationStatus.getServers(peerId)) {
Status status = replicationStatus.getStatus(peerId, server);
if (!(status.getHLogCount() == 1
/* sometimes it stays with two hlog files, with the second one 100% processed. */
|| (status.getHLogCount() == 2 && Math.abs(status.getProgressOnCurrentHLog() - 1) < 0.000000001f))) {
noQueue = false;
break;
}
}
}
} else {
log.debug("There are still recovered queues");
noQueue = false;
}
// If no hlog files are queued (beyond the current one), wait until there is no replication activity
// during MINIMAL_STABLE_STATUS_AGE, after which we assume replication is done
// (there might also be no activity due to some other reason, e.g. that all peer servers are down and
// hence that hbase can't replication anything, or that the processing of a batch of events takes longer
// than the MINIMAL_STABLE_STATUS_AGE).
if (noQueue) {
log.debug("No hlog files queued, will check if replication status is stable");
boolean statusStable = true;
if (prevReplicationStatus != null) {
for (String peerId : replicationStatus.getPeers()) {
for (String server : replicationStatus.getServers(peerId)) {
Status status = replicationStatus.getStatus(peerId, server);
Status prevStatus = prevReplicationStatus.getStatus(peerId, server);
if (prevStatus == null) {
statusStable = false;
log.debug("No previous status for peer " + peerId + ", server " + server);
break;
}