prepareMasterCompute(getSuperstep() + 1);
doMasterCompute();
// If the master is halted or all the vertices voted to halt and there
// are no more messages in the system, stop the computation
GlobalStats globalStats = aggregateWorkerStats(getSuperstep());
if (masterCompute.isHalted() ||
(globalStats.getFinishedVertexCount() ==
globalStats.getVertexCount() &&
globalStats.getMessageCount() == 0)) {
globalStats.setHaltComputation(true);
} else if (getZkExt().exists(haltComputationPath, false) != null) {
if (LOG.isInfoEnabled()) {
LOG.info("Halting computation because halt zookeeper node was created");
}
globalStats.setHaltComputation(true);
}
// If we have completed the maximum number of supersteps, stop
// the computation
if (maxNumberOfSupersteps !=
GiraphConstants.MAX_NUMBER_OF_SUPERSTEPS.getDefaultValue() &&
(getSuperstep() == maxNumberOfSupersteps - 1)) {
if (LOG.isInfoEnabled()) {
LOG.info("coordinateSuperstep: Finished " + maxNumberOfSupersteps +
" supersteps (max specified by the user), halting");
}
globalStats.setHaltComputation(true);
}
// Superstep 0 doesn't need to have matching types (Message types may not
// match) and if the computation is halted, no need to check any of
// the types.
if (!globalStats.getHaltComputation()) {
superstepClasses.verifyTypesMatch(
getConfiguration(), getSuperstep() != 0);
}
getConfiguration().updateSuperstepClasses(superstepClasses);
//Signal workers that we want to checkpoint
checkpointStatus = getCheckpointStatus(getSuperstep() + 1);
globalStats.setCheckpointStatus(checkpointStatus);
// Let everyone know the aggregated application state through the
// superstep finishing znode.
String superstepFinishedNode =
getSuperstepFinishedPath(getApplicationAttempt(), getSuperstep());
WritableUtils.writeToZnode(
getZkExt(), superstepFinishedNode, -1, globalStats, superstepClasses);
updateCounters(globalStats);
cleanUpOldSuperstep(getSuperstep() - 1);
incrCachedSuperstep();
// Counter starts at zero, so no need to increment
if (getSuperstep() > 0) {
GiraphStats.getInstance().getSuperstepCounter().increment();
}
SuperstepState superstepState;
if (globalStats.getHaltComputation()) {
superstepState = SuperstepState.ALL_SUPERSTEPS_DONE;
} else {
superstepState = SuperstepState.THIS_SUPERSTEP_DONE;
}
globalCommHandler.writeAggregators(getSuperstep(), superstepState);