HDSS-375. ContainerReportHandler should not send replication events for open containers. Contributed by Ajay Kumar.

This commit is contained in:
Xiaoyu Yao 2018-08-27 10:39:30 -07:00
parent f152582562
commit c9b63956d9
2 changed files with 33 additions and 9 deletions

View File

@ -129,6 +129,10 @@ public class ContainerReportHandler implements
"Container is missing from containerStateManager. Can't request " "Container is missing from containerStateManager. Can't request "
+ "replication. {}", + "replication. {}",
containerID); containerID);
return;
}
if (container.isContainerOpen()) {
return;
} }
if (replicationStatus.isReplicationEnabled()) { if (replicationStatus.isReplicationEnabled()) {

View File

@ -84,6 +84,7 @@ public class TestContainerReportHandler implements EventPublisher {
new Builder() new Builder()
.setReplicationFactor(ReplicationFactor.THREE) .setReplicationFactor(ReplicationFactor.THREE)
.setContainerID((Long) invocation.getArguments()[0]) .setContainerID((Long) invocation.getArguments()[0])
.setState(LifeCycleState.CLOSED)
.build() .build()
); );
@ -116,26 +117,45 @@ public class TestContainerReportHandler implements EventPublisher {
when(pipelineSelector.getReplicationPipeline(ReplicationType.STAND_ALONE, when(pipelineSelector.getReplicationPipeline(ReplicationType.STAND_ALONE,
ReplicationFactor.THREE)).thenReturn(pipeline); ReplicationFactor.THREE)).thenReturn(pipeline);
long c1 = containerStateManager ContainerInfo cont1 = containerStateManager
.allocateContainer(pipelineSelector, ReplicationType.STAND_ALONE, .allocateContainer(pipelineSelector, ReplicationType.STAND_ALONE,
ReplicationFactor.THREE, "root").getContainerInfo() ReplicationFactor.THREE, "root").getContainerInfo();
.getContainerID(); ContainerInfo cont2 = containerStateManager
long c2 = containerStateManager
.allocateContainer(pipelineSelector, ReplicationType.STAND_ALONE, .allocateContainer(pipelineSelector, ReplicationType.STAND_ALONE,
ReplicationFactor.THREE, "root").getContainerInfo() ReplicationFactor.THREE, "root").getContainerInfo();
.getContainerID(); // Open Container
ContainerInfo cont3 = containerStateManager
.allocateContainer(pipelineSelector, ReplicationType.STAND_ALONE,
ReplicationFactor.THREE, "root").getContainerInfo();
long c1 = cont1.getContainerID();
long c2 = cont2.getContainerID();
long c3 = cont3.getContainerID();
// Close remaining containers
try {
containerStateManager.getContainerStateMap()
.updateState(cont1, cont1.getState(), LifeCycleState.CLOSING);
containerStateManager.getContainerStateMap()
.updateState(cont1, cont1.getState(), LifeCycleState.CLOSED);
containerStateManager.getContainerStateMap()
.updateState(cont2, cont2.getState(), LifeCycleState.CLOSING);
containerStateManager.getContainerStateMap()
.updateState(cont2, cont2.getState(), LifeCycleState.CLOSED);
} catch (IOException e) {
LOG.info("Failed to change state of open containers.", e);
}
//when //when
//initial reports before replication is enabled. 2 containers w 3 replicas. //initial reports before replication is enabled. 2 containers w 3 replicas.
reportHandler.onMessage( reportHandler.onMessage(
new ContainerReportFromDatanode(dn1, new ContainerReportFromDatanode(dn1,
createContainerReport(new long[] {c1, c2})), this); createContainerReport(new long[] {c1, c2, c3})), this);
reportHandler.onMessage( reportHandler.onMessage(
new ContainerReportFromDatanode(dn2, new ContainerReportFromDatanode(dn2,
createContainerReport(new long[] {c1, c2})), this); createContainerReport(new long[] {c1, c2, c3})), this);
reportHandler.onMessage( reportHandler.onMessage(
new ContainerReportFromDatanode(dn3, new ContainerReportFromDatanode(dn3,