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());
}
}
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();
}
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);
}
}
}
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);
}
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();
}
Aggregations