Search in sources :

Example 1 with DatanodeStateMachine

use of org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine in project ozone by apache.

the class TestDatanodeUpgradeToScmHA method startPreFinalizedDatanode.

// / CLUSTER OPERATIONS ///
/**
 * Starts the datanode with the first layout version, and calls the version
 * endpoint task to get cluster ID and SCM ID.
 *
 * The daemon for the datanode state machine is not started in this test.
 * This greatly speeds up execution time.
 * It means we do not have heartbeat functionality or pre-finalize
 * upgrade actions, but neither of those things are needed for these tests.
 */
public void startPreFinalizedDatanode() throws Exception {
    // Set layout version.
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, tempFolder.getRoot().getAbsolutePath());
    DatanodeLayoutStorage layoutStorage = new DatanodeLayoutStorage(conf, UUID.randomUUID().toString(), HDDSLayoutFeature.INITIAL_VERSION.layoutVersion());
    layoutStorage.initialize();
    // Build and start the datanode.
    DatanodeDetails dd = ContainerTestUtils.createDatanodeDetails();
    DatanodeStateMachine newDsm = new DatanodeStateMachine(dd, conf, null, null, null);
    int actualMlv = newDsm.getLayoutVersionManager().getMetadataLayoutVersion();
    Assert.assertEquals(HDDSLayoutFeature.INITIAL_VERSION.layoutVersion(), actualMlv);
    dsm = newDsm;
    callVersionEndpointTask();
}
Also used : DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) DatanodeLayoutStorage(org.apache.hadoop.ozone.container.common.DatanodeLayoutStorage) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)

Example 2 with DatanodeStateMachine

use of org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine in project ozone by apache.

the class TestDatanodeUpgradeToScmHA method restartDatanode.

public void restartDatanode(int expectedMlv) throws Exception {
    // Stop existing datanode.
    DatanodeDetails dd = dsm.getDatanodeDetails();
    dsm.close();
    // Start new datanode with the same configuration.
    dsm = new DatanodeStateMachine(dd, conf, null, null, null);
    int mlv = dsm.getLayoutVersionManager().getMetadataLayoutVersion();
    Assert.assertEquals(expectedMlv, mlv);
    callVersionEndpointTask();
}
Also used : DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)

Example 3 with DatanodeStateMachine

use of org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine in project ozone by apache.

the class TestEndPoint method getContext.

private StateContext getContext(DatanodeDetails datanodeDetails) {
    DatanodeStateMachine stateMachine = Mockito.mock(DatanodeStateMachine.class);
    StateContext context = Mockito.mock(StateContext.class);
    Mockito.when(stateMachine.getDatanodeDetails()).thenReturn(datanodeDetails);
    Mockito.when(context.getParent()).thenReturn(stateMachine);
    return context;
}
Also used : StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)

Example 4 with DatanodeStateMachine

use of org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine in project ozone by apache.

the class TestSecureOzoneContainer method getContext.

private StateContext getContext(DatanodeDetails datanodeDetails) {
    DatanodeStateMachine stateMachine = Mockito.mock(DatanodeStateMachine.class);
    StateContext context = Mockito.mock(StateContext.class);
    Mockito.when(stateMachine.getDatanodeDetails()).thenReturn(datanodeDetails);
    Mockito.when(context.getParent()).thenReturn(stateMachine);
    return context;
}
Also used : StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)

Example 5 with DatanodeStateMachine

use of org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine in project ozone by apache.

the class TestHDDSUpgrade method testPreUpgradeConditionsDataNodes.

/*
   * Helper function to test Pre-Upgrade conditions on all the DataNodes.
   */
private void testPreUpgradeConditionsDataNodes() {
    for (HddsDatanodeService dataNode : cluster.getHddsDatanodes()) {
        DatanodeStateMachine dsm = dataNode.getDatanodeStateMachine();
        HDDSLayoutVersionManager dnVersionManager = dsm.getLayoutVersionManager();
        Assert.assertEquals(0, dnVersionManager.getMetadataLayoutVersion());
    }
    int countContainers = 0;
    for (HddsDatanodeService dataNode : cluster.getHddsDatanodes()) {
        DatanodeStateMachine dsm = dataNode.getDatanodeStateMachine();
        // Also verify that all the existing containers are open.
        for (Iterator<Container<?>> it = dsm.getContainer().getController().getContainers(); it.hasNext(); ) {
            Container container = it.next();
            Assert.assertTrue(container.getContainerState() == ContainerProtos.ContainerDataProto.State.OPEN);
            countContainers++;
        }
    }
    Assert.assertTrue(countContainers >= 1);
}
Also used : Container(org.apache.hadoop.ozone.container.common.interfaces.Container) HddsDatanodeService(org.apache.hadoop.ozone.HddsDatanodeService) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)

Aggregations

DatanodeStateMachine (org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)37 Test (org.junit.Test)22 StateContext (org.apache.hadoop.ozone.container.common.statemachine.StateContext)19 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)17 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)16 File (java.io.File)9 ContainerMetrics (org.apache.hadoop.ozone.container.common.helpers.ContainerMetrics)8 ContainerSet (org.apache.hadoop.ozone.container.common.impl.ContainerSet)8 MutableVolumeSet (org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)7 ContainerProtos (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos)6 Handler (org.apache.hadoop.ozone.container.common.interfaces.Handler)6 MockPipeline (org.apache.hadoop.hdds.scm.pipeline.MockPipeline)5 XceiverServerSpi (org.apache.hadoop.ozone.container.common.transport.server.XceiverServerSpi)5 List (java.util.List)4 UUID (java.util.UUID)4 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)4 ContainerCommandResponseProto (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto)4