hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acmur...@apache.org
Subject svn commit: r1493632 - in /hadoop/common/branches/branch-2/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ hadoop-yarn/hadoop-yar...
Date Mon, 17 Jun 2013 03:20:23 GMT
Author: acmurthy
Date: Mon Jun 17 03:20:22 2013
New Revision: 1493632

URL: http://svn.apache.org/r1493632
Log:
Merge -c 1493631 from trunk to branch-2 to fix YARN-824. Added static factory methods to hadoop-yarn-client
interfaces. Contributed by Jian He.

Modified:
    hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
    hadoop/common/branches/branch-2/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/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
    hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt Mon Jun 17 03:20:22 2013
@@ -149,6 +149,9 @@ Release 2.1.0-beta - UNRELEASED
     YARN-831. Removed minimum resource from GetNewApplicationResponse as a
     follow-up to YARN-787. (Jian He via acmurthy)
 
+    YARN-824. Added static factory methods to hadoop-yarn-client interfaces. 
+    (Jian He via acmurthy)
+
   NEW FEATURES
 
     YARN-482. FS: Extend SchedulingMode to intermediate queues. 

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
Mon Jun 17 03:20:22 2013
@@ -60,7 +60,7 @@ import org.apache.hadoop.yarn.api.record
 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 @@ import org.apache.hadoop.yarn.util.Recor
  */
 @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 class Client extends YarnClientIm
   /**
    */
   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 class Client extends YarnClientIm
   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<NodeReport> clusterNodeReports = super.getNodeReports();
+    List<NodeReport> 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 class Client extends YarnClientIm
           + ", 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 class Client extends YarnClientIm
         + ", queueApplicationCount=" + queueInfo.getApplications().size()
         + ", queueChildQueueCount=" + queueInfo.getChildQueues().size());		
 
-    List<QueueUserACLInfo> listAclInfo = super.getQueueAclsInfo();				
+    List<QueueUserACLInfo> listAclInfo = yarnClient.getQueueAclsInfo();
     for (QueueUserACLInfo aclInfo : listAclInfo) {
       for (QueueACL userAcl : aclInfo.getUserAcls()) {
         LOG.info("User ACL Info for Queue"
@@ -351,7 +352,7 @@ public class Client extends YarnClientIm
     }		
 
     // 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
@@ -564,7 +565,7 @@ public class Client extends YarnClientIm
     // 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
@@ -596,7 +597,7 @@ public class Client extends YarnClientIm
       }
 
       // 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()
@@ -656,7 +657,7 @@ public class Client extends YarnClientIm
 
     // 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);	
   }
 
 }

Modified: hadoop/common/branches/branch-2/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
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/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?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/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
(original)
+++ hadoop/common/branches/branch-2/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
Mon Jun 17 03:20:22 2013
@@ -48,6 +48,7 @@ import org.apache.hadoop.yarn.api.record
 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 @@ public class UnmanagedAMLauncher {
   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 class UnmanagedAMLauncher {
     }
 
     YarnConfiguration yarnConf = new YarnConfiguration(conf);
-    rmClient = new YarnClientImpl();
+    rmClient = YarnClient.createYarnClient();
     rmClient.init(yarnConf);
 
     return true;

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClient.java
Mon Jun 17 03:20:22 2013
@@ -24,22 +24,48 @@ import java.util.List;
 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<T extends AMRMClient.ContainerRequest> extends Service
{
+public abstract class AMRMClient<T extends AMRMClient.ContainerRequest> extends
+    AbstractService {
+
+  /**
+   * Create a new instance of AMRMClient.
+   * For usage:
+   * <pre>
+   * {@code
+   * AMRMClient.<T>createAMRMClientContainerRequest(appAttemptId)
+   * }</pre>
+   * @param appAttemptId the appAttemptId associated with the AMRMClient
+   * @return the newly create AMRMClient instance.
+   */
+  @Public
+  public static <T extends ContainerRequest> AMRMClient<T> createAMRMClient(
+      ApplicationAttemptId appAttemptId) {
+    AMRMClient<T> client = new AMRMClientImpl<T>(appAttemptId);
+    return client;
+  }
+
+  @Private
+  protected AMRMClient(String name) {
+    super(name);
+  }
 
   /**
    * Object to represent container request for resources. Scheduler
@@ -132,7 +158,7 @@ public interface AMRMClient<T extends AM
    * @throws YarnException
    * @throws IOException
    */
-  public RegisterApplicationMasterResponse 
+  public abstract RegisterApplicationMasterResponse 
                registerApplicationMaster(String appHostName,
                                          int appHostPort,
                                          String appTrackingUrl) 
@@ -153,7 +179,7 @@ public interface AMRMClient<T extends AM
    * @throws YarnException
    * @throws IOException
    */
-  public AllocateResponse allocate(float progressIndicator) 
+  public abstract AllocateResponse allocate(float progressIndicator) 
                            throws YarnException, IOException;
   
   /**
@@ -164,7 +190,7 @@ public interface AMRMClient<T extends AM
    * @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 interface AMRMClient<T extends AM
    * Request containers for resources before calling <code>allocate</code>
    * @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 interface AMRMClient<T extends AM
    * 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 interface AMRMClient<T extends AM
    * 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 <code>StoredContainerRequest</code>s matching the given

@@ -218,7 +244,7 @@ public interface AMRMClient<T extends AM
    * collection, requests will be returned in the same order as they were added.
    * @return Collection of request matching the parameters
    */
-  public List<? extends Collection<T>> getMatchingRequests(
+  public abstract List<? extends Collection<T>> getMatchingRequests(
                                            Priority priority, 
                                            String resourceName, 
                                            Resource capability);
@@ -231,5 +257,5 @@ public interface AMRMClient<T extends AM
    * 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<String, Token> getNMTokens();
+  public abstract ConcurrentMap<String, Token> getNMTokens();
 }

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientAsync.java
Mon Jun 17 03:20:22 2013
@@ -120,7 +120,7 @@ public class AMRMClientAsync<T extends C
   
   @Private
   @VisibleForTesting
-  public AMRMClientAsync(AMRMClient<T> client, int intervalMs,
+  protected AMRMClientAsync(AMRMClient<T> client, int intervalMs,
       CallbackHandler callbackHandler) {
     super(AMRMClientAsync.class.getName());
     this.client = client;

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/AMRMClientImpl.java
Mon Jun 17 03:20:22 2013
@@ -64,18 +64,15 @@ import org.apache.hadoop.yarn.exceptions
 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<T extends ContainerRequest> 
-                          extends AbstractService implements AMRMClient<T> {
+public class AMRMClientImpl<T extends ContainerRequest> extends AMRMClient<T>
{
 
   private static final Log LOG = LogFactory.getLog(AMRMClientImpl.class);
   

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClient.java
Mon Jun 17 03:20:22 2013
@@ -23,6 +23,8 @@ import java.nio.ByteBuffer;
 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.record
 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);
+  }
 
   /**
    * <p>Start an allocated container.</p>
@@ -54,7 +79,7 @@ public interface NMClient extends Servic
    * @throws YarnException
    * @throws IOException
    */
-  Map<String, ByteBuffer> startContainer(Container container,
+  public abstract Map<String, ByteBuffer> startContainer(Container container,
       ContainerLaunchContext containerLaunchContext)
           throws YarnException, IOException;
 
@@ -68,7 +93,7 @@ public interface NMClient extends Servic
    * @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 @@ public interface NMClient extends Servic
    * @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 @@ public interface NMClient extends Servic
    *
    * @param enabled whether the feature is enabled or not
    */
-  void cleanupRunningContainersOnStop(boolean enabled);
+  public abstract void cleanupRunningContainersOnStop(boolean enabled);
 
 }

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/NMClientImpl.java
Mon Jun 17 03:20:22 2013
@@ -42,8 +42,8 @@ import org.apache.hadoop.yarn.api.record
 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 @@ import org.apache.hadoop.yarn.util.Recor
  * {@link #stopContainer}.
  * </p>
  */
-public class NMClientImpl extends AbstractService implements NMClient {
+public class NMClientImpl extends NMClient {
 
   private static final Log LOG = LogFactory.getLog(NMClientImpl.class);
 

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
Mon Jun 17 03:20:22 2013
@@ -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.record
 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);
+  }
 
   /**
    * <p>
@@ -61,7 +97,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  GetNewApplicationResponse getNewApplication() throws YarnException,
+  public abstract GetNewApplicationResponse getNewApplication() throws YarnException,
       IOException;
 
   /**
@@ -79,7 +115,7 @@ public interface YarnClient extends Serv
    * @throws IOException
    * @see #getNewApplication()
    */
-  ApplicationId submitApplication(ApplicationSubmissionContext appContext)
+  public abstract ApplicationId submitApplication(ApplicationSubmissionContext appContext)
       throws YarnException, IOException;
 
   /**
@@ -95,7 +131,7 @@ public interface YarnClient extends Serv
    * @throws IOException
    * @see #getQueueAclsInfo()
    */
-  void killApplication(ApplicationId applicationId) throws YarnException,
+  public abstract void killApplication(ApplicationId applicationId) throws YarnException,
       IOException;
 
   /**
@@ -128,7 +164,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  ApplicationReport getApplicationReport(ApplicationId appId)
+  public abstract ApplicationReport getApplicationReport(ApplicationId appId)
       throws YarnException, IOException;
 
   /**
@@ -146,7 +182,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  List<ApplicationReport> getApplicationList() throws YarnException,
+  public abstract List<ApplicationReport> getApplicationList() throws YarnException,
       IOException;
 
   /**
@@ -158,7 +194,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
+  public abstract YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
       IOException;
 
   /**
@@ -170,7 +206,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  List<NodeReport> getNodeReports() throws YarnException, IOException;
+  public abstract List<NodeReport> getNodeReports() throws YarnException, IOException;
 
   /**
    * <p>
@@ -184,7 +220,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  Token getRMDelegationToken(Text renewer)
+  public abstract Token getRMDelegationToken(Text renewer)
       throws YarnException, IOException;
 
   /**
@@ -200,7 +236,7 @@ public interface YarnClient extends Serv
    *           access-control restrictions.
    * @throws IOException
    */
-  QueueInfo getQueueInfo(String queueName) throws YarnException,
+  public abstract QueueInfo getQueueInfo(String queueName) throws YarnException,
       IOException;
 
   /**
@@ -213,7 +249,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  List<QueueInfo> getAllQueues() throws YarnException, IOException;
+  public abstract List<QueueInfo> getAllQueues() throws YarnException, IOException;
 
   /**
    * <p>
@@ -224,7 +260,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  List<QueueInfo> getRootQueueInfos() throws YarnException, IOException;
+  public abstract List<QueueInfo> getRootQueueInfos() throws YarnException, IOException;
 
   /**
    * <p>
@@ -239,7 +275,7 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  List<QueueInfo> getChildQueueInfos(String parent) throws YarnException,
+  public abstract List<QueueInfo> getChildQueueInfos(String parent) throws YarnException,
       IOException;
 
   /**
@@ -253,6 +289,6 @@ public interface YarnClient extends Serv
    * @throws YarnException
    * @throws IOException
    */
-  List<QueueUserACLInfo> getQueueAclsInfo() throws YarnException,
+  public abstract List<QueueUserACLInfo> getQueueAclsInfo() throws YarnException,
       IOException;
 }

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
Mon Jun 17 03:20:22 2013
@@ -59,12 +59,11 @@ import org.apache.hadoop.yarn.api.record
 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);
 

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java
Mon Jun 17 03:20:22 2013
@@ -36,7 +36,7 @@ public abstract class YarnCLI extends Co
 
   public YarnCLI() {
     super(new YarnConfiguration());
-    client = new YarnClientImpl();
+    client = YarnClient.createYarnClient();
     client.init(getConf());
     client.start();
   }

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestAMRMClient.java
Mon Jun 17 03:20:22 2013
@@ -74,7 +74,7 @@ import org.mockito.stubbing.Answer;
 public class TestAMRMClient {
   static Configuration conf = null;
   static MiniYARNCluster yarnCluster = null;
-  static YarnClientImpl yarnClient = null;
+  static YarnClient yarnClient = null;
   static List<NodeReport> nodeReports = null;
   static ApplicationAttemptId attemptId = null;
   static int nodeCount = 3;
@@ -95,7 +95,7 @@ public class TestAMRMClient {
     yarnCluster.start();
 
     // start rm client
-    yarnClient = new YarnClientImpl();
+    yarnClient = YarnClient.createYarnClient();
     yarnClient.init(conf);
     yarnClient.start();
 
@@ -169,10 +169,10 @@ public class TestAMRMClient {
   
   @Test (timeout=60000)
   public void testAMRMClientMatchingFit() throws YarnException, IOException {
-    AMRMClientImpl<StoredContainerRequest> amClient = null;
+    AMRMClient<StoredContainerRequest> amClient = null;
     try {
       // start am rm client
-      amClient = new AMRMClientImpl<StoredContainerRequest>(attemptId);
+      amClient = AMRMClient.<StoredContainerRequest>createAMRMClient(attemptId);
       amClient.init(conf);
       amClient.start();
       amClient.registerApplicationMaster("Host", 10000, "");
@@ -318,7 +318,9 @@ public class TestAMRMClient {
     AMRMClientImpl<StoredContainerRequest> amClient = null;
     try {
       // start am rm client
-      amClient = new AMRMClientImpl<StoredContainerRequest>(attemptId);
+      amClient =
+          (AMRMClientImpl<StoredContainerRequest>) AMRMClient
+            .<StoredContainerRequest> createAMRMClient(attemptId);
       amClient.init(conf);
       amClient.start();
       amClient.registerApplicationMaster("Host", 10000, "");
@@ -436,16 +438,16 @@ public class TestAMRMClient {
 
   @Test (timeout=60000)
   public void testAMRMClient() throws YarnException, IOException {
-    AMRMClientImpl<ContainerRequest> amClient = null;
+    AMRMClient<ContainerRequest> amClient = null;
     try {
       // start am rm client
-      amClient = new AMRMClientImpl<ContainerRequest>(attemptId);
+      amClient = AMRMClient.<ContainerRequest>createAMRMClient(attemptId);
       amClient.init(conf);
       amClient.start();
 
       amClient.registerApplicationMaster("Host", 10000, "");
 
-      testAllocation(amClient);
+      testAllocation((AMRMClientImpl<ContainerRequest>)amClient);
 
       amClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED,
           null, null);

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNMClient.java
Mon Jun 17 03:20:22 2013
@@ -82,7 +82,7 @@ public class TestNMClient {
     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 class TestNMClient {
     }
 
     // start am rm client
-    rmClient = new AMRMClientImpl<ContainerRequest>(attemptId);
+    rmClient =
+        (AMRMClientImpl<ContainerRequest>) AMRMClient
+          .<ContainerRequest> 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);

Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java?rev=1493632&r1=1493631&r2=1493632&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
Mon Jun 17 03:20:22 2013
@@ -62,7 +62,7 @@ public class TestYarnClient {
     rm.init(conf);
     rm.start();
 
-    YarnClient client = new YarnClientImpl();
+    YarnClient client = YarnClient.createYarnClient();
     client.init(conf);
     client.start();
     client.stop();



Mime
View raw message