HDDS-206. Ozone shell command doesn't respect KSM port set in ozone-site.xml. Contributed by Shashikant Banerjee.
This commit is contained in:
parent
1804a31515
commit
ab2f8343a9
|
@ -21,6 +21,7 @@ package org.apache.hadoop.ozone.client;
|
|||
import com.google.common.base.Preconditions;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
||||
import org.apache.hadoop.ozone.KsmUtils;
|
||||
import org.apache.hadoop.ozone.client.protocol.ClientProtocol;
|
||||
import org.apache.hadoop.ozone.client.rest.RestClient;
|
||||
import org.apache.hadoop.ozone.client.rpc.RpcClient;
|
||||
|
@ -37,10 +38,7 @@ import static org.apache.hadoop.ozone.OzoneConfigKeys
|
|||
.OZONE_CLIENT_PROTOCOL;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
|
||||
.OZONE_KSM_HTTP_ADDRESS_KEY;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
|
||||
.OZONE_KSM_HTTP_BIND_PORT_DEFAULT;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_ADDRESS_KEY;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_PORT_DEFAULT;
|
||||
|
||||
/**
|
||||
* Factory class to create different types of OzoneClients.
|
||||
|
@ -108,8 +106,9 @@ public final class OzoneClientFactory {
|
|||
*/
|
||||
public static OzoneClient getRpcClient(String ksmHost)
|
||||
throws IOException {
|
||||
return getRpcClient(ksmHost, OZONE_KSM_PORT_DEFAULT,
|
||||
new OzoneConfiguration());
|
||||
Configuration config = new OzoneConfiguration();
|
||||
int port = KsmUtils.getKsmRpcPort(config);
|
||||
return getRpcClient(ksmHost, port, config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +184,9 @@ public final class OzoneClientFactory {
|
|||
*/
|
||||
public static OzoneClient getRestClient(String ksmHost)
|
||||
throws IOException {
|
||||
return getRestClient(ksmHost, OZONE_KSM_HTTP_BIND_PORT_DEFAULT);
|
||||
Configuration config = new OzoneConfiguration();
|
||||
int port = KsmUtils.getKsmRestPort(config);
|
||||
return getRestClient(ksmHost, port, config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,8 @@ import com.google.common.base.Optional;
|
|||
import static org.apache.hadoop.hdds.HddsUtils.getHostNameFromConfigKeys;
|
||||
import static org.apache.hadoop.hdds.HddsUtils.getPortNumberFromConfigKeys;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_ADDRESS_KEY;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_HTTP_ADDRESS_KEY;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_HTTP_BIND_PORT_DEFAULT;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
|
||||
.OZONE_KSM_BIND_HOST_DEFAULT;
|
||||
import static org.apache.hadoop.ozone.ksm.KSMConfigKeys.OZONE_KSM_PORT_DEFAULT;
|
||||
|
@ -49,13 +51,9 @@ public final class KsmUtils {
|
|||
final Optional<String> host = getHostNameFromConfigKeys(conf,
|
||||
OZONE_KSM_ADDRESS_KEY);
|
||||
|
||||
// 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.or(OZONE_KSM_BIND_HOST_DEFAULT) + ":" +
|
||||
port.or(OZONE_KSM_PORT_DEFAULT));
|
||||
getKsmRpcPort(conf));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,12 +74,22 @@ public final class KsmUtils {
|
|||
" details on configuring Ozone.");
|
||||
}
|
||||
|
||||
return NetUtils.createSocketAddr(
|
||||
host.get() + ":" + getKsmRpcPort(conf));
|
||||
}
|
||||
|
||||
public static int getKsmRpcPort(Configuration conf) {
|
||||
// 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));
|
||||
return port.or(OZONE_KSM_PORT_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getKsmRestPort(Configuration conf) {
|
||||
// If no port number is specified then we'll just try the default
|
||||
// HTTP BindPort.
|
||||
final Optional<Integer> port =
|
||||
getPortNumberFromConfigKeys(conf, OZONE_KSM_HTTP_ADDRESS_KEY);
|
||||
return port.or(OZONE_KSM_HTTP_BIND_PORT_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue