YARN-10439. Yarn Service AM listens on all IP's on the machine. Contributed by D M Murali Krishna Reddy
(cherry picked from commit d0dcfc405c
)
This commit is contained in:
parent
e9d8f16a70
commit
5181b2004b
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.yarn.service;
|
package org.apache.hadoop.yarn.service;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||||
import org.apache.hadoop.ipc.Server;
|
import org.apache.hadoop.ipc.Server;
|
||||||
|
@ -53,8 +54,10 @@ import org.apache.hadoop.yarn.service.api.records.ComponentContainers;
|
||||||
import org.apache.hadoop.yarn.service.component.ComponentEvent;
|
import org.apache.hadoop.yarn.service.component.ComponentEvent;
|
||||||
import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEvent;
|
import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEvent;
|
||||||
import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEventType;
|
import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEventType;
|
||||||
|
import org.apache.hadoop.yarn.service.exceptions.BadClusterStateException;
|
||||||
import org.apache.hadoop.yarn.service.utils.FilterUtils;
|
import org.apache.hadoop.yarn.service.utils.FilterUtils;
|
||||||
import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
|
import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
|
||||||
|
import org.apache.hadoop.yarn.service.utils.ServiceUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -64,6 +67,7 @@ import java.util.List;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.service.component.ComponentEventType.DECOMMISSION_INSTANCE;
|
import static org.apache.hadoop.yarn.service.component.ComponentEventType.DECOMMISSION_INSTANCE;
|
||||||
import static org.apache.hadoop.yarn.service.component.ComponentEventType.FLEX;
|
import static org.apache.hadoop.yarn.service.component.ComponentEventType.FLEX;
|
||||||
|
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_SERVICE_AM_CLIENT_PORT_RANGE;
|
||||||
|
|
||||||
public class ClientAMService extends AbstractService
|
public class ClientAMService extends AbstractService
|
||||||
implements ClientAMProtocol {
|
implements ClientAMProtocol {
|
||||||
|
@ -84,9 +88,11 @@ public class ClientAMService extends AbstractService
|
||||||
@Override protected void serviceStart() throws Exception {
|
@Override protected void serviceStart() throws Exception {
|
||||||
Configuration conf = getConfig();
|
Configuration conf = getConfig();
|
||||||
YarnRPC rpc = YarnRPC.create(conf);
|
YarnRPC rpc = YarnRPC.create(conf);
|
||||||
InetSocketAddress address = new InetSocketAddress(0);
|
String nodeHostString = getNMHostName();
|
||||||
|
|
||||||
|
InetSocketAddress address = new InetSocketAddress(nodeHostString, 0);
|
||||||
server = rpc.getServer(ClientAMProtocol.class, this, address, conf,
|
server = rpc.getServer(ClientAMProtocol.class, this, address, conf,
|
||||||
context.secretManager, 1);
|
context.secretManager, 1, YARN_SERVICE_AM_CLIENT_PORT_RANGE);
|
||||||
|
|
||||||
// Enable service authorization?
|
// Enable service authorization?
|
||||||
if (conf.getBoolean(
|
if (conf.getBoolean(
|
||||||
|
@ -97,9 +103,6 @@ public class ClientAMService extends AbstractService
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
String nodeHostString =
|
|
||||||
System.getenv(ApplicationConstants.Environment.NM_HOST.name());
|
|
||||||
|
|
||||||
bindAddress = NetUtils.createSocketAddrForHost(nodeHostString,
|
bindAddress = NetUtils.createSocketAddrForHost(nodeHostString,
|
||||||
server.getListenerAddress().getPort());
|
server.getListenerAddress().getPort());
|
||||||
|
|
||||||
|
@ -107,6 +110,12 @@ public class ClientAMService extends AbstractService
|
||||||
super.serviceStart();
|
super.serviceStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
String getNMHostName() throws BadClusterStateException {
|
||||||
|
return ServiceUtils.mandatoryEnvVariable(
|
||||||
|
ApplicationConstants.Environment.NM_HOST.name());
|
||||||
|
}
|
||||||
|
|
||||||
@Override protected void serviceStop() throws Exception {
|
@Override protected void serviceStop() throws Exception {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
server.stop();
|
server.stop();
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class ServiceMaster extends CompositeService {
|
||||||
DefaultMetricsSystem.initialize("ServiceAppMaster");
|
DefaultMetricsSystem.initialize("ServiceAppMaster");
|
||||||
|
|
||||||
context.secretManager = new ClientToAMTokenSecretManager(attemptId, null);
|
context.secretManager = new ClientToAMTokenSecretManager(attemptId, null);
|
||||||
ClientAMService clientAMService = new ClientAMService(context);
|
ClientAMService clientAMService = createClientAMService();
|
||||||
context.clientAMService = clientAMService;
|
context.clientAMService = clientAMService;
|
||||||
addService(clientAMService);
|
addService(clientAMService);
|
||||||
|
|
||||||
|
@ -143,6 +143,11 @@ public class ServiceMaster extends CompositeService {
|
||||||
super.serviceInit(conf);
|
super.serviceInit(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
protected ClientAMService createClientAMService() {
|
||||||
|
return new ClientAMService(context);
|
||||||
|
}
|
||||||
|
|
||||||
// Record the tokens and use them for launching containers.
|
// Record the tokens and use them for launching containers.
|
||||||
// e.g. localization requires the hdfs delegation tokens
|
// e.g. localization requires the hdfs delegation tokens
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
|
@ -49,6 +49,8 @@ public class YarnServiceConf {
|
||||||
public static final long DEFAULT_AM_FAILURES_VALIDITY_INTERVAL = -1;
|
public static final long DEFAULT_AM_FAILURES_VALIDITY_INTERVAL = -1;
|
||||||
public static final String AM_RESOURCE_MEM = "yarn.service.am-resource.memory";
|
public static final String AM_RESOURCE_MEM = "yarn.service.am-resource.memory";
|
||||||
public static final long DEFAULT_KEY_AM_RESOURCE_MEM = 1024;
|
public static final long DEFAULT_KEY_AM_RESOURCE_MEM = 1024;
|
||||||
|
public static final String YARN_SERVICE_AM_CLIENT_PORT_RANGE =
|
||||||
|
YARN_SERVICE_PREFIX + "am.client.port-range";
|
||||||
|
|
||||||
public static final String YARN_QUEUE = "yarn.service.queue";
|
public static final String YARN_QUEUE = "yarn.service.queue";
|
||||||
public static final String DEFAULT_YARN_QUEUE = "default";
|
public static final String DEFAULT_YARN_QUEUE = "default";
|
||||||
|
|
|
@ -129,6 +129,16 @@ public class MockServiceAM extends ServiceMaster {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ClientAMService createClientAMService() {
|
||||||
|
return new ClientAMService(context) {
|
||||||
|
@Override
|
||||||
|
String getNMHostName() {
|
||||||
|
return "0.0.0.0";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ServiceScheduler createServiceScheduler(ServiceContext context)
|
protected ServiceScheduler createServiceScheduler(ServiceContext context)
|
||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
|
|
|
@ -132,6 +132,7 @@ The above config allows the service AM to be retried a maximum of 10 times.
|
||||||
|yarn.service.rolling-log.include-pattern | Regex expression for including log files by name when aggregating the logs while app is running.|
|
|yarn.service.rolling-log.include-pattern | Regex expression for including log files by name when aggregating the logs while app is running.|
|
||||||
|yarn.service.rolling-log.exclude-pattern | Regex expression for excluding log files by name when aggregating the logs while app is running. If the log file name matches both include and exclude pattern, this file will be excluded.|
|
|yarn.service.rolling-log.exclude-pattern | Regex expression for excluding log files by name when aggregating the logs while app is running. If the log file name matches both include and exclude pattern, this file will be excluded.|
|
||||||
|yarn.service.classpath | Comma separated extra class path parameters for yarn services AM. These path elements will be appended to the end of the YARN service AM classpath. |
|
|yarn.service.classpath | Comma separated extra class path parameters for yarn services AM. These path elements will be appended to the end of the YARN service AM classpath. |
|
||||||
|
|yarn.service.am.client.port-range | Range of ports that the Yarn Service AM can use when binding. Leave blank if you want all possible ports. For example 50000-50050,50100-50200. |
|
||||||
|
|
||||||
### Component-level configuration properties
|
### Component-level configuration properties
|
||||||
Component-level service AM configuration properties can be specified either in the cluster `yarn-site.xml` at the global level (effectively overriding the default values system-wide), specified per service in the `properties` field of the `Configuration` object, or specified per component in the `properties` field of the component's `Configuration` object.
|
Component-level service AM configuration properties can be specified either in the cluster `yarn-site.xml` at the global level (effectively overriding the default values system-wide), specified per service in the `properties` field of the `Configuration` object, or specified per component in the `properties` field of the component's `Configuration` object.
|
||||||
|
|
Loading…
Reference in New Issue