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

项目:hadoop    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request)
    throws YarnException, IOException {
  YarnServiceProtos.GetLabelsToNodesRequestProto requestProto =
      ((GetLabelsToNodesRequestPBImpl) request).getProto();
  try {
    return new GetLabelsToNodesResponsePBImpl(proxy.getLabelsToNodes(
        null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:ClientRMService.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  if (request.getNodeLabels() == null || request.getNodeLabels().isEmpty()) {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsToNodes());
  } else {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsToNodes(request.getNodeLabels()));
  }
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request)
    throws YarnException, IOException {
  YarnServiceProtos.GetLabelsToNodesRequestProto requestProto =
      ((GetLabelsToNodesRequestPBImpl) request).getProto();
  try {
    return new GetLabelsToNodesResponsePBImpl(proxy.getLabelsToNodes(
        null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:aliyun-oss-hadoop-fs    文件:ClientRMService.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  if (request.getNodeLabels() == null || request.getNodeLabels().isEmpty()) {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsInfoToNodes());
  } else {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsInfoToNodes(request.getNodeLabels()));
  }
}
项目:big-c    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request)
    throws YarnException, IOException {
  YarnServiceProtos.GetLabelsToNodesRequestProto requestProto =
      ((GetLabelsToNodesRequestPBImpl) request).getProto();
  try {
    return new GetLabelsToNodesResponsePBImpl(proxy.getLabelsToNodes(
        null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:big-c    文件:ClientRMService.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  if (request.getNodeLabels() == null || request.getNodeLabels().isEmpty()) {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsToNodes());
  } else {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsToNodes(request.getNodeLabels()));
  }
}
项目:hops    文件:ApplicationClientProtocolPBClientImpl.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request)
    throws YarnException, IOException {
  YarnServiceProtos.GetLabelsToNodesRequestProto requestProto =
      ((GetLabelsToNodesRequestPBImpl) request).getProto();
  try {
    return new GetLabelsToNodesResponsePBImpl(proxy.getLabelsToNodes(
        null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hops    文件:ClientRMService.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager();
  if (request.getNodeLabels() == null || request.getNodeLabels().isEmpty()) {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsToNodes());
  } else {
    return GetLabelsToNodesResponse.newInstance(
        labelsMgr.getLabelsToNodes(request.getNodeLabels()));
  }
}
项目:hadoop    文件:TestClientRMService.java   
@Test
public void testGetLabelsToNodes() throws Exception {
  MockRM rm = new MockRM() {
    protected ClientRMService createClientRMService() {
      return new ClientRMService(this.rmContext, scheduler,
          this.rmAppManager, this.applicationACLsManager,
          this.queueACLsManager, this.getRMContext()
              .getRMDelegationTokenSecretManager());
    };
  };
  rm.start();
  RMNodeLabelsManager labelsMgr = rm.getRMContext().getNodeLabelManager();
  labelsMgr.addToCluserNodeLabels(ImmutableSet.of("x", "y", "z"));

  Map<NodeId, Set<String>> map = new HashMap<NodeId, Set<String>>();
  map.put(NodeId.newInstance("host1", 0), ImmutableSet.of("x"));
  map.put(NodeId.newInstance("host1", 1), ImmutableSet.of("z"));
  map.put(NodeId.newInstance("host2", 0), ImmutableSet.of("y"));
  map.put(NodeId.newInstance("host3", 0), ImmutableSet.of("y"));
  map.put(NodeId.newInstance("host3", 1), ImmutableSet.of("z"));
  labelsMgr.replaceLabelsOnNode(map);

  // Create a client.
  Configuration conf = new Configuration();
  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);

  // Get node labels collection
  GetClusterNodeLabelsResponse response =
      client.getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance());
  Assert.assertTrue(response.getNodeLabels().containsAll(
      Arrays.asList("x", "y", "z")));

  // Get labels to nodes mapping
  GetLabelsToNodesResponse response1 =
      client.getLabelsToNodes(GetLabelsToNodesRequest.newInstance());
  Map<String, Set<NodeId>> labelsToNodes = response1.getLabelsToNodes();
  Assert.assertTrue(
      labelsToNodes.keySet().containsAll(Arrays.asList("x", "y", "z")));
  Assert.assertTrue(
      labelsToNodes.get("x").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 0))));
  Assert.assertTrue(
      labelsToNodes.get("y").containsAll(Arrays.asList(
      NodeId.newInstance("host2", 0), NodeId.newInstance("host3", 0))));
  Assert.assertTrue(
      labelsToNodes.get("z").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 1), NodeId.newInstance("host3", 1))));

  // Get labels to nodes mapping for specific labels
  Set<String> setlabels =
      new HashSet<String>(Arrays.asList(new String[]{"x", "z"}));
  GetLabelsToNodesResponse response2 =
      client.getLabelsToNodes(GetLabelsToNodesRequest.newInstance(setlabels));
  labelsToNodes = response2.getLabelsToNodes();
  Assert.assertTrue(
      labelsToNodes.keySet().containsAll(Arrays.asList("x", "z")));
  Assert.assertTrue(
      labelsToNodes.get("x").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 0))));
  Assert.assertTrue(
      labelsToNodes.get("z").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 1), NodeId.newInstance("host3", 1))));
  Assert.assertEquals(labelsToNodes.get("y"), null);

  rpc.stopProxy(client, conf);
  rm.close();
}
项目:hadoop    文件:YarnClientImpl.java   
@Override
public Map<String, Set<NodeId>> getLabelsToNodes() throws YarnException,
    IOException {
  return rmClient.getLabelsToNodes(GetLabelsToNodesRequest.newInstance())
      .getLabelsToNodes();
}
项目:hadoop    文件:YarnClientImpl.java   
@Override
public Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels)
    throws YarnException, IOException {
  return rmClient.getLabelsToNodes(
      GetLabelsToNodesRequest.newInstance(labels)).getLabelsToNodes();
}
项目:hadoop    文件:TestClientRedirect.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  return null;
}
项目:scheduling-connector-for-hadoop    文件:HPCApplicationClientProtocolImpl.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(GetLabelsToNodesRequest arg0)
        throws YarnException, IOException {
    // TODO Auto-generated method stub
    return null;
}
项目:aliyun-oss-hadoop-fs    文件:MockResourceManagerFacade.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  return null;
}
项目:aliyun-oss-hadoop-fs    文件:YarnClientImpl.java   
@Override
public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() throws YarnException,
    IOException {
  return rmClient.getLabelsToNodes(GetLabelsToNodesRequest.newInstance())
      .getLabelsToNodes();
}
项目:aliyun-oss-hadoop-fs    文件:YarnClientImpl.java   
@Override
public Map<NodeLabel, Set<NodeId>> getLabelsToNodes(Set<String> labels)
    throws YarnException, IOException {
  return rmClient.getLabelsToNodes(
      GetLabelsToNodesRequest.newInstance(labels)).getLabelsToNodes();
}
项目:aliyun-oss-hadoop-fs    文件:TestClientRedirect.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  return null;
}
项目:big-c    文件:TestClientRMService.java   
@Test
public void testGetLabelsToNodes() throws Exception {
  MockRM rm = new MockRM() {
    protected ClientRMService createClientRMService() {
      return new ClientRMService(this.rmContext, scheduler,
          this.rmAppManager, this.applicationACLsManager,
          this.queueACLsManager, this.getRMContext()
              .getRMDelegationTokenSecretManager());
    };
  };
  rm.start();
  RMNodeLabelsManager labelsMgr = rm.getRMContext().getNodeLabelManager();
  labelsMgr.addToCluserNodeLabels(ImmutableSet.of("x", "y", "z"));

  Map<NodeId, Set<String>> map = new HashMap<NodeId, Set<String>>();
  map.put(NodeId.newInstance("host1", 0), ImmutableSet.of("x"));
  map.put(NodeId.newInstance("host1", 1), ImmutableSet.of("z"));
  map.put(NodeId.newInstance("host2", 0), ImmutableSet.of("y"));
  map.put(NodeId.newInstance("host3", 0), ImmutableSet.of("y"));
  map.put(NodeId.newInstance("host3", 1), ImmutableSet.of("z"));
  labelsMgr.replaceLabelsOnNode(map);

  // Create a client.
  Configuration conf = new Configuration();
  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);

  // Get node labels collection
  GetClusterNodeLabelsResponse response =
      client.getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance());
  Assert.assertTrue(response.getNodeLabels().containsAll(
      Arrays.asList("x", "y", "z")));

  // Get labels to nodes mapping
  GetLabelsToNodesResponse response1 =
      client.getLabelsToNodes(GetLabelsToNodesRequest.newInstance());
  Map<String, Set<NodeId>> labelsToNodes = response1.getLabelsToNodes();
  Assert.assertTrue(
      labelsToNodes.keySet().containsAll(Arrays.asList("x", "y", "z")));
  Assert.assertTrue(
      labelsToNodes.get("x").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 0))));
  Assert.assertTrue(
      labelsToNodes.get("y").containsAll(Arrays.asList(
      NodeId.newInstance("host2", 0), NodeId.newInstance("host3", 0))));
  Assert.assertTrue(
      labelsToNodes.get("z").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 1), NodeId.newInstance("host3", 1))));

  // Get labels to nodes mapping for specific labels
  Set<String> setlabels =
      new HashSet<String>(Arrays.asList(new String[]{"x", "z"}));
  GetLabelsToNodesResponse response2 =
      client.getLabelsToNodes(GetLabelsToNodesRequest.newInstance(setlabels));
  labelsToNodes = response2.getLabelsToNodes();
  Assert.assertTrue(
      labelsToNodes.keySet().containsAll(Arrays.asList("x", "z")));
  Assert.assertTrue(
      labelsToNodes.get("x").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 0))));
  Assert.assertTrue(
      labelsToNodes.get("z").containsAll(Arrays.asList(
      NodeId.newInstance("host1", 1), NodeId.newInstance("host3", 1))));
  Assert.assertEquals(labelsToNodes.get("y"), null);

  rpc.stopProxy(client, conf);
  rm.close();
}
项目:big-c    文件:YarnClientImpl.java   
@Override
public Map<String, Set<NodeId>> getLabelsToNodes() throws YarnException,
    IOException {
  return rmClient.getLabelsToNodes(GetLabelsToNodesRequest.newInstance())
      .getLabelsToNodes();
}
项目:big-c    文件:YarnClientImpl.java   
@Override
public Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels)
    throws YarnException, IOException {
  return rmClient.getLabelsToNodes(
      GetLabelsToNodesRequest.newInstance(labels)).getLabelsToNodes();
}
项目:big-c    文件:TestClientRedirect.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  return null;
}
项目:hops    文件:MockResourceManagerFacade.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  return null;
}
项目:hops    文件:TestClientRMService.java   
@Test
public void testGetLabelsToNodes() throws Exception {
  MockRM rm = new MockRM() {
    protected ClientRMService createClientRMService() {
      return new ClientRMService(this.rmContext, scheduler,
          this.rmAppManager, this.applicationACLsManager,
          this.queueACLsManager, this.getRMContext()
              .getRMDelegationTokenSecretManager());
    };
  };
  rm.start();

  NodeLabel labelX = NodeLabel.newInstance("x", false);
  NodeLabel labelY = NodeLabel.newInstance("y", false);
  NodeLabel labelZ = NodeLabel.newInstance("z", false);
  RMNodeLabelsManager labelsMgr = rm.getRMContext().getNodeLabelManager();
  labelsMgr.addToCluserNodeLabels(ImmutableSet.of(labelX, labelY, labelZ));

  NodeId node1A = NodeId.newInstance("host1", 1234);
  NodeId node1B = NodeId.newInstance("host1", 5678);
  NodeId node2A = NodeId.newInstance("host2", 1234);
  NodeId node3A = NodeId.newInstance("host3", 1234);
  NodeId node3B = NodeId.newInstance("host3", 5678);
  Map<NodeId, Set<String>> map = new HashMap<NodeId, Set<String>>();
  map.put(node1A, ImmutableSet.of("x"));
  map.put(node1B, ImmutableSet.of("z"));
  map.put(node2A, ImmutableSet.of("y"));
  map.put(node3A, ImmutableSet.of("y"));
  map.put(node3B, ImmutableSet.of("z"));
  labelsMgr.replaceLabelsOnNode(map);

  // Create a client.
  Configuration conf = new Configuration();
  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);

  // Get node labels collection
  GetClusterNodeLabelsResponse response = client
      .getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance());
  Assert.assertTrue(response.getNodeLabelList().containsAll(
      Arrays.asList(labelX, labelY, labelZ)));

  // Get labels to nodes mapping
  GetLabelsToNodesResponse response1 = client
      .getLabelsToNodes(GetLabelsToNodesRequest.newInstance());
  Map<String, Set<NodeId>> labelsToNodes = response1.getLabelsToNodes();
  Assert.assertTrue(labelsToNodes.keySet().containsAll(
      Arrays.asList(labelX.getName(), labelY.getName(), labelZ.getName())));
  Assert.assertTrue(labelsToNodes.get(labelX.getName()).containsAll(
      Arrays.asList(node1A)));
  Assert.assertTrue(labelsToNodes.get(labelY.getName()).containsAll(
      Arrays.asList(node2A, node3A)));
  Assert.assertTrue(labelsToNodes.get(labelZ.getName()).containsAll(
      Arrays.asList(node1B, node3B)));

  // Get labels to nodes mapping for specific labels
  Set<String> setlabels = new HashSet<String>(Arrays.asList(new String[]{"x",
      "z"}));
  GetLabelsToNodesResponse response2 = client
      .getLabelsToNodes(GetLabelsToNodesRequest.newInstance(setlabels));
  labelsToNodes = response2.getLabelsToNodes();
  Assert.assertTrue(labelsToNodes.keySet().containsAll(
      Arrays.asList(labelX.getName(), labelZ.getName())));
  Assert.assertTrue(labelsToNodes.get(labelX.getName()).containsAll(
      Arrays.asList(node1A)));
  Assert.assertTrue(labelsToNodes.get(labelZ.getName()).containsAll(
      Arrays.asList(node1B, node3B)));
  Assert.assertEquals(labelsToNodes.get(labelY.getName()), null);

  rpc.stopProxy(client, conf);
  rm.close();
}
项目:hops    文件:YarnClientImpl.java   
@Override
public Map<String, Set<NodeId>> getLabelsToNodes() throws YarnException,
    IOException {
  return rmClient.getLabelsToNodes(GetLabelsToNodesRequest.newInstance())
      .getLabelsToNodes();
}
项目:hops    文件:YarnClientImpl.java   
@Override
public Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels)
    throws YarnException, IOException {
  return rmClient.getLabelsToNodes(
      GetLabelsToNodesRequest.newInstance(labels)).getLabelsToNodes();
}
项目:hops    文件:TestYarnClient.java   
@Override
public void start() {
  rmClient = mock(ApplicationClientProtocol.class);
  GetApplicationReportResponse mockResponse =
      mock(GetApplicationReportResponse.class);
  mockReport = mock(ApplicationReport.class);
  try{
    when(rmClient.getApplicationReport(any(
        GetApplicationReportRequest.class))).thenReturn(mockResponse);
    when(rmClient.getApplications(any(GetApplicationsRequest.class)))
        .thenReturn(mockAppResponse);
    // return false for 1st kill request, and true for the 2nd.
    when(rmClient.forceKillApplication(any(
      KillApplicationRequest.class)))
      .thenReturn(KillApplicationResponse.newInstance(false)).thenReturn(
        KillApplicationResponse.newInstance(true));
    when(
        rmClient
            .getApplicationAttemptReport(any(GetApplicationAttemptReportRequest.class)))
        .thenReturn(mockAttemptResponse);
    when(
        rmClient
            .getApplicationAttempts(any(GetApplicationAttemptsRequest.class)))
        .thenReturn(mockAppAttemptsResponse);
    when(rmClient.getContainers(any(GetContainersRequest.class)))
        .thenReturn(mockContainersResponse);

    when(rmClient.getContainerReport(any(GetContainerReportRequest.class)))
        .thenReturn(mockContainerResponse);

    when(rmClient.getLabelsToNodes(any(GetLabelsToNodesRequest.class)))
        .thenReturn(mockLabelsToNodesResponse);

    when(rmClient.getNodeToLabels(any(GetNodesToLabelsRequest.class)))
        .thenReturn(mockNodeToLabelsResponse);

    historyClient = mock(AHSClient.class);

  } catch (Exception e) {
    Assert.fail("Unexpected exception caught: " + e);
  }

  when(mockResponse.getApplicationReport()).thenReturn(mockReport);
}
项目:hops    文件:TestClientRedirect.java   
@Override
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException {
  return null;
}
项目:hadoop    文件:ApplicationClientProtocol.java   
/**
 * <p>
 * The interface used by client to get labels to nodes mappings
 * in existing cluster
 * </p>
 *
 * @param request
 * @return labels to nodes mappings
 * @throws YarnException
 * @throws IOException
 */
@Public
@Unstable
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException;
项目:aliyun-oss-hadoop-fs    文件:ApplicationClientProtocol.java   
/**
 * <p>
 * The interface used by client to get labels to nodes mappings
 * in existing cluster
 * </p>
 *
 * @param request
 * @return labels to nodes mappings
 * @throws YarnException
 * @throws IOException
 */
@Public
@Unstable
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException;
项目:big-c    文件:ApplicationClientProtocol.java   
/**
 * <p>
 * The interface used by client to get labels to nodes mappings
 * in existing cluster
 * </p>
 *
 * @param request
 * @return labels to nodes mappings
 * @throws YarnException
 * @throws IOException
 */
@Public
@Unstable
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException;
项目:hops    文件:ApplicationClientProtocol.java   
/**
 * <p>
 * The interface used by client to get labels to nodes mappings
 * in existing cluster
 * </p>
 *
 * @param request
 * @return labels to nodes mappings
 * @throws YarnException
 * @throws IOException
 */
@Public
@Unstable
public GetLabelsToNodesResponse getLabelsToNodes(
    GetLabelsToNodesRequest request) throws YarnException, IOException;