bshashikant commented on a change in pull request #1722:
URL: https://github.com/apache/ozone/pull/1722#discussion_r570876906
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMNodeDetails.java
##########
@@ -17,59 +17,61 @@
package org.apache.hadoop.hdds.scm.ha;
-import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.ozone.ha.NodeDetails;
+import org.apache.ratis.protocol.RaftGroup;
+import org.apache.ratis.protocol.RaftPeerId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.net.InetAddress;
import java.net.InetSocketAddress;
-import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_INTERNAL_SERVICE_ID;
-import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_SERVICE_IDS_KEY;
-
/**
* Construct SCM node details.
*/
-public final class SCMNodeDetails {
- private String scmServiceId;
- private String scmNodeId;
- private InetSocketAddress rpcAddress;
- private int rpcPort;
- private int ratisPort;
- private String httpAddress;
- private String httpsAddress;
+public final class SCMNodeDetails extends NodeDetails {
+ private InetSocketAddress blockProtocolServerAddress;
+ private String blockProtocolServerAddressKey;
+ private InetSocketAddress clientProtocolServerAddress;
+ private String clientProtocolServerAddressKey;
+ private InetSocketAddress datanodeProtocolServerAddress;
+ private String datanodeAddressKey;
public static final Logger LOG =
LoggerFactory.getLogger(SCMNodeDetails.class);
/**
* Constructs SCMNodeDetails object.
*/
+ @SuppressWarnings("checkstyle:ParameterNumber")
private SCMNodeDetails(String serviceId, String nodeId,
- InetSocketAddress rpcAddr, int rpcPort, int ratisPort,
- String httpAddress, String httpsAddress) {
- this.scmServiceId = serviceId;
- this.scmNodeId = nodeId;
- this.rpcAddress = rpcAddr;
- this.rpcPort = rpcPort;
- this.ratisPort = ratisPort;
- this.httpAddress = httpAddress;
- this.httpsAddress = httpsAddress;
+ InetSocketAddress rpcAddr, int ratisPort, String httpAddress,
+ String httpsAddress, InetSocketAddress blockProtocolServerAddress,
+ InetSocketAddress clientProtocolServerAddress,
+ InetSocketAddress datanodeProtocolServerAddress,
+ RaftGroup group, RaftPeerId selfPeerId, String datanodeAddressKey,
+ String blockProtocolServerAddressKey,
+ String clientProtocolServerAddressAddressKey) {
+ super(serviceId, nodeId, rpcAddr, ratisPort,
+ httpAddress, httpsAddress);
+ this.blockProtocolServerAddress = blockProtocolServerAddress;
+ this.clientProtocolServerAddress = clientProtocolServerAddress;
+ this.datanodeProtocolServerAddress = datanodeProtocolServerAddress;
+ this.datanodeAddressKey = datanodeAddressKey;
+ this.blockProtocolServerAddressKey = blockProtocolServerAddressKey;
+ this.clientProtocolServerAddressKey =
clientProtocolServerAddressAddressKey;
}
@Override
public String toString() {
+ // TODO: add new fields to toString
Review comment:
Can we move this to NodeDetails class itself?
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ScmUtils.java
##########
@@ -60,4 +71,111 @@ public static File createSCMDir(String dirPath) {
}
return dirFile;
}
+
+ public static Collection<String> getSCMNodeIds(ConfigurationSource conf,
+ String scmServiceId) {
+ String key = addSuffix(ScmConfigKeys.OZONE_SCM_NODES_KEY, scmServiceId);
+ return conf.getTrimmedStringCollection(key);
+ }
+
+ public static InetSocketAddress getScmBlockProtocolServerAddress(
+ OzoneConfiguration conf, String localScmServiceId, String nodeId) {
+ String bindHostKey = ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_BIND_HOST_KEY,
+ localScmServiceId, nodeId);
+ final Optional<String> host = getHostNameFromConfigKeys(conf, bindHostKey);
+
+ String addressKey = ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_ADDRESS_KEY,
+ localScmServiceId, nodeId);
+ final OptionalInt port = getPortNumberFromConfigKeys(conf, addressKey);
+
+ return NetUtils.createSocketAddr(
+ host.orElse(
+ ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_BIND_HOST_DEFAULT) + ":" +
+ port.orElse(ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_PORT_DEFAULT));
+ }
+
+ public static String getScmBlockProtocolServerAddressKey(
+ String serviceId, String nodeId) {
+ return ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_ADDRESS_KEY,
+ serviceId, nodeId);
+ }
+
+ public static InetSocketAddress getClientProtocolServerAddress(
+ OzoneConfiguration conf, String localScmServiceId, String nodeId) {
+ String bindHostKey = ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_CLIENT_BIND_HOST_KEY,
+ localScmServiceId, nodeId);
+
+ final String host = getHostNameFromConfigKeys(conf, bindHostKey)
+ .orElse(ScmConfigKeys.OZONE_SCM_CLIENT_BIND_HOST_DEFAULT);
+
+ String addressKey = ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY,
+ localScmServiceId, nodeId);
+
+ final int port = getPortNumberFromConfigKeys(conf, addressKey)
+ .orElse(ScmConfigKeys.OZONE_SCM_CLIENT_PORT_DEFAULT);
+
+ return NetUtils.createSocketAddr(host + ":" + port);
+ }
+
+ public static String getClientProtocolServerAddressKey(
+ String serviceId, String nodeId) {
+ return ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY,
+ serviceId, nodeId);
+ }
+
+ public static InetSocketAddress getScmDataNodeBindAddress(
+ ConfigurationSource conf, String localScmServiceId, String nodeId) {
+ String bindHostKey = ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_DATANODE_BIND_HOST_KEY,
+ localScmServiceId, nodeId
+ );
+ final Optional<String> host = getHostNameFromConfigKeys(conf, bindHostKey);
+ String addressKey = ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_DATANODE_ADDRESS_KEY,
+ localScmServiceId, nodeId
+ );
+ final OptionalInt port = getPortNumberFromConfigKeys(conf, addressKey);
+
+ return NetUtils.createSocketAddr(
+ host.orElse(ScmConfigKeys.OZONE_SCM_DATANODE_BIND_HOST_DEFAULT) + ":" +
+ port.orElse(ScmConfigKeys.OZONE_SCM_DATANODE_PORT_DEFAULT));
+ }
+
+ public static String getScmDataNodeBindAddressKey(
+ String serviceId, String nodeId) {
+ return ScmUtils.addKeySuffixes(
+ ScmConfigKeys.OZONE_SCM_DATANODE_ADDRESS_KEY,
+ serviceId, nodeId);
+ }
+
+ private static String addSuffix(String key, String suffix) {
+ if (suffix == null || suffix.isEmpty()) {
+ return key;
+ }
Review comment:
These functions can be moved to a utility and used by both OM and SCM as
required. Nothing seems specific ti SCM here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]