HDFS-12466. Ozone: KSM: Make ozone.ksm.address as mandatory property for client. Contributed by Nandakumar.

This commit is contained in:
Weiwei Yang 2017-09-20 14:55:33 +08:00 committed by Owen O'Malley
parent 8ddf75da17
commit 3b290fe3bf
4 changed files with 40 additions and 14 deletions

View File

@ -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 {

View File

@ -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<String> 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<Integer> 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

View File

@ -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(

View File

@ -529,7 +529,7 @@
<property>
<name>ozone.ksm.address</name>
<value>0.0.0.0</value>
<value></value>
<description>
The address of the Ozone KSM service.
</description>