HDDS-144. Fix TestEndPoint#testHeartbeat and TestEndPoint#testRegister.
Contributed by Shashikant Banerjee.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9e50dce4
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9e50dce4
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9e50dce4

Branch: refs/heads/YARN-1011
Commit: 9e50dce46c22d78f28d3ea91dcdb6e9b3bcd6047
Parents: ff583d3
Author: Anu Engineer <aengin...@apache.org>
Authored: Fri Jun 1 14:42:03 2018 -0700
Committer: Anu Engineer <aengin...@apache.org>
Committed: Fri Jun 1 15:36:30 2018 -0700

----------------------------------------------------------------------
 .../ozone/container/common/ScmTestMock.java     | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/9e50dce4/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ScmTestMock.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ScmTestMock.java
 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ScmTestMock.java
index 0ee6321..14da960 100644
--- 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ScmTestMock.java
+++ 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ScmTestMock.java
@@ -16,6 +16,7 @@
  */
 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.scm.VersionInfo;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
@@ -179,6 +180,7 @@ public class ScmTestMock implements 
StorageContainerDatanodeProtocol {
     List<SCMCommandProto>
         cmdResponses = new LinkedList<>();
     return SCMHeartbeatResponseProto.newBuilder().addAllCommands(cmdResponses)
+        .setDatanodeUUID(heartbeat.getDatanodeDetails().getUuid())
         .build();
   }
 
@@ -197,6 +199,7 @@ public class ScmTestMock implements 
StorageContainerDatanodeProtocol {
       throws IOException {
     rpcCount.incrementAndGet();
     updateNodeReport(datanodeDetailsProto, nodeReport);
+    updateContainerReport(containerReportsRequestProto, datanodeDetailsProto);
     sleepIfNeeded();
     return StorageContainerDatanodeProtocolProtos.SCMRegisteredResponseProto
         .newBuilder().setClusterID(UUID.randomUUID().toString())
@@ -228,6 +231,35 @@ public class ScmTestMock implements 
StorageContainerDatanodeProtocol {
   }
 
   /**
+   * 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.
    * @param datanodeDetails
    * @return count of containers of a datanode


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to