Search in sources :

Example 1 with ContainerReplicaProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto in project ozone by apache.

the class TestReconContainerManager method testCheckAndAddNewContainerBatch.

@Test
public void testCheckAndAddNewContainerBatch() throws IOException {
    List<ContainerReplicaProto> containerReplicaProtoList = new LinkedList<>();
    ReconContainerManager containerManager = getContainerManager();
    State[] stateTypes = State.values();
    LifeCycleState[] lifeCycleStateTypes = LifeCycleState.values();
    int lifeCycleStateCount = lifeCycleStateTypes.length;
    for (int i = 200; i < 300; i++) {
        assertFalse(containerManager.containerExist(ContainerID.valueOf(i)));
        ContainerReplicaProto.Builder ciBuilder = ContainerReplicaProto.newBuilder();
        ContainerReplicaProto crp = ciBuilder.setContainerID(i).setState(stateTypes[i % lifeCycleStateCount]).build();
        containerReplicaProtoList.add(crp);
    }
    containerManager.checkAndAddNewContainerBatch(containerReplicaProtoList);
    for (long i = 200L; i < 300L; i++) {
        assertTrue(containerManager.containerExist(ContainerID.valueOf(i)));
    }
    // Doing it one more time should not change any state.
    containerManager.checkAndAddNewContainerBatch(containerReplicaProtoList);
    for (int i = 200; i < 300; i++) {
        assertTrue(containerManager.containerExist(ContainerID.valueOf(i)));
        assertEquals(lifeCycleStateTypes[i % lifeCycleStateCount], getContainerManager().getContainer(ContainerID.valueOf(i)).getState());
    }
}
Also used : LifeCycleState(org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleState) State(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto.State) LifeCycleState(org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleState) ContainerReplicaProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with ContainerReplicaProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto in project ozone by apache.

the class TestReconIncrementalContainerReportHandler method getIncrementalContainerReportProto.

private static IncrementalContainerReportProto getIncrementalContainerReportProto(final ContainerID containerId, final State state, final String originNodeId) {
    final IncrementalContainerReportProto.Builder crBuilder = IncrementalContainerReportProto.newBuilder();
    final ContainerReplicaProto replicaProto = ContainerReplicaProto.newBuilder().setContainerID(containerId.getId()).setState(state).setOriginNodeId(originNodeId).build();
    return crBuilder.addReport(replicaProto).build();
}
Also used : IncrementalContainerReportProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.IncrementalContainerReportProto) ContainerReplicaProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto)

Example 3 with ContainerReplicaProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto in project ozone by apache.

the class ScmTestMock method updateContainerReport.

/**
 * Update the cotainerReport.
 *
 * @param reports Container report
 * @param datanodeDetails DataNode Info
 * @throws IOException
 */
public void updateContainerReport(StorageContainerDatanodeProtocolProtos.ContainerReportsProto reports, DatanodeDetailsProto datanodeDetails) throws IOException {
    Preconditions.checkNotNull(reports);
    containerReportsCount.incrementAndGet();
    DatanodeDetails datanode = DatanodeDetails.getFromProtoBuf(datanodeDetails);
    if (reports.getReportsCount() > 0) {
        Map containers = nodeContainers.get(datanode);
        if (containers == null) {
            containers = new LinkedHashMap();
            nodeContainers.put(datanode, containers);
        }
        for (ContainerReplicaProto report : reports.getReportsList()) {
            containers.put(report.getContainerID(), report);
        }
    }
}
Also used : DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ContainerReplicaProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with ContainerReplicaProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto in project ozone by apache.

the class ReconIncrementalContainerReportHandler method onMessage.

@Override
public void onMessage(final IncrementalContainerReportFromDatanode report, final EventPublisher publisher) {
    final DatanodeDetails dnFromReport = report.getDatanodeDetails();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing incremental container report from data node {}", dnFromReport);
    }
    DatanodeDetails dd = getNodeManager().getNodeByUuid(dnFromReport.getUuidString());
    if (dd == null) {
        LOG.warn("Received container report from unknown datanode {}", dnFromReport);
        return;
    }
    ReconContainerManager containerManager = (ReconContainerManager) getContainerManager();
    boolean success = true;
    for (ContainerReplicaProto replicaProto : report.getReport().getReportList()) {
        try {
            final ContainerID id = ContainerID.valueOf(replicaProto.getContainerID());
            try {
                containerManager.checkAndAddNewContainer(id, replicaProto.getState(), report.getDatanodeDetails());
            } catch (Exception ioEx) {
                LOG.error("Exception while checking and adding new container.", ioEx);
                return;
            }
            getNodeManager().addContainer(dd, id);
            processContainerReplica(dd, replicaProto, publisher);
        } catch (ContainerNotFoundException e) {
            success = false;
            LOG.warn("Container {} not found!", replicaProto.getContainerID());
        } catch (NodeNotFoundException ex) {
            success = false;
            LOG.error("Received ICR from unknown datanode {}.", report.getDatanodeDetails(), ex);
        } catch (IOException | InvalidStateTransitionException e) {
            success = false;
            LOG.error("Exception while processing ICR for container {}", replicaProto.getContainerID());
        }
    }
    containerManager.notifyContainerReportProcessing(false, success);
}
Also used : NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException) InvalidStateTransitionException(org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) IOException(java.io.IOException) ContainerNotFoundException(org.apache.hadoop.hdds.scm.container.ContainerNotFoundException) ContainerReplicaProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto) InvalidStateTransitionException(org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException) ContainerNotFoundException(org.apache.hadoop.hdds.scm.container.ContainerNotFoundException) IOException(java.io.IOException) NodeNotFoundException(org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException)

Example 5 with ContainerReplicaProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto in project ozone by apache.

the class TestContainerReportHandler method getContainerReportsProto.

protected static ContainerReportsProto getContainerReportsProto(final ContainerID containerId, final ContainerReplicaProto.State state, final String originNodeId, final long usedBytes, final long keyCount) {
    final ContainerReportsProto.Builder crBuilder = ContainerReportsProto.newBuilder();
    final ContainerReplicaProto replicaProto = ContainerReplicaProto.newBuilder().setContainerID(containerId.getId()).setState(state).setOriginNodeId(originNodeId).setFinalhash("e16cc9d6024365750ed8dbd194ea46d2").setSize(5368709120L).setUsed(usedBytes).setKeyCount(keyCount).setReadCount(100000000L).setWriteCount(100000000L).setReadBytes(2000000000L).setWriteBytes(2000000000L).setBlockCommitSequenceId(10000L).setDeleteTransactionId(0).build();
    return crBuilder.addReports(replicaProto).build();
}
Also used : ContainerReportsProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto) ContainerReplicaProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto)

Aggregations

ContainerReplicaProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto)10 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)5 IOException (java.io.IOException)3 ContainerReportsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto)3 NodeNotFoundException (org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IncrementalContainerReportProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.IncrementalContainerReportProto)2 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)2 ContainerNotFoundException (org.apache.hadoop.hdds.scm.container.ContainerNotFoundException)2 InvalidStateTransitionException (org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ArrayList (java.util.ArrayList)1 Comparator.comparingLong (java.util.Comparator.comparingLong)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1