use of org.apache.hadoop.hdds.scm.container.ContainerReplicaCount in project ozone by apache.
the class DatanodeAdminMonitorImpl method checkContainersReplicatedOnNode.
private boolean checkContainersReplicatedOnNode(DatanodeDetails dn) throws NodeNotFoundException {
int sufficientlyReplicated = 0;
int underReplicated = 0;
int unhealthy = 0;
List<ContainerID> underReplicatedIDs = new ArrayList<>();
List<ContainerID> unhealthyIDs = new ArrayList<>();
Set<ContainerID> containers = nodeManager.getContainers(dn);
for (ContainerID cid : containers) {
try {
ContainerReplicaCount replicaSet = replicationManager.getContainerReplicaCount(cid);
if (replicaSet.isSufficientlyReplicated()) {
sufficientlyReplicated++;
} else {
if (LOG.isDebugEnabled()) {
underReplicatedIDs.add(cid);
}
if (underReplicated < CONTAINER_DETAILS_LOGGING_LIMIT || LOG.isDebugEnabled()) {
LOG.info("Under Replicated Container {} {}; {}", cid, replicaSet, replicaDetails(replicaSet.getReplica()));
}
underReplicated++;
}
if (!replicaSet.isHealthy()) {
if (LOG.isDebugEnabled()) {
unhealthyIDs.add(cid);
}
if (unhealthy < CONTAINER_DETAILS_LOGGING_LIMIT || LOG.isDebugEnabled()) {
LOG.info("Unhealthy Container {} {}; {}", cid, replicaSet, replicaDetails(replicaSet.getReplica()));
}
unhealthy++;
}
} catch (ContainerNotFoundException e) {
LOG.warn("ContainerID {} present in node list for {} but not found " + "in containerManager", cid, dn);
}
}
LOG.info("{} has {} sufficientlyReplicated, {} underReplicated and {} " + "unhealthy containers", dn, sufficientlyReplicated, underReplicated, unhealthy);
if (LOG.isDebugEnabled() && underReplicatedIDs.size() < 10000 && unhealthyIDs.size() < 10000) {
LOG.debug("{} has {} underReplicated [{}] and {} unhealthy [{}] " + "containers", dn, underReplicated, underReplicatedIDs.stream().map(Object::toString).collect(Collectors.joining(", ")), unhealthy, unhealthyIDs.stream().map(Object::toString).collect(Collectors.joining(", ")));
}
return underReplicated == 0 && unhealthy == 0;
}
use of org.apache.hadoop.hdds.scm.container.ContainerReplicaCount in project ozone by apache.
the class TestContainerReplicaCount method testOneHealthyThreeMaintenanceMinRepOfTwo.
@Test
public void testOneHealthyThreeMaintenanceMinRepOfTwo() {
Set<ContainerReplica> replica = registerNodes(IN_SERVICE, IN_MAINTENANCE, IN_MAINTENANCE, ENTERING_MAINTENANCE);
ContainerInfo container = createContainer(HddsProtos.LifeCycleState.CLOSED);
ContainerReplicaCount rcnt = new ContainerReplicaCount(container, replica, 0, 0, 3, 2);
validate(rcnt, false, 1, false);
}
use of org.apache.hadoop.hdds.scm.container.ContainerReplicaCount in project ozone by apache.
the class TestDatanodeAdminMonitor method generateReplicaCount.
/**
* Create a ContainerReplicaCount object, including a container with the
* requested ContainerID and state, along with a set of replicas of the given
* states.
* @param containerID The ID of the container to create an included
* @param containerState The state of the container
* @param states Create a replica for each of the given states.
* @return A ContainerReplicaCount containing the generated container and
* replica set
*/
private ContainerReplicaCount generateReplicaCount(ContainerID containerID, HddsProtos.LifeCycleState containerState, HddsProtos.NodeOperationalState... states) {
Set<ContainerReplica> replicas = new HashSet<>();
for (HddsProtos.NodeOperationalState s : states) {
replicas.add(generateReplica(containerID, s, CLOSED));
}
ContainerInfo container = new ContainerInfo.Builder().setContainerID(containerID.getId()).setState(containerState).build();
return new ContainerReplicaCount(container, replicas, 0, 0, 3, 2);
}
use of org.apache.hadoop.hdds.scm.container.ContainerReplicaCount in project ozone by apache.
the class TestContainerReplicaCount method testIsHealthyWithMaintReplicaIsHealthy.
@Test
public void testIsHealthyWithMaintReplicaIsHealthy() {
Set<ContainerReplica> replica = registerNodes(IN_SERVICE, IN_SERVICE, IN_MAINTENANCE, ENTERING_MAINTENANCE);
ContainerInfo container = createContainer(HddsProtos.LifeCycleState.CLOSED);
ContainerReplicaCount rcnt = new ContainerReplicaCount(container, replica, 0, 0, 3, 2);
assertTrue(rcnt.isHealthy());
}
use of org.apache.hadoop.hdds.scm.container.ContainerReplicaCount in project ozone by apache.
the class TestContainerReplicaCount method testOneHealthyReplicaRepFactorOne.
@Test
public void testOneHealthyReplicaRepFactorOne() {
Set<ContainerReplica> replica = registerNodes(IN_SERVICE);
ContainerInfo container = createContainer(HddsProtos.LifeCycleState.CLOSED);
ContainerReplicaCount rcnt = new ContainerReplicaCount(container, replica, 0, 0, 1, 2);
validate(rcnt, true, 0, false);
}
Aggregations