use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.FinalizeNewLayoutVersionCommandProto in project ozone by apache.
the class FinalizeNewLayoutVersionCommandHandler method handle.
/**
* Handles a given SCM command.
*
* @param command - SCM Command
* @param ozoneContainer - Ozone Container.
* @param context - Current Context.
* @param connectionManager - The SCMs that we are talking to.
*/
@Override
public void handle(SCMCommand command, OzoneContainer ozoneContainer, StateContext context, SCMConnectionManager connectionManager) {
LOG.info("Processing FinalizeNewLayoutVersionCommandHandler command.");
invocationCount.incrementAndGet();
final long startTime = Time.monotonicNow();
DatanodeStateMachine dsm = context.getParent();
final FinalizeNewLayoutVersionCommandProto finalizeCommand = ((FinalizeNewLayoutVersionCommand) command).getProto();
try {
if (finalizeCommand.getFinalizeNewLayoutVersion()) {
// SCM is asking datanode to finalize
if (dsm.getLayoutVersionManager().getUpgradeState() == FINALIZATION_REQUIRED) {
// SCM will keep sending Finalize command until datanode mlv == slv
// we need to avoid multiple invocations of finalizeUpgrade.
LOG.info("Finalize Upgrade called!");
dsm.finalizeUpgrade();
}
}
} catch (Exception e) {
LOG.debug("Unexpected Error: {} ", e);
} finally {
long endTime = Time.monotonicNow();
totalTime += endTime - startTime;
}
}
Aggregations