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();
}
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();
}
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;
}
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;
}
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);
}
Aggregations