Java 类org.apache.hadoop.yarn.api.records.NodeLabel 实例源码

项目:hadoop    文件:TestRMNodeLabelsManager.java   
@Test(timeout = 5000)
public void testPullRMNodeLabelsInfo() throws IOException {
  mgr.addToCluserNodeLabels(toSet("x", "y", "z"));
  mgr.activateNode(NodeId.newInstance("n1", 1), Resource.newInstance(10, 0, 0));
  mgr.activateNode(NodeId.newInstance("n2", 1), Resource.newInstance(10, 0, 0));
  mgr.activateNode(NodeId.newInstance("n3", 1), Resource.newInstance(10, 0, 0));
  mgr.activateNode(NodeId.newInstance("n4", 1), Resource.newInstance(10, 0, 0));
  mgr.activateNode(NodeId.newInstance("n5", 1), Resource.newInstance(10, 0, 0));
  mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("x"),
      toNodeId("n2"), toSet("x"), toNodeId("n3"), toSet("y")));

  // x, y, z and ""
  List<NodeLabel> infos = mgr.pullRMNodeLabelsInfo();
  Assert.assertEquals(4, infos.size());
  checkNodeLabelInfo(infos, RMNodeLabelsManager.NO_LABEL, 2, 20);
  checkNodeLabelInfo(infos, "x", 2, 20);
  checkNodeLabelInfo(infos, "y", 1, 10);
  checkNodeLabelInfo(infos, "z", 0, 0);
}
项目:aliyun-oss-hadoop-fs    文件:CommonNodeLabelsManager.java   
private void checkExclusivityMatch(Collection<NodeLabel> labels)
    throws IOException {
  ArrayList<NodeLabel> mismatchlabels = new ArrayList<NodeLabel>();
  for (NodeLabel label : labels) {
    RMNodeLabel rmNodeLabel = this.labelCollections.get(label.getName());
    if (rmNodeLabel != null
        && rmNodeLabel.getIsExclusive() != label.isExclusive()) {
      mismatchlabels.add(label);
    }
  }
  if (mismatchlabels.size() > 0) {
    throw new IOException(
        "Exclusivity cannot be modified for an existing label with : "
            + StringUtils.join(mismatchlabels.iterator(), ","));
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterCLI.java   
@Test
public void testGetClusterNodeLabels() throws Exception {
  YarnClient client = mock(YarnClient.class);
  when(client.getClusterNodeLabels()).thenReturn(
      Arrays.asList(NodeLabel.newInstance("label1"),
          NodeLabel.newInstance("label2")));
  ClusterCLI cli = new ClusterCLI();
  cli.setClient(client);
  cli.setSysOutPrintStream(sysOut);
  cli.setSysErrPrintStream(sysErr);

  int rc =
      cli.run(new String[] { ClusterCLI.CMD, "-" + ClusterCLI.LIST_LABELS_CMD });
  assertEquals(0, rc);

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter pw = new PrintWriter(baos);
  pw.print("Node Labels: <label1:exclusivity=true>,<label2:exclusivity=true>");
  pw.close();
  verify(sysOut).println(baos.toString("UTF-8"));
}
项目:aliyun-oss-hadoop-fs    文件:TestYarnClient.java   
@Test (timeout = 10000)
public void testGetLabelsToNodes() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  // Get labels to nodes mapping
  Map<NodeLabel, Set<NodeId>> expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap();
  Map<NodeLabel, Set<NodeId>> labelsToNodes = client.getLabelsToNodes();
  Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
  Assert.assertEquals(labelsToNodes.size(), 3);

  // Get labels to nodes for selected labels
  Set<String> setLabels = new HashSet<String>(Arrays.asList("x", "z"));
  expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap(setLabels);
  labelsToNodes = client.getLabelsToNodes(setLabels);
  Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
  Assert.assertEquals(labelsToNodes.size(), 2);

  client.stop();
  client.close();
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterCLI.java   
@Test
public void testGetEmptyClusterNodeLabels() throws Exception {
  YarnClient client = mock(YarnClient.class);
  when(client.getClusterNodeLabels()).thenReturn(new ArrayList<NodeLabel>());
  ClusterCLI cli = new ClusterCLI();
  cli.setClient(client);
  cli.setSysOutPrintStream(sysOut);
  cli.setSysErrPrintStream(sysErr);

  int rc =
      cli.run(new String[] { ClusterCLI.CMD, "-" + ClusterCLI.LIST_LABELS_CMD });
  assertEquals(0, rc);

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter pw = new PrintWriter(baos);
  pw.print("Node Labels: ");
  pw.close();
  verify(sysOut).println(baos.toString("UTF-8"));
}
项目:aliyun-oss-hadoop-fs    文件:GetLabelsToNodesResponsePBImpl.java   
private void initLabelsToNodes() {
  if (this.labelsToNodes != null) {
    return;
  }
  GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList();
  this.labelsToNodes = new HashMap<NodeLabel, Set<NodeId>>();

  for (LabelsToNodeIdsProto c : list) {
    Set<NodeId> setNodes = new HashSet<NodeId>();
    for(NodeIdProto n : c.getNodeIdList()) {
      NodeId node = new NodeIdPBImpl(n);
      setNodes.add(node);
    }
    if (!setNodes.isEmpty()) {
      this.labelsToNodes
          .put(new NodeLabelPBImpl(c.getNodeLabels()), setNodes);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:GetNodesToLabelsResponsePBImpl.java   
private void initNodeToLabels() {
  if (this.nodeToLabels != null) {
    return;
  }
  GetNodesToLabelsResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<NodeIdToLabelsInfoProto> list = p.getNodeToLabelsList();
  this.nodeToLabels = new HashMap<NodeId, Set<NodeLabel>>();

  for (NodeIdToLabelsInfoProto c : list) {
    Set<NodeLabel> labels = new HashSet<NodeLabel>();
    for (NodeLabelProto l : c.getNodeLabelsList()) {
      labels.add(new NodeLabelPBImpl(l));
    }
    this.nodeToLabels.put(new NodeIdPBImpl(c.getNodeId()), labels);
  }
}
项目:aliyun-oss-hadoop-fs    文件:NodeHeartbeatRequestPBImpl.java   
private void mergeLocalToBuilder() {
  if (this.nodeStatus != null) {
    builder.setNodeStatus(convertToProtoFormat(this.nodeStatus));
  }
  if (this.lastKnownContainerTokenMasterKey != null) {
    builder.setLastKnownContainerTokenMasterKey(
        convertToProtoFormat(this.lastKnownContainerTokenMasterKey));
  }
  if (this.lastKnownNMTokenMasterKey != null) {
    builder.setLastKnownNmTokenMasterKey(
        convertToProtoFormat(this.lastKnownNMTokenMasterKey));
  }
  if (this.labels != null) {
    builder.clearNodeLabels();
    Builder newBuilder = NodeLabelsProto.newBuilder();
    for (NodeLabel label : labels) {
      newBuilder.addNodeLabels(convertToProtoFormat(label));
    }
    builder.setNodeLabels(newBuilder.build());
  }
  if (this.logAggregationReportsForApps != null) {
    addLogAggregationStatusForAppsToProto();
  }
}
项目:aliyun-oss-hadoop-fs    文件:CapacitySchedulerPage.java   
private void renderCommonLeafQueueInfo(ResponseInfo ri) {
  ri.
  _("Num Schedulable Applications:", Integer.toString(lqinfo.getNumActiveApplications())).
  _("Num Non-Schedulable Applications:", Integer.toString(lqinfo.getNumPendingApplications())).
  _("Num Containers:", Integer.toString(lqinfo.getNumContainers())).
  _("Max Applications:", Integer.toString(lqinfo.getMaxApplications())).
  _("Max Applications Per User:", Integer.toString(lqinfo.getMaxApplicationsPerUser())).
  _("Max Application Master Resources:", lqinfo.getAMResourceLimit().toString()).
  _("Used Application Master Resources:", lqinfo.getUsedAMResource().toString()).
  _("Max Application Master Resources Per User:", lqinfo.getUserAMResourceLimit().toString()).
  _("Configured Minimum User Limit Percent:", Integer.toString(lqinfo.getUserLimit()) + "%").
  _("Configured User Limit Factor:", lqinfo.getUserLimitFactor()).
  _("Accessible Node Labels:", StringUtils.join(",", lqinfo.getNodeLabels())).
  _("Ordering Policy: ", lqinfo.getOrderingPolicyInfo()).
  _("Preemption:", lqinfo.getPreemptionDisabled() ? "disabled" : "enabled").
  _("Default Node Label Expression:",
          lqinfo.getDefaultNodeLabelExpression() == null
              ? NodeLabel.DEFAULT_NODE_LABEL_PARTITION
              : lqinfo.getDefaultNodeLabelExpression()).
  _("Default Application Priority:",
          Integer.toString(lqinfo.getDefaultApplicationPriority()));
}
项目:aliyun-oss-hadoop-fs    文件:FiCaSchedulerApp.java   
protected void getPendingAppDiagnosticMessage(
    StringBuilder diagnosticMessage) {
  LeafQueue queue = getCSLeafQueue();
  diagnosticMessage.append(" Details : AM Partition = ");
  diagnosticMessage.append(appAMNodePartitionName.isEmpty()
      ? NodeLabel.DEFAULT_NODE_LABEL_PARTITION : appAMNodePartitionName);
  diagnosticMessage.append("; ");
  diagnosticMessage.append("AM Resource Request = ");
  diagnosticMessage.append(getAMResource(appAMNodePartitionName));
  diagnosticMessage.append("; ");
  diagnosticMessage.append("Queue Resource Limit for AM = ");
  diagnosticMessage
      .append(queue.getAMResourceLimitPerPartition(appAMNodePartitionName));
  diagnosticMessage.append("; ");
  diagnosticMessage.append("User AM Resource Limit of the queue = ");
  diagnosticMessage.append(
      queue.getUserAMResourceLimitPerPartition(appAMNodePartitionName));
  diagnosticMessage.append("; ");
  diagnosticMessage.append("Queue AM Resource Usage = ");
  diagnosticMessage.append(
      queue.getQueueResourceUsage().getAMUsed(appAMNodePartitionName));
  diagnosticMessage.append("; ");
}
项目:aliyun-oss-hadoop-fs    文件:FiCaSchedulerApp.java   
protected void getActivedAppDiagnosticMessage(
    StringBuilder diagnosticMessage) {
  LeafQueue queue = getCSLeafQueue();
  QueueCapacities queueCapacities = queue.getQueueCapacities();
  diagnosticMessage.append(" Details : AM Partition = ");
  diagnosticMessage.append(appAMNodePartitionName.isEmpty()
      ? NodeLabel.DEFAULT_NODE_LABEL_PARTITION : appAMNodePartitionName);
  diagnosticMessage.append(" ; ");
  diagnosticMessage.append("Partition Resource = ");
  diagnosticMessage.append(rmContext.getNodeLabelManager()
      .getResourceByLabel(appAMNodePartitionName, Resources.none()));
  diagnosticMessage.append(" ; ");
  diagnosticMessage.append("Queue's Absolute capacity = ");
  diagnosticMessage.append(
      queueCapacities.getAbsoluteCapacity(appAMNodePartitionName) * 100);
  diagnosticMessage.append(" % ; ");
  diagnosticMessage.append("Queue's Absolute used capacity = ");
  diagnosticMessage.append(
      queueCapacities.getAbsoluteUsedCapacity(appAMNodePartitionName) * 100);
  diagnosticMessage.append(" % ; ");
  diagnosticMessage.append("Queue's Absolute max capacity = ");
  diagnosticMessage.append(
      queueCapacities.getAbsoluteMaximumCapacity(appAMNodePartitionName)
          * 100);
  diagnosticMessage.append(" % ; ");
}
项目:hadoop    文件:TestRMNodeLabelsManager.java   
private void checkNodeLabelInfo(List<NodeLabel> infos, String labelName, int activeNMs, int memory) {
  for (NodeLabel info : infos) {
    if (info.getLabelName().equals(labelName)) {
      Assert.assertEquals(activeNMs, info.getNumActiveNMs());
      Assert.assertEquals(memory, info.getResource().getMemory());
      return;
    }
  }
  Assert.fail("Failed to find info has label=" + labelName);
}
项目:aliyun-oss-hadoop-fs    文件:RMNodeLabel.java   
protected RMNodeLabel(String labelName, Resource res, int activeNMs,
    boolean exclusive) {
  this.labelName = labelName;
  this.resource = res;
  this.numActiveNMs = activeNMs;
  this.nodeIds = new HashSet<NodeId>();
  this.exclusive = exclusive;
  this.nodeLabel = NodeLabel.newInstance(labelName, exclusive);
}
项目:aliyun-oss-hadoop-fs    文件:CommonNodeLabelsManager.java   
/**
 * Add multiple node labels to repository
 *
 * @param labels
 *          new node labels added
 */
@VisibleForTesting
public void addToCluserNodeLabelsWithDefaultExclusivity(Set<String> labels)
    throws IOException {
  Set<NodeLabel> nodeLabels = new HashSet<NodeLabel>();
  for (String label : labels) {
    nodeLabels.add(NodeLabel.newInstance(label));
  }
  addToCluserNodeLabels(nodeLabels);
}
项目:aliyun-oss-hadoop-fs    文件:CommonNodeLabelsManager.java   
/**
 * Get mapping of labels to nodes for all the labels.
 *
 * @return labels to nodes map
 */
public Map<NodeLabel, Set<NodeId>> getLabelsInfoToNodes() {
  try {
    readLock.lock();
    return getLabelsInfoToNodes(labelCollections.keySet());
  } finally {
    readLock.unlock();
  }
}
项目:aliyun-oss-hadoop-fs    文件:CommonNodeLabelsManager.java   
public List<NodeLabel> getClusterNodeLabels() {
  try {
    readLock.lock();
    List<NodeLabel> nodeLabels = new ArrayList<>();
    for (RMNodeLabel label : labelCollections.values()) {
      if (!label.getLabelName().equals(NO_LABEL)) {
        nodeLabels.add(NodeLabel.newInstance(label.getLabelName(),
            label.getIsExclusive()));
      }
    }
    return nodeLabels;
  } finally {
    readLock.unlock();
  }
}
项目:aliyun-oss-hadoop-fs    文件:CommonNodeLabelsManager.java   
public Set<NodeLabel> getLabelsInfoByNode(NodeId nodeId) {
  try {
    readLock.lock();
    Set<String> labels = getLabelsByNode(nodeId, nodeCollections);
    if (labels.isEmpty()) {
      return EMPTY_NODELABEL_SET;
    }
    Set<NodeLabel> nodeLabels = createNodeLabelFromLabelNames(labels);
    return nodeLabels;
  } finally {
    readLock.unlock();
  }
}
项目:aliyun-oss-hadoop-fs    文件:CommonNodeLabelsManager.java   
private Set<NodeLabel> createNodeLabelFromLabelNames(Set<String> labels) {
  Set<NodeLabel> nodeLabels = new HashSet<NodeLabel>();
  for (String label : labels) {
    if (label.equals(NO_LABEL)) {
      continue;
    }
    RMNodeLabel rmLabel = labelCollections.get(label);
    if (rmLabel == null) {
      continue;
    }
    nodeLabels.add(rmLabel.getNodeLabel());
  }
  return nodeLabels;
}
项目:aliyun-oss-hadoop-fs    文件:FileSystemNodeLabelsStore.java   
@Override
public void storeNewClusterNodeLabels(List<NodeLabel> labels)
    throws IOException {
  try {
    ensureAppendEditlogFile();
    editlogOs.writeInt(SerializedLogType.ADD_LABELS.ordinal());
    ((AddToClusterNodeLabelsRequestPBImpl) AddToClusterNodeLabelsRequest
        .newInstance(labels)).getProto().writeDelimitedTo(editlogOs);
  } finally {
    ensureCloseEditlogFile();
  }
}
项目:aliyun-oss-hadoop-fs    文件:GetNodesToLabelsResponse.java   
public static GetNodesToLabelsResponse newInstance(
    Map<NodeId, Set<NodeLabel>> map) {
  GetNodesToLabelsResponse response =
      Records.newRecord(GetNodesToLabelsResponse.class);
  response.setNodeToLabels(map);
  return response;
}
项目:aliyun-oss-hadoop-fs    文件:NullRMNodeLabelsManager.java   
@Override
public void initNodeLabelStore(Configuration conf) {
  this.store = new NodeLabelsStore() {

    @Override
    public void recover()
        throws IOException {
      // do nothing
    }

    @Override
    public void removeClusterNodeLabels(Collection<String> labels)
        throws IOException {
      // do nothing
    }

    @Override
    public void updateNodeToLabelsMappings(
        Map<NodeId, Set<String>> nodeToLabels) throws IOException {
      // do nothing
    }

    @Override
    public void storeNewClusterNodeLabels(List<NodeLabel> label)
        throws IOException {
      // do nothing
    }

    @Override
    public void close() throws IOException {
      // do nothing
    }
  };
}
项目:aliyun-oss-hadoop-fs    文件:GetClusterNodeLabelsResponsePBImpl.java   
@Override
public List<NodeLabel> getNodeLabels() {
  if (this.updatedNodeLabels != null) {
    return this.updatedNodeLabels;
  }
  initLocalNodeLabels();
  return this.updatedNodeLabels;
}
项目:aliyun-oss-hadoop-fs    文件:GetLabelsToNodesResponse.java   
public static GetLabelsToNodesResponse newInstance(
     Map<NodeLabel, Set<NodeId>> map) {
GetLabelsToNodesResponse response =
       Records.newRecord(GetLabelsToNodesResponse.class);
   response.setLabelsToNodes(map);
   return response;
 }
项目:aliyun-oss-hadoop-fs    文件:GetLabelsToNodesResponsePBImpl.java   
@Override
@Public
@Evolving
public void setLabelsToNodes(Map<NodeLabel, Set<NodeId>> map) {
  initLabelsToNodes();
  labelsToNodes.clear();
  labelsToNodes.putAll(map);
}
项目:aliyun-oss-hadoop-fs    文件:GetLabelsToNodesResponsePBImpl.java   
@Override
@Public
@Evolving
public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() {
  initLabelsToNodes();
  return this.labelsToNodes;
}
项目:aliyun-oss-hadoop-fs    文件:AddToClusterNodeLabelsRequestPBImpl.java   
@Override
public void setNodeLabels(List<NodeLabel> updatedNodeLabels) {
  maybeInitBuilder();
  this.updatedNodeLabels = new ArrayList<>();
  if (updatedNodeLabels == null) {
    builder.clearNodeLabels();
    return;
  }
  this.updatedNodeLabels.addAll(updatedNodeLabels);
}
项目:aliyun-oss-hadoop-fs    文件:AddToClusterNodeLabelsRequestPBImpl.java   
private void initLocalNodeLabels() {
  AddToClusterNodeLabelsRequestProtoOrBuilder p = viaProto ? proto : builder;
  List<NodeLabelProto> attributesProtoList = p.getNodeLabelsList();
  this.updatedNodeLabels = new ArrayList<NodeLabel>();
  for (NodeLabelProto r : attributesProtoList) {
    this.updatedNodeLabels.add(convertFromProtoFormat(r));
  }
}
项目:aliyun-oss-hadoop-fs    文件:AddToClusterNodeLabelsRequestPBImpl.java   
@Override
public List<NodeLabel> getNodeLabels() {
  if (this.updatedNodeLabels != null) {
    return this.updatedNodeLabels;
  }
  initLocalNodeLabels();
  return this.updatedNodeLabels;
}
项目:aliyun-oss-hadoop-fs    文件:NodeLabelTestBase.java   
public static void assertLabelInfoMapEquals(
    Map<NodeId, Set<NodeLabel>> expected,
    ImmutableMap<NodeId, Set<NodeLabel>> actual) {
  Assert.assertEquals(expected.size(), actual.size());
  for (NodeId k : expected.keySet()) {
    Assert.assertTrue(actual.containsKey(k));
    assertNLCollectionEquals(expected.get(k), actual.get(k));
  }
}
项目:aliyun-oss-hadoop-fs    文件:NodeLabelTestBase.java   
public static void assertNLCollectionEquals(Collection<NodeLabel> expected,
    Collection<NodeLabel> actual) {
  if (expected == null) {
    Assert.assertNull(actual);
  } else {
    Assert.assertNotNull(actual);
  }

  Set<NodeLabel> expectedSet = new HashSet<>(expected);
  Set<NodeLabel> actualSet = new HashSet<>(actual);
  Assert.assertEquals(expectedSet, actualSet);
  Assert.assertTrue(expectedSet.containsAll(actualSet));
}
项目:aliyun-oss-hadoop-fs    文件:NodeLabelTestBase.java   
public static Set<NodeLabel> toNodeLabelSet(String... nodeLabelsStr) {
  if (null == nodeLabelsStr) {
    return null;
  }
  Set<NodeLabel> labels = new HashSet<>();
  for (String label : nodeLabelsStr) {
    labels.add(NodeLabel.newInstance(label));
  }
  return labels;
}
项目:aliyun-oss-hadoop-fs    文件:ClusterCLI.java   
void printClusterNodeLabels() throws YarnException, IOException {
  List<NodeLabel> nodeLabels = null;
  if (accessLocal) {
    nodeLabels =
        new ArrayList<>(getNodeLabelManagerInstance(getConf()).getClusterNodeLabels());
  } else {
    nodeLabels = new ArrayList<>(client.getClusterNodeLabels());
  }
  sysout.println(String.format("Node Labels: %s",
      StringUtils.join(nodeLabels.iterator(), ",")));
}
项目:aliyun-oss-hadoop-fs    文件:TestCommonNodeLabelsManager.java   
@Test(timeout = 5000)
public void testAddlabelWithExclusivity() throws Exception {
  // Add some label, case will not ignore here
  mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("a", false), NodeLabel.newInstance("b", true)));
  Assert.assertFalse(mgr.isExclusiveNodeLabel("a"));
  Assert.assertTrue(mgr.isExclusiveNodeLabel("b"));
}
项目:aliyun-oss-hadoop-fs    文件:TestCommonNodeLabelsManager.java   
private void verifyNodeLabelAdded(Set<String> expectedAddedLabelNames,
    Collection<NodeLabel> addedNodeLabels) {
  Assert.assertEquals(expectedAddedLabelNames.size(), addedNodeLabels.size());
  for (NodeLabel label : addedNodeLabels) {
    Assert.assertTrue(expectedAddedLabelNames.contains(label.getName()));
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestCommonNodeLabelsManager.java   
@Test(timeout = 5000)
public void testGetNodeLabelsInfo() throws IOException {
  mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", false),
      NodeLabel.newInstance("p2", true), NodeLabel.newInstance("p3", false)));
  mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p2")));
  mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n2"), toSet("p3")));

  assertLabelInfoMapEquals(mgr.getNodeLabelsInfo(), ImmutableMap.of(
      toNodeId("n1"), toSet(NodeLabel.newInstance("p2", true)),
      toNodeId("n2"), toSet(NodeLabel.newInstance("p3", false))));
}
项目:aliyun-oss-hadoop-fs    文件:TestClusterCLI.java   
@Test
public void testGetClusterNodeLabelsWithLocalAccess() throws Exception {
  YarnClient client = mock(YarnClient.class);
  when(client.getClusterNodeLabels()).thenReturn(
      Arrays.asList(NodeLabel.newInstance("remote1"),
          NodeLabel.newInstance("remote2")));
  ClusterCLI cli = new ClusterCLI();
  cli.setClient(client);
  cli.setSysOutPrintStream(sysOut);
  cli.setSysErrPrintStream(sysErr);
  ClusterCLI.localNodeLabelsManager = mock(CommonNodeLabelsManager.class);
  when(ClusterCLI.localNodeLabelsManager.getClusterNodeLabels()).thenReturn(
      Arrays.asList(NodeLabel.newInstance("local1"),
          NodeLabel.newInstance("local2")));

  int rc =
      cli.run(new String[] { ClusterCLI.CMD,
          "-" + ClusterCLI.LIST_LABELS_CMD,
          "-" + ClusterCLI.DIRECTLY_ACCESS_NODE_LABEL_STORE });
  assertEquals(0, rc);

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter pw = new PrintWriter(baos);
  // it should return local* instead of remote*
  pw.print("Node Labels: <local1:exclusivity=true>,<local2:exclusivity=true>");
  pw.close();
  verify(sysOut).println(baos.toString("UTF-8"));
}
项目:aliyun-oss-hadoop-fs    文件:NodeHeartbeatRequest.java   
public static NodeHeartbeatRequest newInstance(NodeStatus nodeStatus,
    MasterKey lastKnownContainerTokenMasterKey,
    MasterKey lastKnownNMTokenMasterKey, Set<NodeLabel> nodeLabels) {
  NodeHeartbeatRequest nodeHeartbeatRequest =
      Records.newRecord(NodeHeartbeatRequest.class);
  nodeHeartbeatRequest.setNodeStatus(nodeStatus);
  nodeHeartbeatRequest
      .setLastKnownContainerTokenMasterKey(lastKnownContainerTokenMasterKey);
  nodeHeartbeatRequest
      .setLastKnownNMTokenMasterKey(lastKnownNMTokenMasterKey);
  nodeHeartbeatRequest.setNodeLabels(nodeLabels);
  return nodeHeartbeatRequest;
}
项目:aliyun-oss-hadoop-fs    文件:RegisterNodeManagerRequest.java   
public static RegisterNodeManagerRequest newInstance(NodeId nodeId,
    int httpPort, Resource resource, String nodeManagerVersionId,
    List<NMContainerStatus> containerStatuses,
    List<ApplicationId> runningApplications, Set<NodeLabel> nodeLabels) {
  RegisterNodeManagerRequest request =
      Records.newRecord(RegisterNodeManagerRequest.class);
  request.setHttpPort(httpPort);
  request.setResource(resource);
  request.setNodeId(nodeId);
  request.setNMVersion(nodeManagerVersionId);
  request.setContainerStatuses(containerStatuses);
  request.setRunningApplications(runningApplications);
  request.setNodeLabels(nodeLabels);
  return request;
}
项目:aliyun-oss-hadoop-fs    文件:TestYarnClient.java   
@Override
public Map<NodeLabel, Set<NodeId>> getLabelsToNodes(Set<String> labels)
    throws YarnException, IOException {
  when(mockLabelsToNodesResponse.getLabelsToNodes()).thenReturn(
      getLabelsToNodesMap(labels));
  return super.getLabelsToNodes(labels);
}
项目:aliyun-oss-hadoop-fs    文件:NodeHeartbeatRequestPBImpl.java   
private void initNodeLabels() {
  if (this.labels != null) {
    return;
  }
  NodeHeartbeatRequestProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasNodeLabels()) {
    labels = null;
    return;
  }
  NodeLabelsProto nodeLabels = p.getNodeLabels();
  labels = new HashSet<NodeLabel>();
  for(NodeLabelProto nlp : nodeLabels.getNodeLabelsList()) {
    labels.add(convertFromProtoFormat(nlp));
  }
}