Search in sources :

Example 1 with ContainerReplicaCount

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;
}
Also used : ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) ArrayList(java.util.ArrayList) ContainerNotFoundException(org.apache.hadoop.hdds.scm.container.ContainerNotFoundException) ContainerReplicaCount(org.apache.hadoop.hdds.scm.container.ContainerReplicaCount)

Example 2 with ContainerReplicaCount

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);
}
Also used : ContainerReplica(org.apache.hadoop.hdds.scm.container.ContainerReplica) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) ContainerReplicaCount(org.apache.hadoop.hdds.scm.container.ContainerReplicaCount) Test(org.junit.Test)

Example 3 with ContainerReplicaCount

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);
}
Also used : ContainerReplica(org.apache.hadoop.hdds.scm.container.ContainerReplica) HddsProtos(org.apache.hadoop.hdds.protocol.proto.HddsProtos) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) HashSet(java.util.HashSet) ContainerReplicaCount(org.apache.hadoop.hdds.scm.container.ContainerReplicaCount)

Example 4 with ContainerReplicaCount

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());
}
Also used : ContainerReplica(org.apache.hadoop.hdds.scm.container.ContainerReplica) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) ContainerReplicaCount(org.apache.hadoop.hdds.scm.container.ContainerReplicaCount) Test(org.junit.Test)

Example 5 with ContainerReplicaCount

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);
}
Also used : ContainerReplica(org.apache.hadoop.hdds.scm.container.ContainerReplica) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) ContainerReplicaCount(org.apache.hadoop.hdds.scm.container.ContainerReplicaCount) Test(org.junit.Test)

Aggregations

ContainerReplicaCount (org.apache.hadoop.hdds.scm.container.ContainerReplicaCount)38 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)37 ContainerReplica (org.apache.hadoop.hdds.scm.container.ContainerReplica)36 Test (org.junit.Test)36 HashSet (java.util.HashSet)2 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 ArrayList (java.util.ArrayList)1 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)1 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)1 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)1 ContainerNotFoundException (org.apache.hadoop.hdds.scm.container.ContainerNotFoundException)1