use of org.apache.hadoop.hdds.scm.node.NodeManager in project ozone by apache.
the class TestReconAsPassiveScm method testDatanodeRegistrationAndReports.
@Test
public void testDatanodeRegistrationAndReports() throws Exception {
ReconStorageContainerManagerFacade reconScm = (ReconStorageContainerManagerFacade) cluster.getReconServer().getReconStorageContainerManager();
StorageContainerManager scm = cluster.getStorageContainerManager();
PipelineManager reconPipelineManager = reconScm.getPipelineManager();
PipelineManager scmPipelineManager = scm.getPipelineManager();
LambdaTestUtils.await(60000, 5000, () -> (reconPipelineManager.getPipelines().size() >= 4));
// Verify if Recon has all the pipelines from SCM.
scmPipelineManager.getPipelines().forEach(p -> {
try {
assertNotNull(reconPipelineManager.getPipeline(p.getId()));
} catch (PipelineNotFoundException e) {
Assert.fail();
}
});
// Verify we can never create a pipeline in Recon.
LambdaTestUtils.intercept(UnsupportedOperationException.class, "Trying to create pipeline in Recon, which is prohibited!", () -> reconPipelineManager.createPipeline(RatisReplicationConfig.getInstance(ONE)));
ContainerManager scmContainerManager = scm.getContainerManager();
assertTrue(scmContainerManager.getContainers().isEmpty());
// Verify if all the 3 nodes are registered with Recon.
NodeManager reconNodeManager = reconScm.getScmNodeManager();
NodeManager scmNodeManager = scm.getScmNodeManager();
assertEquals(scmNodeManager.getAllNodes().size(), reconNodeManager.getAllNodes().size());
// Create container
ContainerManager reconContainerManager = reconScm.getContainerManager();
ContainerInfo containerInfo = scmContainerManager.allocateContainer(RatisReplicationConfig.getInstance(ONE), "test");
long containerID = containerInfo.getContainerID();
Pipeline pipeline = scmPipelineManager.getPipeline(containerInfo.getPipelineID());
XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf);
runTestOzoneContainerViaDataNode(containerID, client);
// Verify Recon picked up the new container that was created.
assertEquals(scmContainerManager.getContainerIDs(), reconContainerManager.getContainerIDs());
GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(ReconNodeManager.LOG);
GenericTestUtils.setLogLevel(ReconNodeManager.LOG, Level.DEBUG);
reconScm.getEventQueue().fireEvent(CLOSE_CONTAINER, containerInfo.containerID());
GenericTestUtils.waitFor(() -> logCapturer.getOutput().contains("Ignoring unsupported command closeContainerCommand"), 1000, 20000);
}
use of org.apache.hadoop.hdds.scm.node.NodeManager in project ozone by apache.
the class TestReconAsPassiveScm method testReconRestart.
@Test
public void testReconRestart() throws Exception {
final OzoneStorageContainerManager reconScm = cluster.getReconServer().getReconStorageContainerManager();
StorageContainerManager scm = cluster.getStorageContainerManager();
// Stop Recon
ContainerManager scmContainerManager = scm.getContainerManager();
assertTrue(scmContainerManager.getContainers().isEmpty());
ContainerManager reconContainerManager = reconScm.getContainerManager();
assertTrue(reconContainerManager.getContainers().isEmpty());
LambdaTestUtils.await(60000, 5000, () -> (reconScm.getScmNodeManager().getAllNodes().size() == 3));
cluster.stopRecon();
// Create container in SCM.
ContainerInfo containerInfo = scmContainerManager.allocateContainer(RatisReplicationConfig.getInstance(ONE), "test");
long containerID = containerInfo.getContainerID();
PipelineManager scmPipelineManager = scm.getPipelineManager();
Pipeline pipeline = scmPipelineManager.getPipeline(containerInfo.getPipelineID());
XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf);
runTestOzoneContainerViaDataNode(containerID, client);
assertFalse(scmContainerManager.getContainers().isEmpty());
// Close a pipeline
Optional<Pipeline> pipelineToClose = scmPipelineManager.getPipelines(RatisReplicationConfig.getInstance(ONE)).stream().filter(p -> !p.getId().equals(containerInfo.getPipelineID())).findFirst();
assertTrue(pipelineToClose.isPresent());
scmPipelineManager.closePipeline(pipelineToClose.get(), false);
// Start Recon
cluster.startRecon();
// Verify if Recon has all the nodes on restart (even if heartbeats are
// not yet received).
NodeManager reconNodeManager = reconScm.getScmNodeManager();
NodeManager scmNodeManager = scm.getScmNodeManager();
assertEquals(scmNodeManager.getAllNodes().size(), reconNodeManager.getAllNodes().size());
// Verify Recon picks up new container, close pipeline SCM actions.
OzoneStorageContainerManager newReconScm = cluster.getReconServer().getReconStorageContainerManager();
PipelineManager reconPipelineManager = newReconScm.getPipelineManager();
assertFalse(reconPipelineManager.containsPipeline(pipelineToClose.get().getId()));
LambdaTestUtils.await(90000, 5000, () -> (newReconScm.getContainerManager().containerExist(ContainerID.valueOf(containerID))));
}
use of org.apache.hadoop.hdds.scm.node.NodeManager in project ozone by apache.
the class TestQueryNode method testNodeOperationalStates.
@Test
public void testNodeOperationalStates() throws Exception {
StorageContainerManager scm = cluster.getStorageContainerManager();
NodeManager nm = scm.getScmNodeManager();
// Set one node to be something other than IN_SERVICE
DatanodeDetails node = nm.getAllNodes().get(0);
nm.setNodeOperationalState(node, DECOMMISSIONING);
// All nodes should be returned as they are all in service
int nodeCount = scmClient.queryNode(IN_SERVICE, HEALTHY, HddsProtos.QueryScope.CLUSTER, "").size();
assertEquals(numOfDatanodes - 1, nodeCount);
// null acts as wildcard for opState
nodeCount = scmClient.queryNode(null, HEALTHY, HddsProtos.QueryScope.CLUSTER, "").size();
assertEquals(numOfDatanodes, nodeCount);
// null acts as wildcard for nodeState
nodeCount = scmClient.queryNode(IN_SERVICE, null, HddsProtos.QueryScope.CLUSTER, "").size();
assertEquals(numOfDatanodes - 1, nodeCount);
// Both null - should return all nodes
nodeCount = scmClient.queryNode(null, null, HddsProtos.QueryScope.CLUSTER, "").size();
assertEquals(numOfDatanodes, nodeCount);
// No node should be returned
nodeCount = scmClient.queryNode(IN_MAINTENANCE, HEALTHY, HddsProtos.QueryScope.CLUSTER, "").size();
assertEquals(0, nodeCount);
// Test all operational states by looping over them all and setting the
// state manually.
node = nm.getAllNodes().get(0);
for (HddsProtos.NodeOperationalState s : HddsProtos.NodeOperationalState.values()) {
nm.setNodeOperationalState(node, s);
nodeCount = scmClient.queryNode(s, HEALTHY, HddsProtos.QueryScope.CLUSTER, "").size();
if (s == IN_SERVICE) {
assertEquals(5, nodeCount);
} else {
assertEquals(1, nodeCount);
}
}
}
use of org.apache.hadoop.hdds.scm.node.NodeManager in project ozone by apache.
the class TestReconIncrementalContainerReportHandler method testProcessICRStateMismatch.
@Test
public void testProcessICRStateMismatch() throws IOException {
// Recon container state is "OPEN".
// Replica state could be any Non OPEN state.
long containerId = 11;
for (State state : Arrays.asList(State.CLOSING, State.QUASI_CLOSED, State.CLOSED)) {
ContainerWithPipeline containerWithPipeline = getTestContainer(containerId++, OPEN);
ContainerID containerID = containerWithPipeline.getContainerInfo().containerID();
ReconContainerManager containerManager = getContainerManager();
containerManager.addNewContainer(containerWithPipeline);
DatanodeDetails datanodeDetails = containerWithPipeline.getPipeline().getFirstNode();
NodeManager nodeManagerMock = mock(NodeManager.class);
when(nodeManagerMock.getNodeByUuid(any())).thenReturn(datanodeDetails);
IncrementalContainerReportFromDatanode reportMock = mock(IncrementalContainerReportFromDatanode.class);
when(reportMock.getDatanodeDetails()).thenReturn(containerWithPipeline.getPipeline().getFirstNode());
IncrementalContainerReportProto containerReport = getIncrementalContainerReportProto(containerID, state, datanodeDetails.getUuidString());
when(reportMock.getReport()).thenReturn(containerReport);
ReconIncrementalContainerReportHandler reconIcr = new ReconIncrementalContainerReportHandler(nodeManagerMock, containerManager, SCMContext.emptyContext());
reconIcr.onMessage(reportMock, mock(EventPublisher.class));
assertTrue(containerManager.containerExist(containerID));
assertEquals(1, containerManager.getContainerReplicas(containerID).size());
LifeCycleState expectedState = getContainerStateFromReplicaState(state);
LifeCycleState actualState = containerManager.getContainer(containerID).getState();
assertEquals(String.format("Expecting %s in " + "container state for replica state %s", expectedState, state), expectedState, actualState);
}
}
use of org.apache.hadoop.hdds.scm.node.NodeManager in project ozone by apache.
the class TestKeyInputStream method getNodeHealth.
private HddsProtos.NodeState getNodeHealth(DatanodeDetails dn) {
HddsProtos.NodeState health = null;
try {
NodeManager nodeManager = getCluster().getStorageContainerManager().getScmNodeManager();
health = nodeManager.getNodeStatus(dn).getHealth();
} catch (NodeNotFoundException e) {
fail("Unexpected NodeNotFound exception");
}
return health;
}
Aggregations