use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto.State.CLOSED in project ozone by apache.
the class TestReplicationManager method testOverReplicatedClosedContainerWithDecomAndMaint.
/**
* When a CLOSED container is over replicated, ReplicationManager
* deletes the excess replicas. While choosing the replica for deletion
* ReplicationManager should not attempt to remove a DECOMMISSION or
* MAINTENANCE replica.
*/
@Test
public void testOverReplicatedClosedContainerWithDecomAndMaint() throws IOException {
final ContainerInfo container = createContainer(LifeCycleState.CLOSED);
addReplica(container, NodeStatus.inServiceHealthy(), CLOSED);
addReplica(container, new NodeStatus(DECOMMISSIONED, HEALTHY), CLOSED);
addReplica(container, new NodeStatus(IN_MAINTENANCE, HEALTHY), CLOSED);
addReplica(container, NodeStatus.inServiceHealthy(), CLOSED);
addReplica(container, NodeStatus.inServiceHealthy(), CLOSED);
addReplica(container, NodeStatus.inServiceHealthy(), CLOSED);
addReplica(container, NodeStatus.inServiceHealthy(), CLOSED);
final int currentDeleteCommandCount = datanodeCommandHandler.getInvocationCount(SCMCommandProto.Type.deleteContainerCommand);
replicationManager.processAll();
eventQueue.processAll(1000);
Assert.assertEquals(currentDeleteCommandCount + 2, datanodeCommandHandler.getInvocationCount(SCMCommandProto.Type.deleteContainerCommand));
Assert.assertEquals(currentDeleteCommandCount + 2, replicationManager.getMetrics().getNumDeletionCmdsSent());
Assert.assertEquals(1, replicationManager.getInflightDeletion().size());
Assert.assertEquals(1, replicationManager.getMetrics().getInflightDeletion());
// Get the DECOM and Maint replica and ensure none of them are scheduled
// for removal
Set<ContainerReplica> decom = containerStateManager.getContainerReplicas(container.containerID()).stream().filter(r -> r.getDatanodeDetails().getPersistedOpState() != IN_SERVICE).collect(Collectors.toSet());
for (ContainerReplica r : decom) {
Assert.assertFalse(datanodeCommandHandler.received(SCMCommandProto.Type.deleteContainerCommand, r.getDatanodeDetails()));
}
assertOverReplicatedCount(1);
}
Aggregations