HDDS-144. Fix TestEndPoint#testHeartbeat and TestEndPoint#testRegister.

Contributed by Shashikant Banerjee.
This commit is contained in:
Anu Engineer 2018-06-01 14:42:03 -07:00
parent ff583d3fa3
commit 9e50dce46c

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.hadoop.ozone.container.common; package org.apache.hadoop.ozone.container.common;
import com.google.common.base.Preconditions;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos; import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
import org.apache.hadoop.hdds.scm.VersionInfo; import org.apache.hadoop.hdds.scm.VersionInfo;
import org.apache.hadoop.hdds.protocol.DatanodeDetails; import org.apache.hadoop.hdds.protocol.DatanodeDetails;
@ -179,6 +180,7 @@ private void sleepIfNeeded() {
List<SCMCommandProto> List<SCMCommandProto>
cmdResponses = new LinkedList<>(); cmdResponses = new LinkedList<>();
return SCMHeartbeatResponseProto.newBuilder().addAllCommands(cmdResponses) return SCMHeartbeatResponseProto.newBuilder().addAllCommands(cmdResponses)
.setDatanodeUUID(heartbeat.getDatanodeDetails().getUuid())
.build(); .build();
} }
@ -197,6 +199,7 @@ private void sleepIfNeeded() {
throws IOException { throws IOException {
rpcCount.incrementAndGet(); rpcCount.incrementAndGet();
updateNodeReport(datanodeDetailsProto, nodeReport); updateNodeReport(datanodeDetailsProto, nodeReport);
updateContainerReport(containerReportsRequestProto, datanodeDetailsProto);
sleepIfNeeded(); sleepIfNeeded();
return StorageContainerDatanodeProtocolProtos.SCMRegisteredResponseProto return StorageContainerDatanodeProtocolProtos.SCMRegisteredResponseProto
.newBuilder().setClusterID(UUID.randomUUID().toString()) .newBuilder().setClusterID(UUID.randomUUID().toString())
@ -227,6 +230,35 @@ public void updateNodeReport(DatanodeDetailsProto datanodeDetailsProto,
} }
/**
* 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 (StorageContainerDatanodeProtocolProtos.ContainerInfo report : reports
.getReportsList()) {
containers.put(report.getContainerID(), report);
}
}
}
/** /**
* Return the number of StorageReports of a datanode. * Return the number of StorageReports of a datanode.
* @param datanodeDetails * @param datanodeDetails