diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java index 580cd110d5a..cda95a548ad 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java @@ -158,7 +158,6 @@ public final class OzoneClientFactory { return ctor.newInstance(getConfiguration()); } catch (Exception e) { final String message = "Couldn't create protocol " + protocolClass; - LOG.warn(message, e); if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java index cc3632dedc3..e192d87ec57 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java @@ -321,6 +321,32 @@ public final class OzoneClientUtils { port.or(OZONE_KSM_PORT_DEFAULT)); } + /** + * Retrieve the socket address that should be used by clients to connect + * to KSM. + * @param conf + * @return Target InetSocketAddress for the KSM service endpoint. + */ + public static InetSocketAddress getKsmAddressForClients( + Configuration conf) { + final Optional host = getHostNameFromConfigKeys(conf, + OZONE_KSM_ADDRESS_KEY); + + if (!host.isPresent()) { + throw new IllegalArgumentException( + OZONE_KSM_ADDRESS_KEY + " must be defined. See" + + " https://wiki.apache.org/hadoop/Ozone#Configuration for" + + " details on configuring Ozone."); + } + + // If no port number is specified then we'll just try the defaultBindPort. + final Optional port = getPortNumberFromConfigKeys(conf, + OZONE_KSM_ADDRESS_KEY); + + return NetUtils.createSocketAddr( + host.get() + ":" + port.or(OZONE_KSM_PORT_DEFAULT)); + } + /** * Retrieve the socket address that is used by CBlock Service. * @param conf diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java index 6464c5deba2..e79d1709f5c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java @@ -106,6 +106,19 @@ public class RpcClient implements ClientProtocol { this.groupRights = conf.getEnum(KSMConfigKeys.OZONE_KSM_GROUP_RIGHTS, KSMConfigKeys.OZONE_KSM_GROUP_RIGHTS_DEFAULT); + long ksmVersion = + RPC.getProtocolVersion(KeySpaceManagerProtocolPB.class); + InetSocketAddress ksmAddress = OzoneClientUtils + .getKsmAddressForClients(conf); + RPC.setProtocolEngine(conf, KeySpaceManagerProtocolPB.class, + ProtobufRpcEngine.class); + this.keySpaceManagerClient = + new KeySpaceManagerProtocolClientSideTranslatorPB( + RPC.getProxy(KeySpaceManagerProtocolPB.class, ksmVersion, + ksmAddress, UserGroupInformation.getCurrentUser(), conf, + NetUtils.getDefaultSocketFactory(conf), + Client.getRpcTimeout(conf))); + long scmVersion = RPC.getProtocolVersion(StorageContainerLocationProtocolPB.class); InetSocketAddress scmAddress = @@ -119,18 +132,6 @@ public class RpcClient implements ClientProtocol { NetUtils.getDefaultSocketFactory(conf), Client.getRpcTimeout(conf))); - long ksmVersion = - RPC.getProtocolVersion(KeySpaceManagerProtocolPB.class); - InetSocketAddress ksmAddress = OzoneClientUtils.getKsmAddress(conf); - RPC.setProtocolEngine(conf, KeySpaceManagerProtocolPB.class, - ProtobufRpcEngine.class); - this.keySpaceManagerClient = - new KeySpaceManagerProtocolClientSideTranslatorPB( - RPC.getProxy(KeySpaceManagerProtocolPB.class, ksmVersion, - ksmAddress, UserGroupInformation.getCurrentUser(), conf, - NetUtils.getDefaultSocketFactory(conf), - Client.getRpcTimeout(conf))); - this.xceiverClientManager = new XceiverClientManager(conf); int configuredChunkSize = conf.getInt( diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml index 492ab06c109..4e0028f34f9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml @@ -529,7 +529,7 @@ ozone.ksm.address - 0.0.0.0 + The address of the Ozone KSM service.