You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-commits@hadoop.apache.org by vi...@apache.org on 2012/09/05 19:54:33 UTC
svn commit: r1381273 - in /hadoop/common/trunk/hadoop-yarn-project: ./
hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/
hadoop-yarn/hadoop-yarn-client/src...
Author: vinodkv
Date: Wed Sep 5 17:54:32 2012
New Revision: 1381273
URL: http://svn.apache.org/viewvc?rev=1381273&view=rev
Log:
YARN-83. Change package of YarnClient to org.apache.hadoop. Contributed by Bikas Saha.
Added:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java
Removed:
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/hadoop/
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/hadoop/
Modified:
hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1381273&r1=1381272&r2=1381273&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Wed Sep 5 17:54:32 2012
@@ -70,6 +70,8 @@ Release 0.23.4 - UNRELEASED
IMPROVEMENTS
+ Change package of YarnClient to org.apache.hadoop. (Bikas Saha via vinodkv)
+
OPTIMIZATIONS
BUG FIXES
Modified: hadoop/common/trunk/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/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java?rev=1381273&r1=1381272&r2=1381273&view=diff
==============================================================================
--- hadoop/common/trunk/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/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java Wed Sep 5 17:54:32 2012
@@ -61,11 +61,11 @@ 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.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.util.Records;
-import org.hadoop.yarn.client.YarnClientImpl;
/**
* Client for Distributed Shell application submission to YARN.
Added: hadoop/common/trunk/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/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java?rev=1381273&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClient.java Wed Sep 5 17:54:32 2012
@@ -0,0 +1,234 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.client;
+
+import java.util.List;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.DelegationToken;
+import org.apache.hadoop.yarn.api.records.NodeReport;
+import org.apache.hadoop.yarn.api.records.QueueInfo;
+import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
+import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.service.Service;
+
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public interface YarnClient extends Service {
+
+ /**
+ * <p>
+ * Obtain a new {@link ApplicationId} for submitting new applications.
+ * </p>
+ *
+ * <p>
+ * Returns a response which contains {@link ApplicationId} that can be used to
+ * submit a new application. See
+ * {@link #submitApplication(ApplicationSubmissionContext)}.
+ * </p>
+ *
+ * <p>
+ * See {@link GetNewApplicationResponse} for other information that is
+ * returned.
+ * </p>
+ *
+ * @return response containing the new <code>ApplicationId</code> to be used
+ * to submit an application
+ * @throws YarnRemoteException
+ */
+ GetNewApplicationResponse getNewApplication() throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Submit a new application to <code>YARN.</code>
+ * </p>
+ *
+ * @param appContext
+ * {@link ApplicationSubmissionContext} containing all the details
+ * needed to submit a new application
+ * @return {@link ApplicationId} of the accepted application
+ * @throws YarnRemoteException
+ * @see #getNewApplication()
+ */
+ ApplicationId submitApplication(ApplicationSubmissionContext appContext)
+ throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Kill an application identified by given ID.
+ * </p>
+ *
+ * @param applicationId
+ * {@link ApplicationId} of the application that needs to be killed
+ * @throws YarnRemoteException
+ * in case of errors or if YARN rejects the request due to
+ * access-control restrictions.
+ * @see #getQueueAclsInfo()
+ */
+ void killApplication(ApplicationId applicationId) throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get a report of the given Application.
+ * </p>
+ *
+ * <p>
+ * In secure mode, <code>YARN</code> verifies access to the application, queue
+ * etc. before accepting the request.
+ * </p>
+ *
+ * <p>
+ * If the user does not have <code>VIEW_APP</code> access then the following
+ * fields in the report will be set to stubbed values:
+ * <ul>
+ * <li>host - set to "N/A"</li>
+ * <li>RPC port - set to -1</li>
+ * <li>client token - set to "N/A"</li>
+ * <li>diagnostics - set to "N/A"</li>
+ * <li>tracking URL - set to "N/A"</li>
+ * <li>original tracking URL - set to "N/A"</li>
+ * <li>resource usage report - all values are -1</li>
+ * </ul>
+ * </p>
+ *
+ * @param appId
+ * {@link ApplicationId} of the application that needs a report
+ * @return application report
+ * @throws YarnRemoteException
+ */
+ ApplicationReport getApplicationReport(ApplicationId appId)
+ throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get a report (ApplicationReport) of all Applications in the cluster.
+ * </p>
+ *
+ * <p>
+ * If the user does not have <code>VIEW_APP</code> access for an application
+ * then the corresponding report will be filtered as described in
+ * {@link #getApplicationReport(ApplicationId)}.
+ * </p>
+ *
+ * @return a list of reports of all running applications
+ * @throws YarnRemoteException
+ */
+ List<ApplicationReport> getApplicationList() throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get metrics ({@link YarnClusterMetrics}) about the cluster.
+ * </p>
+ *
+ * @return cluster metrics
+ * @throws YarnRemoteException
+ */
+ YarnClusterMetrics getYarnClusterMetrics() throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get a report of all nodes ({@link NodeReport}) in the cluster.
+ * </p>
+ *
+ * @return A list of report of all nodes
+ * @throws YarnRemoteException
+ */
+ List<NodeReport> getNodeReports() throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get a delegation token so as to be able to talk to YARN using those tokens.
+ *
+ * @param renewer
+ * Address of the renewer who can renew these tokens when needed by
+ * securely talking to YARN.
+ * @return a delegation token ({@link DelegationToken}) that can be used to
+ * talk to YARN
+ * @throws YarnRemoteException
+ */
+ DelegationToken getRMDelegationToken(Text renewer) throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get information ({@link QueueInfo}) about a given <em>queue</em>.
+ * </p>
+ *
+ * @param queueName
+ * Name of the queue whose information is needed
+ * @return queue information
+ * @throws YarnRemoteException
+ * in case of errors or if YARN rejects the request due to
+ * access-control restrictions.
+ */
+ QueueInfo getQueueInfo(String queueName) throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get information ({@link QueueInfo}) about all queues, recursively if there
+ * is a hierarchy
+ * </p>
+ *
+ * @return a list of queue-information for all queues
+ * @throws YarnRemoteException
+ */
+ List<QueueInfo> getAllQueues() throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get information ({@link QueueInfo}) about top level queues.
+ * </p>
+ *
+ * @return a list of queue-information for all the top-level queues
+ * @throws YarnRemoteException
+ */
+ List<QueueInfo> getRootQueueInfos() throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get information ({@link QueueInfo}) about all the immediate children queues
+ * of the given queue
+ * </p>
+ *
+ * @param parent
+ * Name of the queue whose child-queues' information is needed
+ * @return a list of queue-information for all queues who are direct children
+ * of the given parent queue.
+ * @throws YarnRemoteException
+ */
+ List<QueueInfo> getChildQueueInfos(String parent) throws YarnRemoteException;
+
+ /**
+ * <p>
+ * Get information about <em>acls</em> for <em>current user</em> on all the
+ * existing queues.
+ * </p>
+ *
+ * @return a list of queue acls ({@link QueueUserACLInfo}) for
+ * <em>current user</em>
+ * @throws YarnRemoteException
+ */
+ List<QueueUserACLInfo> getQueueAclsInfo() throws YarnRemoteException;
+}
Added: hadoop/common/trunk/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/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java?rev=1381273&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/YarnClientImpl.java Wed Sep 5 17:54:32 2012
@@ -0,0 +1,258 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.client;
+
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.api.protocolrecords.GetAllApplicationsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetAllApplicationsResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.DelegationToken;
+import org.apache.hadoop.yarn.api.records.NodeReport;
+import org.apache.hadoop.yarn.api.records.QueueInfo;
+import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
+import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+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 {
+
+ private static final Log LOG = LogFactory.getLog(YarnClientImpl.class);
+
+ protected ClientRMProtocol rmClient;
+ protected InetSocketAddress rmAddress;
+
+ private static final String ROOT = "root";
+
+ public YarnClientImpl() {
+ super(YarnClientImpl.class.getName());
+ }
+
+ private static InetSocketAddress getRmAddress(Configuration conf) {
+ return conf.getSocketAddr(YarnConfiguration.RM_ADDRESS,
+ YarnConfiguration.DEFAULT_RM_ADDRESS, YarnConfiguration.DEFAULT_RM_PORT);
+ }
+
+ @Override
+ public synchronized void init(Configuration conf) {
+ this.rmAddress = getRmAddress(conf);
+ super.init(conf);
+ }
+
+ @Override
+ public synchronized void start() {
+ YarnRPC rpc = YarnRPC.create(getConfig());
+
+ this.rmClient =
+ (ClientRMProtocol) rpc.getProxy(ClientRMProtocol.class, rmAddress,
+ getConfig());
+ LOG.debug("Connecting to ResourceManager at " + rmAddress);
+ super.start();
+ }
+
+ @Override
+ public synchronized void stop() {
+ RPC.stopProxy(this.rmClient);
+ super.stop();
+ }
+
+ @Override
+ public GetNewApplicationResponse getNewApplication()
+ throws YarnRemoteException {
+ GetNewApplicationRequest request =
+ Records.newRecord(GetNewApplicationRequest.class);
+ return rmClient.getNewApplication(request);
+ }
+
+ @Override
+ public ApplicationId
+ submitApplication(ApplicationSubmissionContext appContext)
+ throws YarnRemoteException {
+ ApplicationId applicationId = appContext.getApplicationId();
+ appContext.setApplicationId(applicationId);
+ SubmitApplicationRequest request =
+ Records.newRecord(SubmitApplicationRequest.class);
+ request.setApplicationSubmissionContext(appContext);
+ rmClient.submitApplication(request);
+ LOG.info("Submitted application " + applicationId + " to ResourceManager"
+ + " at " + rmAddress);
+ return applicationId;
+ }
+
+ @Override
+ public void killApplication(ApplicationId applicationId)
+ throws YarnRemoteException {
+ LOG.info("Killing application " + applicationId);
+ KillApplicationRequest request =
+ Records.newRecord(KillApplicationRequest.class);
+ request.setApplicationId(applicationId);
+ rmClient.forceKillApplication(request);
+ }
+
+ @Override
+ public ApplicationReport getApplicationReport(ApplicationId appId)
+ throws YarnRemoteException {
+ GetApplicationReportRequest request =
+ Records.newRecord(GetApplicationReportRequest.class);
+ request.setApplicationId(appId);
+ GetApplicationReportResponse response =
+ rmClient.getApplicationReport(request);
+ return response.getApplicationReport();
+ }
+
+ @Override
+ public List<ApplicationReport> getApplicationList()
+ throws YarnRemoteException {
+ GetAllApplicationsRequest request =
+ Records.newRecord(GetAllApplicationsRequest.class);
+ GetAllApplicationsResponse response = rmClient.getAllApplications(request);
+ return response.getApplicationList();
+ }
+
+ @Override
+ public YarnClusterMetrics getYarnClusterMetrics() throws YarnRemoteException {
+ GetClusterMetricsRequest request =
+ Records.newRecord(GetClusterMetricsRequest.class);
+ GetClusterMetricsResponse response = rmClient.getClusterMetrics(request);
+ return response.getClusterMetrics();
+ }
+
+ @Override
+ public List<NodeReport> getNodeReports() throws YarnRemoteException {
+ GetClusterNodesRequest request =
+ Records.newRecord(GetClusterNodesRequest.class);
+ GetClusterNodesResponse response = rmClient.getClusterNodes(request);
+ return response.getNodeReports();
+ }
+
+ @Override
+ public DelegationToken getRMDelegationToken(Text renewer)
+ throws YarnRemoteException {
+ /* get the token from RM */
+ GetDelegationTokenRequest rmDTRequest =
+ Records.newRecord(GetDelegationTokenRequest.class);
+ rmDTRequest.setRenewer(renewer.toString());
+ GetDelegationTokenResponse response =
+ rmClient.getDelegationToken(rmDTRequest);
+ return response.getRMDelegationToken();
+ }
+
+ private GetQueueInfoRequest
+ getQueueInfoRequest(String queueName, boolean includeApplications,
+ boolean includeChildQueues, boolean recursive) {
+ GetQueueInfoRequest request = Records.newRecord(GetQueueInfoRequest.class);
+ request.setQueueName(queueName);
+ request.setIncludeApplications(includeApplications);
+ request.setIncludeChildQueues(includeChildQueues);
+ request.setRecursive(recursive);
+ return request;
+ }
+
+ @Override
+ public QueueInfo getQueueInfo(String queueName) throws YarnRemoteException {
+ GetQueueInfoRequest request =
+ getQueueInfoRequest(queueName, true, false, false);
+ Records.newRecord(GetQueueInfoRequest.class);
+ return rmClient.getQueueInfo(request).getQueueInfo();
+ }
+
+ @Override
+ public List<QueueUserACLInfo> getQueueAclsInfo() throws YarnRemoteException {
+ GetQueueUserAclsInfoRequest request =
+ Records.newRecord(GetQueueUserAclsInfoRequest.class);
+ return rmClient.getQueueUserAcls(request).getUserAclsInfoList();
+ }
+
+ @Override
+ public List<QueueInfo> getAllQueues() throws YarnRemoteException {
+ List<QueueInfo> queues = new ArrayList<QueueInfo>();
+
+ QueueInfo rootQueue =
+ rmClient.getQueueInfo(getQueueInfoRequest(ROOT, false, true, true))
+ .getQueueInfo();
+ getChildQueues(rootQueue, queues, true);
+ return queues;
+ }
+
+ @Override
+ public List<QueueInfo> getRootQueueInfos() throws YarnRemoteException {
+ List<QueueInfo> queues = new ArrayList<QueueInfo>();
+
+ QueueInfo rootQueue =
+ rmClient.getQueueInfo(getQueueInfoRequest(ROOT, false, true, true))
+ .getQueueInfo();
+ getChildQueues(rootQueue, queues, false);
+ return queues;
+ }
+
+ @Override
+ public List<QueueInfo> getChildQueueInfos(String parent)
+ throws YarnRemoteException {
+ List<QueueInfo> queues = new ArrayList<QueueInfo>();
+
+ QueueInfo parentQueue =
+ rmClient.getQueueInfo(getQueueInfoRequest(parent, false, true, false))
+ .getQueueInfo();
+ getChildQueues(parentQueue, queues, true);
+ return queues;
+ }
+
+ private void getChildQueues(QueueInfo parent, List<QueueInfo> queues,
+ boolean recursive) {
+ List<QueueInfo> childQueues = parent.getChildQueues();
+
+ for (QueueInfo child : childQueues) {
+ queues.add(child);
+ if (recursive) {
+ getChildQueues(child, queues, recursive);
+ }
+ }
+ }
+}
Added: hadoop/common/trunk/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/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java?rev=1381273&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestYarnClient.java Wed Sep 5 17:54:32 2012
@@ -0,0 +1,46 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.client;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.client.YarnClient;
+import org.apache.hadoop.yarn.client.YarnClientImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.junit.Test;
+
+public class TestYarnClient {
+
+ @Test
+ public void test() {
+ // More to come later.
+ }
+
+ @Test
+ public void testClientStop() {
+ Configuration conf = new Configuration();
+ ResourceManager rm = new ResourceManager(null);
+ rm.init(conf);
+ rm.start();
+
+ YarnClient client = new YarnClientImpl();
+ client.init(conf);
+ client.start();
+ client.stop();
+ }
+}