Search in sources :

Example 1 with FinalizeNewLayoutVersionCommandProto

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;
    }
}
Also used : FinalizeNewLayoutVersionCommandProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.FinalizeNewLayoutVersionCommandProto) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) FinalizeNewLayoutVersionCommand(org.apache.hadoop.ozone.protocol.commands.FinalizeNewLayoutVersionCommand)

Aggregations

FinalizeNewLayoutVersionCommandProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.FinalizeNewLayoutVersionCommandProto)1 DatanodeStateMachine (org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)1 FinalizeNewLayoutVersionCommand (org.apache.hadoop.ozone.protocol.commands.FinalizeNewLayoutVersionCommand)1