Browse Source

HDFS-13018. Block Storage: make the iscsi target addres configurable for discovery. Contributed by Elek, Marton.

Mukul Kumar Singh 7 năm trước cách đây
mục cha
commit
fb09d75379

+ 8 - 0
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/cblock/CBlockConfigKeys.java

@@ -187,6 +187,14 @@ public final class CBlockConfigKeys {
       "dfs.cblock.rpc.timeout";
   public static final String DFS_CBLOCK_RPC_TIMEOUT_DEFAULT = "300s";
 
+  public static final String DFS_CBLOCK_ISCSI_ADVERTISED_IP =
+      "dfs.cblock.iscsi.advertised.ip";
+
+  public static final String DFS_CBLOCK_ISCSI_ADVERTISED_PORT =
+      "dfs.cblock.iscsi.advertised.port";
+
+  public static final int DFS_CBLOCK_ISCSI_ADVERTISED_PORT_DEFAULT = 3260;
+
   private CBlockConfigKeys() {
 
   }

+ 18 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/cblock/jscsiHelper/SCSITargetDaemon.java

@@ -17,6 +17,12 @@
  */
 package org.apache.hadoop.cblock.jscsiHelper;
 
+import static org.apache.hadoop.cblock.CBlockConfigKeys
+    .DFS_CBLOCK_ISCSI_ADVERTISED_IP;
+import static org.apache.hadoop.cblock.CBlockConfigKeys
+    .DFS_CBLOCK_ISCSI_ADVERTISED_PORT;
+import static org.apache.hadoop.cblock.CBlockConfigKeys
+    .DFS_CBLOCK_ISCSI_ADVERTISED_PORT_DEFAULT;
 import org.apache.hadoop.cblock.protocolPB.CBlockClientServerProtocolPB;
 import org.apache.hadoop.cblock.protocolPB.CBlockServiceProtocolPB;
 import org.apache.hadoop.ipc.ProtobufRpcEngine;
@@ -97,7 +103,18 @@ public final class SCSITargetDaemon {
                 NetUtils.getDefaultSocketFactory(ozoneConf), 5000)
         );
     CBlockManagerHandler cbmHandler = new CBlockManagerHandler(cbmClient);
-    Configuration jscsiConfig = new Configuration(jscsiServerAddress);
+
+    String advertisedAddress = ozoneConf.
+        getTrimmed(DFS_CBLOCK_ISCSI_ADVERTISED_IP, jscsiServerAddress);
+
+    int advertisedPort = ozoneConf.
+        getInt(DFS_CBLOCK_ISCSI_ADVERTISED_PORT,
+            DFS_CBLOCK_ISCSI_ADVERTISED_PORT_DEFAULT);
+
+    Configuration jscsiConfig =
+        new Configuration(jscsiServerAddress,
+            advertisedAddress,
+            advertisedPort);
     DefaultMetricsSystem.initialize("CBlockMetrics");
     CBlockTargetMetrics metrics = CBlockTargetMetrics.create();
     CBlockTargetServer targetServer = new CBlockTargetServer(

+ 17 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml

@@ -277,6 +277,23 @@
     </description>
   </property>
 
+  <property>
+    <name>dfs.cblock.iscsi.advertised.ip</name>
+    <value>0.0.0.0</value>
+    <tag>CBLOCK</tag>
+    <description>
+      IP address returned during the iscsi discovery.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.cblock.iscsi.advertised.port</name>
+    <value>3260</value>
+    <tag>CBLOCK</tag>
+    <description>
+      TCP port returned during the iscsi discovery.
+    </description>
+  </property>
   <!--Container Settings used by Datanode-->
   <property>
     <name>ozone.container.cache.size</name>