HDDS-557. DeadNodeHandler should handle exception from removeContainerHandler api. Contributed by Ajay Kumar.

This commit is contained in:
Ajay Kumar 2018-10-01 11:21:26 -07:00
parent f7ff8c051e
commit cc80ac2315
2 changed files with 37 additions and 2 deletions

View File

@ -72,8 +72,13 @@ public class DeadNodeHandler implements EventHandler<DatanodeDetails> {
datanodeDetails.getUuid());
for (ContainerID container : containers) {
try {
containerStateManager.removeContainerReplica(container,
datanodeDetails);
try {
containerStateManager.removeContainerReplica(container,
datanodeDetails);
} catch (SCMException ex) {
LOG.info("DataNode {} doesn't have replica for container {}.",
datanodeDetails.getUuid(), container.getId());
}
if (!containerStateManager.isOpen(container)) {
ReplicationRequest replicationRequest =
@ -90,4 +95,11 @@ public class DeadNodeHandler implements EventHandler<DatanodeDetails> {
}
}
}
/**
* Returns logger.
* */
public static Logger getLogger() {
return LOG;
}
}

View File

@ -196,6 +196,29 @@ public class TestDeadNodeHandler {
Assert.assertTrue(nodeStat.get().getScmUsed().get() == 0);
}
@Test
public void testOnMessageReplicaFailure() throws Exception {
DatanodeDetails dn1 = TestUtils.randomDatanodeDetails();
GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer
.captureLogs(DeadNodeHandler.getLogger());
String storagePath1 = GenericTestUtils.getRandomizedTempPath()
.concat("/" + dn1.getUuidString());
StorageReportProto storageOne = TestUtils.createStorageReport(
dn1.getUuid(), storagePath1, 100, 10, 90, null);
nodeReportHandler.onMessage(getNodeReport(dn1, storageOne),
Mockito.mock(EventPublisher.class));
ContainerInfo container1 =
TestUtils.allocateContainer(containerStateManager);
registerReplicas(node2ContainerMap, dn1, container1);
deadNodeHandler.onMessage(dn1, eventQueue);
Assert.assertTrue(logCapturer.getOutput().contains(
"DataNode " + dn1.getUuid() + " doesn't have replica for container "
+ container1.getContainerID()));
}
private void registerReplicas(ContainerStateManager csm,
ContainerInfo container, DatanodeDetails... datanodes) {
csm.getContainerStateMap()