From cd8b9e913e9a27196d5622feab68d679c0b552c5 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Sat, 12 May 2018 10:13:13 -0700 Subject: [PATCH] HDDS-53. Fix TestKey#testPutAndGetKeyWithDnRestart. Contributed by Mukul Kumar Singh. --- .../hadoop/ozone/MiniOzoneClusterImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java index 17872f4e17..08d71760cb 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java @@ -62,6 +62,14 @@ import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState .HEALTHY; import static org.apache.hadoop.ozone.OzoneConfigKeys.HDDS_DATANODE_PLUGINS_KEY; +import static org.apache.hadoop.ozone.OzoneConfigKeys + .DFS_CONTAINER_IPC_PORT; +import static org.apache.hadoop.ozone.OzoneConfigKeys + .DFS_CONTAINER_IPC_RANDOM_PORT; +import static org.apache.hadoop.ozone.OzoneConfigKeys + .DFS_CONTAINER_RATIS_IPC_PORT; +import static org.apache.hadoop.ozone.OzoneConfigKeys + .DFS_CONTAINER_RATIS_IPC_RANDOM_PORT; /** * MiniOzoneCluster creates a complete in-process Ozone cluster suitable for @@ -211,6 +219,14 @@ public void restartHddsDatanode(int i) { HddsDatanodeService datanodeService = hddsDatanodes.get(i); datanodeService.stop(); datanodeService.join(); + // ensure same ports are used across restarts. + Configuration conf = datanodeService.getConf(); + int currentPort = datanodeService.getDatanodeDetails().getContainerPort(); + conf.setInt(DFS_CONTAINER_IPC_PORT, currentPort); + conf.setBoolean(DFS_CONTAINER_IPC_RANDOM_PORT, false); + int ratisPort = datanodeService.getDatanodeDetails().getRatisPort(); + conf.setInt(DFS_CONTAINER_RATIS_IPC_PORT, ratisPort); + conf.setBoolean(DFS_CONTAINER_RATIS_IPC_RANDOM_PORT, false); datanodeService.start(null); }