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

项目:hadoop    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:aliyun-oss-hadoop-fs    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:big-c    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hadoop-plus    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hops    文件:TestYarnSSLServer.java   
@Override
public void run() {
    EnumSet<NodeState> filter = EnumSet.of(NodeState.RUNNING);
    GetClusterNodesRequest req = GetClusterNodesRequest.newInstance();
    req.setNodeStates(filter);
    LOG.debug("Sending cluster nodes request from first client");
    try {
        TimeUnit.SECONDS.sleep(1);
        GetClusterNodesResponse res = client.getClusterNodes(req);
        assertNotNull("Response from the first client should not be null", res);
        LOG.debug("NodeReports: " + res.getNodeReports().size());
        for (NodeReport nodeReport : res.getNodeReports()) {
            LOG.debug("Node: " + nodeReport.getNodeId() + " Capability: " + nodeReport.getCapability());
        }
    } catch (Exception ex) {
        LOG.error(ex, ex);
    }
}
项目:hops    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response =
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hadoop-TCP    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);
  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hardfs    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hadoop-on-lustre2    文件:ClientRMService.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException {
  GetClusterNodesResponse response = 
    recordFactory.newRecordInstance(GetClusterNodesResponse.class);
  EnumSet<NodeState> nodeStates = request.getNodeStates();
  if (nodeStates == null || nodeStates.isEmpty()) {
    nodeStates = EnumSet.allOf(NodeState.class);
  }
  Collection<RMNode> nodes = RMServerUtils.queryRMNodes(rmContext,
      nodeStates);

  List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size());
  for (RMNode nodeInfo : nodes) {
    nodeReports.add(createNodeReports(nodeInfo));
  }
  response.setNodeReports(nodeReports);
  return response;
}
项目:hadoop    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hadoop    文件:ProtocolHATestBase.java   
@Override
public GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

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

  // create GetClusterNodesResponse with fake ClusterNodeLists
  GetClusterNodesResponse response =
      GetClusterNodesResponse.newInstance(createFakeNodeReports());
  return response;
}
项目:scheduling-connector-for-hadoop    文件:HPCApplicationClientProtocolImpl.java   
@Override
public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
    throws YarnException, IOException {
  List<NodeReport> clusterNodes = appClient.getClusterNodes(request
      .getNodeStates());
  return GetClusterNodesResponse.newInstance(clusterNodes);
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:aliyun-oss-hadoop-fs    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:aliyun-oss-hadoop-fs    文件:ProtocolHATestBase.java   
@Override
public GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

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

  // create GetClusterNodesResponse with fake ClusterNodeLists
  GetClusterNodesResponse response =
      GetClusterNodesResponse.newInstance(createFakeNodeReports());
  return response;
}
项目:big-c    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:big-c    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:big-c    文件:ProtocolHATestBase.java   
@Override
public GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

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

  // create GetClusterNodesResponse with fake ClusterNodeLists
  GetClusterNodesResponse response =
      GetClusterNodesResponse.newInstance(createFakeNodeReports());
  return response;
}
项目:apex-core    文件:StramMiniClusterTest.java   
private void checkNodeState() throws YarnException
{
  GetClusterNodesRequest request = Records.newRecord(GetClusterNodesRequest.class);
  ClientRMService clientRMService = yarnCluster.getResourceManager().getClientRMService();
  GetClusterNodesResponse response = clientRMService.getClusterNodes(request);
  List<NodeReport> nodeReports = response.getNodeReports();
  LOG.info("{}", nodeReports);

  for (NodeReport nr: nodeReports) {
    if (!nr.getNodeState().isUnusable()) {
      return;
    }
  }
  fail("Yarn Mini cluster should have at least one usable node.");
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ProtocolHATestBase.java   
@Override
public GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

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

  // create GetClusterNodesResponse with fake ClusterNodeLists
  GetClusterNodesResponse response =
      GetClusterNodesResponse.newInstance(createFakeNodeReports());
  return response;
}
项目:hadoop-plus    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-plus    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hops    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hops    文件:TestYarnSSLServer.java   
@Test(timeout = 3000)
public void testRpcCall() throws Exception {
    EnumSet<NodeState> filter = EnumSet.of(NodeState.RUNNING);
    GetClusterNodesRequest req = GetClusterNodesRequest.newInstance();
    req.setNodeStates(filter);
    LOG.debug("Sending request");
    GetClusterNodesResponse res = acClient.getClusterNodes(req);
    LOG.debug("Got response from server");
    assertNotNull("Response should not be null", res);
    List<NodeReport> reports = res.getNodeReports();
    LOG.debug("Printing cluster nodes report");
    for (NodeReport report : reports) {
        LOG.debug("NodeId: " + report.getNodeId().toString());
    }
}
项目:hops    文件:TestClientRMService.java   
@Test
public void testRMStartWithDecommissionedNode() throws Exception {
  String excludeFile = "excludeFile";
  createExcludeFile(excludeFile);
  YarnConfiguration conf = new YarnConfiguration();
  conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, excludeFile);
  MockRM rm = new MockRM(conf) {
    protected ClientRMService createClientRMService() {
      return new ClientRMService(this.rmContext, scheduler, this.rmAppManager,
          this.applicationACLsManager, this.queueACLsManager,
          this.getRMContext().getRMDelegationTokenSecretManager());
    }

    ;
  };
  rm.start();

  YarnRPC rpc = YarnRPC.create(conf);
  InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress();
  LOG.info("Connecting to ResourceManager at " + rmAddress);
  ApplicationClientProtocol client = (ApplicationClientProtocol) rpc
      .getProxy(ApplicationClientProtocol.class, rmAddress, conf);

  // Make call
  GetClusterNodesRequest request =
      GetClusterNodesRequest.newInstance(EnumSet.allOf(NodeState.class));
  List<NodeReport> nodeReports = client.getClusterNodes(request).getNodeReports();
  Assert.assertEquals(1, nodeReports.size());

  rm.stop();
  rpc.stopProxy(client, conf);
  new File(excludeFile).delete();
}
项目:hops    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hops    文件:ProtocolHATestBase.java   
@Override
public GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

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

  // create GetClusterNodesResponse with fake ClusterNodeLists
  GetClusterNodesResponse response =
      GetClusterNodesResponse.newInstance(createFakeNodeReports());
  return response;
}
项目:hadoop-TCP    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-TCP    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hardfs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hardfs    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hadoop-on-lustre2    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetClusterNodesResponse
    getClusterNodes(GetClusterNodesRequest request)
        throws YarnException, IOException {
  GetClusterNodesRequestProto requestProto =
      ((GetClusterNodesRequestPBImpl) request).getProto();
  try {
    return new GetClusterNodesResponsePBImpl(proxy.getClusterNodes(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-on-lustre2    文件:YarnClientImpl.java   
@Override
public List<NodeReport> getNodeReports(NodeState... states) throws YarnException,
    IOException {
  EnumSet<NodeState> statesSet = (states.length == 0) ?
      EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
  for (NodeState state : states) {
    statesSet.add(state);
  }
  GetClusterNodesRequest request = GetClusterNodesRequest
      .newInstance(statesSet);
  GetClusterNodesResponse response = rmClient.getClusterNodes(request);
  return response.getNodeReports();
}
项目:hadoop-on-lustre2    文件:ProtocolHATestBase.java   
@Override
public GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request)
    throws YarnException {
  resetStartFailoverFlag(true);

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

  // create GetClusterNodesResponse with fake ClusterNodeLists
  GetClusterNodesResponse response =
      GetClusterNodesResponse.newInstance(createFakeNodeReports());
  return response;
}
项目: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 GetClusterNodesResponse getClusterNodes(
    GetClusterNodesRequest request) throws IOException {
  return null;
}