Skip to content

Commit 3b290fe

Browse files
yangwweiomalley
authored andcommittedApr 26, 2018
HDFS-12466. Ozone: KSM: Make ozone.ksm.address as mandatory property for client. Contributed by Nandakumar.
1 parent 8ddf75d commit 3b290fe

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed
 

‎hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ private static ClientProtocol getProtocolClass(ClientType clientType)
158158
return ctor.newInstance(getConfiguration());
159159
} catch (Exception e) {
160160
final String message = "Couldn't create protocol " + protocolClass;
161-
LOG.warn(message, e);
162161
if (e.getCause() instanceof IOException) {
163162
throw (IOException) e.getCause();
164163
} else {

‎hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java

+26
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,32 @@ public static InetSocketAddress getKsmAddress(
321321
port.or(OZONE_KSM_PORT_DEFAULT));
322322
}
323323

324+
/**
325+
* Retrieve the socket address that should be used by clients to connect
326+
* to KSM.
327+
* @param conf
328+
* @return Target InetSocketAddress for the KSM service endpoint.
329+
*/
330+
public static InetSocketAddress getKsmAddressForClients(
331+
Configuration conf) {
332+
final Optional<String> host = getHostNameFromConfigKeys(conf,
333+
OZONE_KSM_ADDRESS_KEY);
334+
335+
if (!host.isPresent()) {
336+
throw new IllegalArgumentException(
337+
OZONE_KSM_ADDRESS_KEY + " must be defined. See" +
338+
" https://wiki.apache.org/hadoop/Ozone#Configuration for" +
339+
" details on configuring Ozone.");
340+
}
341+
342+
// If no port number is specified then we'll just try the defaultBindPort.
343+
final Optional<Integer> port = getPortNumberFromConfigKeys(conf,
344+
OZONE_KSM_ADDRESS_KEY);
345+
346+
return NetUtils.createSocketAddr(
347+
host.get() + ":" + port.or(OZONE_KSM_PORT_DEFAULT));
348+
}
349+
324350
/**
325351
* Retrieve the socket address that is used by CBlock Service.
326352
* @param conf

‎hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ public RpcClient(Configuration conf) throws IOException {
106106
this.groupRights = conf.getEnum(KSMConfigKeys.OZONE_KSM_GROUP_RIGHTS,
107107
KSMConfigKeys.OZONE_KSM_GROUP_RIGHTS_DEFAULT);
108108

109+
long ksmVersion =
110+
RPC.getProtocolVersion(KeySpaceManagerProtocolPB.class);
111+
InetSocketAddress ksmAddress = OzoneClientUtils
112+
.getKsmAddressForClients(conf);
113+
RPC.setProtocolEngine(conf, KeySpaceManagerProtocolPB.class,
114+
ProtobufRpcEngine.class);
115+
this.keySpaceManagerClient =
116+
new KeySpaceManagerProtocolClientSideTranslatorPB(
117+
RPC.getProxy(KeySpaceManagerProtocolPB.class, ksmVersion,
118+
ksmAddress, UserGroupInformation.getCurrentUser(), conf,
119+
NetUtils.getDefaultSocketFactory(conf),
120+
Client.getRpcTimeout(conf)));
121+
109122
long scmVersion =
110123
RPC.getProtocolVersion(StorageContainerLocationProtocolPB.class);
111124
InetSocketAddress scmAddress =
@@ -119,18 +132,6 @@ public RpcClient(Configuration conf) throws IOException {
119132
NetUtils.getDefaultSocketFactory(conf),
120133
Client.getRpcTimeout(conf)));
121134

122-
long ksmVersion =
123-
RPC.getProtocolVersion(KeySpaceManagerProtocolPB.class);
124-
InetSocketAddress ksmAddress = OzoneClientUtils.getKsmAddress(conf);
125-
RPC.setProtocolEngine(conf, KeySpaceManagerProtocolPB.class,
126-
ProtobufRpcEngine.class);
127-
this.keySpaceManagerClient =
128-
new KeySpaceManagerProtocolClientSideTranslatorPB(
129-
RPC.getProxy(KeySpaceManagerProtocolPB.class, ksmVersion,
130-
ksmAddress, UserGroupInformation.getCurrentUser(), conf,
131-
NetUtils.getDefaultSocketFactory(conf),
132-
Client.getRpcTimeout(conf)));
133-
134135
this.xceiverClientManager = new XceiverClientManager(conf);
135136

136137
int configuredChunkSize = conf.getInt(

‎hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@
529529

530530
<property>
531531
<name>ozone.ksm.address</name>
532-
<value>0.0.0.0</value>
532+
<value></value>
533533
<description>
534534
The address of the Ozone KSM service.
535535
</description>

0 commit comments

Comments
 (0)
Please sign in to comment.