Java 类org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse 实例源码

项目:hadoop-2.6.0-cdh5.4.3    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, null, null, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);
}
项目:hadoop-plus    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, null, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);
}
项目:hadoop-TCP    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, null, null, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);
}
项目:hardfs    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, null, null, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);
}
项目:hadoop-on-lustre2    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, null, null, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);
}
项目:hadoop    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:ProtocolHATestBase.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // return fake QueueInfo
  return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
}
项目:scheduling-connector-for-hadoop    文件:HPCApplicationClientProtocolImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  QueueInfo queueInfo = QueueInfo.newInstance("default", 10240, 10240, 10240,
      null, null, QueueState.RUNNING, null, null);
  GetQueueInfoResponse queueInfoResponse = GetQueueInfoResponse
      .newInstance(queueInfo);
  return queueInfoResponse;
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:aliyun-oss-hadoop-fs    文件:ProtocolHATestBase.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // return fake QueueInfo
  return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
}
项目:big-c    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:big-c    文件:ProtocolHATestBase.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // return fake QueueInfo
  return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      List<ApplicationAttemptId> apps =
          scheduler.getAppsInQueue(request.getQueueName());
      appReports = new ArrayList<ApplicationReport>(apps.size());
      for (ApplicationAttemptId app : apps) {
        RMApp rmApp = rmContext.getRMApps().get(app.getApplicationId());
        appReports.add(rmApp.createAndGetApplicationReport(null, true));
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ProtocolHATestBase.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // return fake QueueInfo
  return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
}
项目:hadoop-plus    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-plus    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      Collection<RMApp> apps = this.rmContext.getRMApps().values();
      appReports = new ArrayList<ApplicationReport>(
          apps.size());
      for (RMApp app : apps) {
        if (app.getQueue().equals(queueInfo.getQueueName())) {
          appReports.add(app.createAndGetApplicationReport(true));
        }
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:hops    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hops    文件:ProtocolHATestBase.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // return fake QueueInfo
  return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
}
项目:hadoop-TCP    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-TCP    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      Collection<RMApp> apps = this.rmContext.getRMApps().values();
      appReports = new ArrayList<ApplicationReport>(
          apps.size());
      for (RMApp app : apps) {
        if (app.getQueue().equals(queueInfo.getQueueName())) {
          appReports.add(app.createAndGetApplicationReport(null, true));
        }
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:hardfs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hardfs    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      Collection<RMApp> apps = this.rmContext.getRMApps().values();
      appReports = new ArrayList<ApplicationReport>(
          apps.size());
      for (RMApp app : apps) {
        if (app.getQueue().equals(queueInfo.getQueueName())) {
          appReports.add(app.createAndGetApplicationReport(null, true));
        }
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:hadoop-on-lustre2    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  GetQueueInfoRequestProto requestProto =
      ((GetQueueInfoRequestPBImpl) request).getProto();
  try {
    return new GetQueueInfoResponsePBImpl(proxy.getQueueInfo(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-on-lustre2    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      List<ApplicationAttemptId> apps =
          scheduler.getAppsInQueue(request.getQueueName());
      appReports = new ArrayList<ApplicationReport>(apps.size());
      for (ApplicationAttemptId app : apps) {
        RMApp rmApp = rmContext.getRMApps().get(app.getApplicationId());
        appReports.add(rmApp.createAndGetApplicationReport(null, true));
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:hadoop-on-lustre2    文件:ProtocolHATestBase.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // return fake QueueInfo
  return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
}
项目:hadoop    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw RPCUtil.getRemoteException(ie);
  }

  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      List<ApplicationAttemptId> apps =
          scheduler.getAppsInQueue(request.getQueueName());
      appReports = new ArrayList<ApplicationReport>(apps.size());
      for (ApplicationAttemptId app : apps) {
        RMApp rmApp = rmContext.getRMApps().get(app.getApplicationId());
        if (rmApp != null) {
          // Check if user is allowed access to this app
          if (!checkAccess(callerUGI, rmApp.getUser(),
              ApplicationAccessType.VIEW_APP, rmApp)) {
            continue;
          }
          appReports.add(
              rmApp.createAndGetApplicationReport(
                  callerUGI.getUserName(), true));
        }          
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:hadoop    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
  when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), anyString())).thenReturn(true);
  when(mockAclsManager.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(true);

  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager, mockQueueACLsManager, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);

  // Case where user does not have application access
  ApplicationACLsManager mockAclsManager1 =
      mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager1 =
      mock(QueueACLsManager.class);
  when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), anyString())).thenReturn(false);
  when(mockAclsManager1.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(false);

  ClientRMService rmService1 = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager1, mockQueueACLsManager1, null);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request);
  List<ApplicationReport> applications1 = queueInfo1.getQueueInfo()
      .getApplications();
  Assert.assertEquals(0, applications1.size());
}
项目:hadoop    文件:TestYARNRunner.java   
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(KillApplicationResponse.newInstance(true));
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));

  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));

  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
项目:hadoop    文件:TestClientRedirect.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws IOException {
  return null;
}
项目:aliyun-oss-hadoop-fs    文件:MockResourceManagerFacade.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException, IOException {
  throw new NotImplementedException();
}
项目:aliyun-oss-hadoop-fs    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw RPCUtil.getRemoteException(ie);
  }

  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      List<ApplicationAttemptId> apps =
          scheduler.getAppsInQueue(request.getQueueName());
      appReports = new ArrayList<ApplicationReport>(apps.size());
      for (ApplicationAttemptId app : apps) {
        RMApp rmApp = rmContext.getRMApps().get(app.getApplicationId());
        if (rmApp != null) {
          // Check if user is allowed access to this app
          if (!checkAccess(callerUGI, rmApp.getUser(),
              ApplicationAccessType.VIEW_APP, rmApp)) {
            continue;
          }
          appReports.add(
              rmApp.createAndGetApplicationReport(
                  callerUGI.getUserName(), true));
        }          
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:aliyun-oss-hadoop-fs    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
  when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), anyString())).thenReturn(true);
  when(mockAclsManager.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(true);

  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager, mockQueueACLsManager, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);

  // Case where user does not have application access
  ApplicationACLsManager mockAclsManager1 =
      mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager1 =
      mock(QueueACLsManager.class);
  when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), anyString())).thenReturn(false);
  when(mockAclsManager1.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(false);

  ClientRMService rmService1 = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager1, mockQueueACLsManager1, null);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request);
  List<ApplicationReport> applications1 = queueInfo1.getQueueInfo()
      .getApplications();
  Assert.assertEquals(0, applications1.size());
}
项目:aliyun-oss-hadoop-fs    文件:TestYARNRunner.java   
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(KillApplicationResponse.newInstance(true));
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));

  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));

  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
项目:aliyun-oss-hadoop-fs    文件:TestClientRedirect.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws IOException {
  return null;
}
项目:big-c    文件:ClientRMService.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws YarnException {
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw RPCUtil.getRemoteException(ie);
  }

  GetQueueInfoResponse response =
    recordFactory.newRecordInstance(GetQueueInfoResponse.class);
  try {
    QueueInfo queueInfo = 
      scheduler.getQueueInfo(request.getQueueName(),  
          request.getIncludeChildQueues(), 
          request.getRecursive());
    List<ApplicationReport> appReports = EMPTY_APPS_REPORT;
    if (request.getIncludeApplications()) {
      List<ApplicationAttemptId> apps =
          scheduler.getAppsInQueue(request.getQueueName());
      appReports = new ArrayList<ApplicationReport>(apps.size());
      for (ApplicationAttemptId app : apps) {
        RMApp rmApp = rmContext.getRMApps().get(app.getApplicationId());
        if (rmApp != null) {
          // Check if user is allowed access to this app
          if (!checkAccess(callerUGI, rmApp.getUser(),
              ApplicationAccessType.VIEW_APP, rmApp)) {
            continue;
          }
          appReports.add(
              rmApp.createAndGetApplicationReport(
                  callerUGI.getUserName(), true));
        }          
      }
    }
    queueInfo.setApplications(appReports);
    response.setQueueInfo(queueInfo);
  } catch (IOException ioe) {
    LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe);
  }

  return response;
}
项目:big-c    文件:TestClientRMService.java   
@Test
public void testGetQueueInfo() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
  when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), anyString())).thenReturn(true);
  when(mockAclsManager.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(true);

  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager, mockQueueACLsManager, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);

  // Case where user does not have application access
  ApplicationACLsManager mockAclsManager1 =
      mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager1 =
      mock(QueueACLsManager.class);
  when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), anyString())).thenReturn(false);
  when(mockAclsManager1.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(false);

  ClientRMService rmService1 = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager1, mockQueueACLsManager1, null);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request);
  List<ApplicationReport> applications1 = queueInfo1.getQueueInfo()
      .getApplications();
  Assert.assertEquals(0, applications1.size());
}
项目:big-c    文件:TestYARNRunner.java   
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(KillApplicationResponse.newInstance(true));
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));

  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));

  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
项目:big-c    文件:TestClientRedirect.java   
@Override
public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
    throws IOException {
  return null;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestYARNRunner.java   
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(KillApplicationResponse.newInstance(true));
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));

  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));

  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}