diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
index cec24c2..2a54d1d 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
@@ -60,7 +60,7 @@
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
-import org.apache.hadoop.yarn.client.YarnClientImpl;
+import org.apache.hadoop.yarn.client.YarnClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.util.ConverterUtils;
@@ -99,13 +99,13 @@
*/
@InterfaceAudience.Public
@InterfaceStability.Unstable
-public class Client extends YarnClientImpl {
+public class Client {
private static final Log LOG = LogFactory.getLog(Client.class);
// Configuration
private Configuration conf;
-
+ private YarnClient yarnClient;
// Application master specific info to register a new Application with RM/ASM
private String appName = "";
// App master priority
@@ -186,9 +186,10 @@ public static void main(String[] args) {
/**
*/
public Client(Configuration conf) throws Exception {
- super();
+
this.conf = conf;
- init(conf);
+ yarnClient = YarnClient.createYarnClient();
+ yarnClient.init(conf);
opts = new Options();
opts.addOption("appname", true, "Application Name. Default value - DistributedShell");
opts.addOption("priority", true, "Application Priority. Default 0");
@@ -317,13 +318,13 @@ public boolean init(String[] args) throws ParseException {
public boolean run() throws IOException, YarnException {
LOG.info("Running Client");
- start();
+ yarnClient.start();
- YarnClusterMetrics clusterMetrics = super.getYarnClusterMetrics();
+ YarnClusterMetrics clusterMetrics = yarnClient.getYarnClusterMetrics();
LOG.info("Got Cluster metric info from ASM"
+ ", numNodeManagers=" + clusterMetrics.getNumNodeManagers());
- List clusterNodeReports = super.getNodeReports();
+ List clusterNodeReports = yarnClient.getNodeReports();
LOG.info("Got Cluster node info from ASM");
for (NodeReport node : clusterNodeReports) {
LOG.info("Got node report from ASM for"
@@ -333,7 +334,7 @@ public boolean run() throws IOException, YarnException {
+ ", nodeNumContainers" + node.getNumContainers());
}
- QueueInfo queueInfo = super.getQueueInfo(this.amQueue);
+ QueueInfo queueInfo = yarnClient.getQueueInfo(this.amQueue);
LOG.info("Queue info"
+ ", queueName=" + queueInfo.getQueueName()
+ ", queueCurrentCapacity=" + queueInfo.getCurrentCapacity()
@@ -341,7 +342,7 @@ public boolean run() throws IOException, YarnException {
+ ", queueApplicationCount=" + queueInfo.getApplications().size()
+ ", queueChildQueueCount=" + queueInfo.getChildQueues().size());
- List listAclInfo = super.getQueueAclsInfo();
+ List listAclInfo = yarnClient.getQueueAclsInfo();
for (QueueUserACLInfo aclInfo : listAclInfo) {
for (QueueACL userAcl : aclInfo.getUserAcls()) {
LOG.info("User ACL Info for Queue"
@@ -351,7 +352,7 @@ public boolean run() throws IOException, YarnException {
}
// Get a new application id
- GetNewApplicationResponse newApp = super.getNewApplication();
+ GetNewApplicationResponse newApp = yarnClient.getNewApplication();
ApplicationId appId = newApp.getApplicationId();
// TODO get min/max resource capabilities from RM and change memory ask if needed
@@ -574,7 +575,7 @@ else if (amMemory > maxMem) {
// or an exception thrown to denote some form of a failure
LOG.info("Submitting application to ASM");
- super.submitApplication(appContext);
+ yarnClient.submitApplication(appContext);
// TODO
// Try submitting the same request again
@@ -606,7 +607,7 @@ private boolean monitorApplication(ApplicationId appId)
}
// Get application report for the appId we are interested in
- ApplicationReport report = super.getApplicationReport(appId);
+ ApplicationReport report = yarnClient.getApplicationReport(appId);
LOG.info("Got application report from ASM for"
+ ", appId=" + appId.getId()
@@ -666,7 +667,7 @@ private void forceKillApplication(ApplicationId appId)
// Response can be ignored as it is non-null on success or
// throws an exception in case of failures
- super.killApplication(appId);
+ yarnClient.killApplication(appId);
}
}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java
index a01370a..5a7892d 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java
@@ -48,6 +48,7 @@
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.client.YarnClient;
import org.apache.hadoop.yarn.client.YarnClientImpl;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
@@ -72,7 +73,7 @@
private Configuration conf;
// Handle to talk to the Resource Manager/Applications Manager
- private YarnClientImpl rmClient;
+ private YarnClient rmClient;
// Application master specific info to register a new Application with RM/ASM
private String appName = "";
@@ -160,7 +161,7 @@ public boolean init(String[] args) throws ParseException {
}
YarnConfiguration yarnConf = new YarnConfiguration(conf);
- rmClient = new YarnClientImpl();
+ rmClient = YarnClient.createYarnClient();
rmClient.init(yarnConf);
return true;
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
index 36a5af4..0906346 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
@@ -24,22 +24,48 @@
import java.util.concurrent.ConcurrentMap;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.hadoop.yarn.service.Service;
+import org.apache.hadoop.yarn.service.AbstractService;
import com.google.common.collect.ImmutableList;
@InterfaceAudience.Public
@InterfaceStability.Unstable
-public interface AMRMClient extends Service {
+public abstract class AMRMClient extends
+ AbstractService {
+
+ /**
+ * Create a new instance of AMRMClient.
+ * For usage:
+ *
+ * {@code
+ * AMRMClient.createAMRMClientContainerRequest(appAttemptId)
+ * }
+ * @param appAttemptId the appAttemptId associated with the AMRMClient
+ * @return the newly create AMRMClient instance.
+ */
+ @Public
+ public static AMRMClient createAMRMClient(
+ ApplicationAttemptId appAttemptId) {
+ AMRMClient client = new AMRMClientImpl(appAttemptId);
+ return client;
+ }
+
+ @Private
+ protected AMRMClient(String name) {
+ super(name);
+ }
/**
* Object to represent container request for resources. Scheduler
@@ -132,7 +158,7 @@ public StoredContainerRequest(Resource capability, String[] nodes,
* @throws YarnException
* @throws IOException
*/
- public RegisterApplicationMasterResponse
+ public abstract RegisterApplicationMasterResponse
registerApplicationMaster(String appHostName,
int appHostPort,
String appTrackingUrl)
@@ -153,7 +179,7 @@ public StoredContainerRequest(Resource capability, String[] nodes,
* @throws YarnException
* @throws IOException
*/
- public AllocateResponse allocate(float progressIndicator)
+ public abstract AllocateResponse allocate(float progressIndicator)
throws YarnException, IOException;
/**
@@ -164,7 +190,7 @@ public AllocateResponse allocate(float progressIndicator)
* @throws YarnException
* @throws IOException
*/
- public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
+ public abstract void unregisterApplicationMaster(FinalApplicationStatus appStatus,
String appMessage,
String appTrackingUrl)
throws YarnException, IOException;
@@ -173,7 +199,7 @@ public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
* Request containers for resources before calling allocate
* @param req Resource request
*/
- public void addContainerRequest(T req);
+ public abstract void addContainerRequest(T req);
/**
* Remove previous container request. The previous container request may have
@@ -182,7 +208,7 @@ public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
* even after the remove request
* @param req Resource request
*/
- public void removeContainerRequest(T req);
+ public abstract void removeContainerRequest(T req);
/**
* Release containers assigned by the Resource Manager. If the app cannot use
@@ -191,21 +217,21 @@ public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
* it still needs it. eg. it released non-local resources
* @param containerId
*/
- public void releaseAssignedContainer(ContainerId containerId);
+ public abstract void releaseAssignedContainer(ContainerId containerId);
/**
* Get the currently available resources in the cluster.
* A valid value is available after a call to allocate has been made
* @return Currently available resources
*/
- public Resource getClusterAvailableResources();
+ public abstract Resource getClusterAvailableResources();
/**
* Get the current number of nodes in the cluster.
* A valid values is available after a call to allocate has been made
* @return Current number of nodes in the cluster
*/
- public int getClusterNodeCount();
+ public abstract int getClusterNodeCount();
/**
* Get outstanding StoredContainerRequests matching the given
@@ -218,7 +244,7 @@ public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
* collection, requests will be returned in the same order as they were added.
* @return Collection of request matching the parameters
*/
- public List extends Collection> getMatchingRequests(
+ public abstract List extends Collection> getMatchingRequests(
Priority priority,
String resourceName,
Resource capability);
@@ -231,5 +257,5 @@ public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
* communicating with NodeManager (ex. NMClient) using NMTokens. If a new
* NMToken is received for the same node manager then it will be replaced.
*/
- public ConcurrentMap getNMTokens();
+ public abstract ConcurrentMap getNMTokens();
}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
index 425c984..8904f44 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
@@ -120,7 +120,7 @@ public AMRMClientAsync(ApplicationAttemptId id, int intervalMs,
@Private
@VisibleForTesting
- public AMRMClientAsync(AMRMClient client, int intervalMs,
+ protected AMRMClientAsync(AMRMClient client, int intervalMs,
CallbackHandler callbackHandler) {
super(AMRMClientAsync.class.getName());
this.client = client;
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
index f76ea5c..e0236fe 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
@@ -64,18 +64,15 @@
import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.ipc.YarnRPC;
-import org.apache.hadoop.yarn.service.AbstractService;
import org.apache.hadoop.yarn.util.RackResolver;
-import com.google.common.base.Joiner;
-
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
// TODO check inputs for null etc. YARN-654
@Unstable
-public class AMRMClientImpl
- extends AbstractService implements AMRMClient {
+public class AMRMClientImpl extends AMRMClient {
private static final Log LOG = LogFactory.getLog(AMRMClientImpl.class);
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
index 0e45aa6..1e278bf 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
@@ -23,6 +23,8 @@
import java.util.Map;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -31,11 +33,34 @@
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.hadoop.yarn.service.Service;
+import org.apache.hadoop.yarn.service.AbstractService;
@InterfaceAudience.Public
@InterfaceStability.Unstable
-public interface NMClient extends Service {
+public abstract class NMClient extends AbstractService {
+
+ /**
+ * Create a new instance of NMClient.
+ */
+ @Public
+ public static NMClient createNMClient() {
+ NMClient client = new NMClientImpl();
+ return client;
+ }
+
+ /**
+ * Create a new instance of NMClient.
+ */
+ @Public
+ public static NMClient createNMClient(String name) {
+ NMClient client = new NMClientImpl(name);
+ return client;
+ }
+
+ @Private
+ protected NMClient(String name) {
+ super(name);
+ }
/**
* Start an allocated container.
@@ -54,7 +79,7 @@
* @throws YarnException
* @throws IOException
*/
- Map startContainer(Container container,
+ public abstract Map startContainer(Container container,
ContainerLaunchContext containerLaunchContext)
throws YarnException, IOException;
@@ -68,7 +93,7 @@
* @throws YarnException
* @throws IOException
*/
- void stopContainer(ContainerId containerId, NodeId nodeId,
+ public abstract void stopContainer(ContainerId containerId, NodeId nodeId,
Token containerToken) throws YarnException, IOException;
/**
@@ -82,7 +107,7 @@ void stopContainer(ContainerId containerId, NodeId nodeId,
* @throws YarnException
* @throws IOException
*/
- ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId,
+ public abstract ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId,
Token containerToken) throws YarnException, IOException;
/**
@@ -92,6 +117,6 @@ ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId,
*
* @param enabled whether the feature is enabled or not
*/
- void cleanupRunningContainersOnStop(boolean enabled);
+ public abstract void cleanupRunningContainersOnStop(boolean enabled);
}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
index b1be764..e7c14e7 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
@@ -42,8 +42,8 @@
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
-import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.ipc.YarnRPC;
@@ -76,7 +76,7 @@
* {@link #stopContainer}.
*
*/
-public class NMClientImpl extends AbstractService implements NMClient {
+public class NMClientImpl extends NMClient {
private static final Log LOG = LogFactory.getLog(NMClientImpl.class);
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
index 53303b1..b255449 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
@@ -19,9 +19,12 @@
package org.apache.hadoop.yarn.client;
import java.io.IOException;
+import java.net.InetSocketAddress;
import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse;
@@ -34,11 +37,44 @@
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.hadoop.yarn.service.Service;
+import org.apache.hadoop.yarn.service.AbstractService;
@InterfaceAudience.Public
@InterfaceStability.Evolving
-public interface YarnClient extends Service {
+public abstract class YarnClient extends AbstractService {
+
+ /**
+ * Create a new instance of YarnClient.
+ */
+ @Public
+ public static YarnClient createYarnClient() {
+ YarnClient client = new YarnClientImpl();
+ return client;
+ }
+
+ /**
+ * Create a new instance of YarnClient.
+ */
+ @Public
+ public static YarnClient createYarnClient(InetSocketAddress rmAddress) {
+ YarnClient client = new YarnClientImpl(rmAddress);
+ return client;
+ }
+
+ /**
+ * Create a new instance of YarnClient.
+ */
+ @Public
+ public static YarnClient createYarnClient(String name,
+ InetSocketAddress rmAddress) {
+ YarnClient client = new YarnClientImpl(name, rmAddress);
+ return client;
+ }
+
+ @Private
+ protected YarnClient(String name) {
+ super(name);
+ }
/**
*
@@ -61,7 +97,7 @@
* @throws YarnException
* @throws IOException
*/
- GetNewApplicationResponse getNewApplication() throws YarnException,
+ public abstract GetNewApplicationResponse getNewApplication() throws YarnException,
IOException;
/**
@@ -79,7 +115,7 @@ GetNewApplicationResponse getNewApplication() throws YarnException,
* @throws IOException
* @see #getNewApplication()
*/
- ApplicationId submitApplication(ApplicationSubmissionContext appContext)
+ public abstract ApplicationId submitApplication(ApplicationSubmissionContext appContext)
throws YarnException, IOException;
/**
@@ -95,7 +131,7 @@ ApplicationId submitApplication(ApplicationSubmissionContext appContext)
* @throws IOException
* @see #getQueueAclsInfo()
*/
- void killApplication(ApplicationId applicationId) throws YarnException,
+ public abstract void killApplication(ApplicationId applicationId) throws YarnException,
IOException;
/**
@@ -128,7 +164,7 @@ void killApplication(ApplicationId applicationId) throws YarnException,
* @throws YarnException
* @throws IOException
*/
- ApplicationReport getApplicationReport(ApplicationId appId)
+ public abstract ApplicationReport getApplicationReport(ApplicationId appId)
throws YarnException, IOException;
/**
@@ -146,7 +182,7 @@ ApplicationReport getApplicationReport(ApplicationId appId)
* @throws YarnException
* @throws IOException
*/
- List getApplicationList() throws YarnException,
+ public abstract List getApplicationList() throws YarnException,
IOException;
/**
@@ -158,7 +194,7 @@ ApplicationReport getApplicationReport(ApplicationId appId)
* @throws YarnException
* @throws IOException
*/
- YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
+ public abstract YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
IOException;
/**
@@ -170,7 +206,7 @@ YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
* @throws YarnException
* @throws IOException
*/
- List getNodeReports() throws YarnException, IOException;
+ public abstract List getNodeReports() throws YarnException, IOException;
/**
*
@@ -184,7 +220,7 @@ YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
* @throws YarnException
* @throws IOException
*/
- Token getRMDelegationToken(Text renewer)
+ public abstract Token getRMDelegationToken(Text renewer)
throws YarnException, IOException;
/**
@@ -200,7 +236,7 @@ Token getRMDelegationToken(Text renewer)
* access-control restrictions.
* @throws IOException
*/
- QueueInfo getQueueInfo(String queueName) throws YarnException,
+ public abstract QueueInfo getQueueInfo(String queueName) throws YarnException,
IOException;
/**
@@ -213,7 +249,7 @@ QueueInfo getQueueInfo(String queueName) throws YarnException,
* @throws YarnException
* @throws IOException
*/
- List getAllQueues() throws YarnException, IOException;
+ public abstract List getAllQueues() throws YarnException, IOException;
/**
*
@@ -224,7 +260,7 @@ QueueInfo getQueueInfo(String queueName) throws YarnException,
* @throws YarnException
* @throws IOException
*/
- List getRootQueueInfos() throws YarnException, IOException;
+ public abstract List getRootQueueInfos() throws YarnException, IOException;
/**
*
@@ -239,7 +275,7 @@ QueueInfo getQueueInfo(String queueName) throws YarnException,
* @throws YarnException
* @throws IOException
*/
- List getChildQueueInfos(String parent) throws YarnException,
+ public abstract List getChildQueueInfos(String parent) throws YarnException,
IOException;
/**
@@ -253,6 +289,6 @@ QueueInfo getQueueInfo(String queueName) throws YarnException,
* @throws YarnException
* @throws IOException
*/
- List getQueueAclsInfo() throws YarnException,
+ public abstract List getQueueAclsInfo() throws YarnException,
IOException;
}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
index 48be1a3..fdbc9a1 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
@@ -59,12 +59,11 @@
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.ipc.YarnRPC;
-import org.apache.hadoop.yarn.service.AbstractService;
import org.apache.hadoop.yarn.util.Records;
@InterfaceAudience.Public
@InterfaceStability.Evolving
-public class YarnClientImpl extends AbstractService implements YarnClient {
+public class YarnClientImpl extends YarnClient {
private static final Log LOG = LogFactory.getLog(YarnClientImpl.class);
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
index a36e671..aa7cb8d 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
@@ -36,7 +36,7 @@
public YarnCLI() {
super(new YarnConfiguration());
- client = new YarnClientImpl();
+ client = YarnClient.createYarnClient();
client.init(getConf());
client.start();
}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
index 4de458e..39fc6a3 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
@@ -74,7 +74,7 @@
public class TestAMRMClient {
static Configuration conf = null;
static MiniYARNCluster yarnCluster = null;
- static YarnClientImpl yarnClient = null;
+ static YarnClient yarnClient = null;
static List nodeReports = null;
static ApplicationAttemptId attemptId = null;
static int nodeCount = 3;
@@ -95,7 +95,7 @@ public static void setup() throws Exception {
yarnCluster.start();
// start rm client
- yarnClient = new YarnClientImpl();
+ yarnClient = YarnClient.createYarnClient();
yarnClient.init(conf);
yarnClient.start();
@@ -169,10 +169,10 @@ public static void tearDown() {
@Test (timeout=60000)
public void testAMRMClientMatchingFit() throws YarnException, IOException {
- AMRMClientImpl amClient = null;
+ AMRMClient amClient = null;
try {
// start am rm client
- amClient = new AMRMClientImpl(attemptId);
+ amClient = AMRMClient.createAMRMClient(attemptId);
amClient.init(conf);
amClient.start();
amClient.registerApplicationMaster("Host", 10000, "");
@@ -318,7 +318,9 @@ public void testAMRMClientMatchStorage() throws YarnException, IOException {
AMRMClientImpl amClient = null;
try {
// start am rm client
- amClient = new AMRMClientImpl(attemptId);
+ amClient =
+ (AMRMClientImpl) AMRMClient
+ . createAMRMClient(attemptId);
amClient.init(conf);
amClient.start();
amClient.registerApplicationMaster("Host", 10000, "");
@@ -436,16 +438,16 @@ public void testAMRMClientMatchStorage() throws YarnException, IOException {
@Test (timeout=60000)
public void testAMRMClient() throws YarnException, IOException {
- AMRMClientImpl amClient = null;
+ AMRMClient amClient = null;
try {
// start am rm client
- amClient = new AMRMClientImpl(attemptId);
+ amClient = AMRMClient.createAMRMClient(attemptId);
amClient.init(conf);
amClient.start();
amClient.registerApplicationMaster("Host", 10000, "");
- testAllocation(amClient);
+ testAllocation((AMRMClientImpl)amClient);
amClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED,
null, null);
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
index 86a3eb6..0b40248 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
@@ -82,7 +82,7 @@ public void setup() throws YarnException, IOException {
assertEquals(STATE.STARTED, yarnCluster.getServiceState());
// start rm client
- yarnClient = new YarnClientImpl();
+ yarnClient = (YarnClientImpl) YarnClient.createYarnClient();
yarnClient.init(conf);
yarnClient.start();
assertNotNull(yarnClient);
@@ -136,14 +136,16 @@ public void setup() throws YarnException, IOException {
}
// start am rm client
- rmClient = new AMRMClientImpl(attemptId);
+ rmClient =
+ (AMRMClientImpl) AMRMClient
+ . createAMRMClient(attemptId);
rmClient.init(conf);
rmClient.start();
assertNotNull(rmClient);
assertEquals(STATE.STARTED, rmClient.getServiceState());
// start am nm client
- nmClient = new NMClientImpl();
+ nmClient = (NMClientImpl) NMClient.createNMClient();
nmClient.init(conf);
nmClient.start();
assertNotNull(nmClient);
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
index fbc876a..0bc6bcd 100644
--- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
@@ -62,7 +62,7 @@ public void testClientStop() {
rm.init(conf);
rm.start();
- YarnClient client = new YarnClientImpl();
+ YarnClient client = YarnClient.createYarnClient();
client.init(conf);
client.start();
client.stop();