HDDS-557. DeadNodeHandler should handle exception from removeContainerHandler api. Contributed by Ajay Kumar.
This commit is contained in:
parent
f7ff8c051e
commit
cc80ac2315
@ -71,9 +71,14 @@ public void onMessage(DatanodeDetails datanodeDetails,
|
||||
"Datanode {} is dead. Removing replications from the in-memory state.",
|
||||
datanodeDetails.getUuid());
|
||||
for (ContainerID container : containers) {
|
||||
try {
|
||||
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 void onMessage(DatanodeDetails datanodeDetails,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns logger.
|
||||
* */
|
||||
public static Logger getLogger() {
|
||||
return LOG;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +196,29 @@ public void testStatisticsUpdate() throws Exception {
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user