当前位置: 首页>>代码示例>>Java>>正文


Java NodeAction类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.api.records.NodeAction的典型用法代码示例。如果您正苦于以下问题:Java NodeAction类的具体用法?Java NodeAction怎么用?Java NodeAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NodeAction类属于org.apache.hadoop.yarn.server.api.records包,在下文中一共展示了NodeAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newNodeHeartbeatResponse

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
public static NodeHeartbeatResponse newNodeHeartbeatResponse(int responseId,
    NodeAction action, List<ContainerId> containersToCleanUp,
    List<ApplicationId> applicationsToCleanUp,
    MasterKey containerTokenMasterKey, MasterKey nmTokenMasterKey,
    long nextHeartbeatInterval) {
  NodeHeartbeatResponse response = recordFactory
      .newRecordInstance(NodeHeartbeatResponse.class);
  response.setResponseId(responseId);
  response.setNodeAction(action);
  response.setContainerTokenMasterKey(containerTokenMasterKey);
  response.setNMTokenMasterKey(nmTokenMasterKey);
  response.setNextHeartBeatInterval(nextHeartbeatInterval);
  if(containersToCleanUp != null) {
    response.addAllContainersToCleanup(containersToCleanUp);
  }
  if(applicationsToCleanUp != null) {
    response.addAllApplicationsToCleanup(applicationsToCleanUp);
  }
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:YarnServerBuilderUtils.java

示例2: testRegisterNodeManagerResponsePBImpl

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
/**
 * Test RegisterNodeManagerResponsePBImpl. Test getters and setters. The
 * RegisterNodeManagerResponsePBImpl should generate a prototype and data
 * restore from prototype
 */
@Test
public void testRegisterNodeManagerResponsePBImpl() {
  RegisterNodeManagerResponsePBImpl original =
      new RegisterNodeManagerResponsePBImpl();
  original.setContainerTokenMasterKey(getMasterKey());
  original.setNMTokenMasterKey(getMasterKey());
  original.setNodeAction(NodeAction.NORMAL);
  original.setDiagnosticsMessage("testDiagnosticMessage");

  RegisterNodeManagerResponsePBImpl copy =
      new RegisterNodeManagerResponsePBImpl(
          original.getProto());
  assertEquals(1, copy.getContainerTokenMasterKey().getKeyId());
  assertEquals(1, copy.getNMTokenMasterKey().getKeyId());
  assertEquals(NodeAction.NORMAL, copy.getNodeAction());
  assertEquals("testDiagnosticMessage", copy.getDiagnosticsMessage());

}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestYarnServerApiClasses.java

示例3: testNodeHeartbeatResponsePBImpl

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
/**
 * Test NodeHeartbeatResponsePBImpl.
 */

@Test
public void testNodeHeartbeatResponsePBImpl() {
  NodeHeartbeatResponsePBImpl original = new NodeHeartbeatResponsePBImpl();

  original.setDiagnosticsMessage("testDiagnosticMessage");
  original.setContainerTokenMasterKey(getMasterKey());
  original.setNMTokenMasterKey(getMasterKey());
  original.setNextHeartBeatInterval(1000);
  original.setNodeAction(NodeAction.NORMAL);
  original.setResponseId(100);

  NodeHeartbeatResponsePBImpl copy = new NodeHeartbeatResponsePBImpl(
      original.getProto());
  assertEquals(100, copy.getResponseId());
  assertEquals(NodeAction.NORMAL, copy.getNodeAction());
  assertEquals(1000, copy.getNextHeartBeatInterval());
  assertEquals(1, copy.getContainerTokenMasterKey().getKeyId());
  assertEquals(1, copy.getNMTokenMasterKey().getKeyId());
  assertEquals("testDiagnosticMessage", copy.getDiagnosticsMessage());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestYarnServerApiClasses.java

示例4: testNodeDecommision

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNodeDecommision() throws Exception {
  nm = getNodeManager(NodeAction.SHUTDOWN);
  YarnConfiguration conf = createNMConfig();
  nm.init(conf);
  Assert.assertEquals(STATE.INITED, nm.getServiceState());
  nm.start();

  int waitCount = 0;
  while (heartBeatID < 1 && waitCount++ != 200) {
    Thread.sleep(500);
  }
  Assert.assertFalse(heartBeatID < 1);
  Assert.assertTrue(nm.getNMContext().getDecommissioned());

  // NM takes a while to reach the STOPPED state.
  waitCount = 0;
  while (nm.getServiceState() != STATE.STOPPED && waitCount++ != 20) {
    LOG.info("Waiting for NM to stop..");
    Thread.sleep(1000);
  }

  Assert.assertEquals(STATE.STOPPED, nm.getServiceState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestNodeStatusUpdater.java

示例5: testNMShutdownForRegistrationFailure

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNMShutdownForRegistrationFailure() throws Exception {

  nm = new NodeManagerWithCustomNodeStatusUpdater() {
    @Override
    protected NodeStatusUpdater createUpdater(Context context,
        Dispatcher dispatcher, NodeHealthCheckerService healthChecker) {
      MyNodeStatusUpdater nodeStatusUpdater = new MyNodeStatusUpdater(
          context, dispatcher, healthChecker, metrics);
      MyResourceTracker2 myResourceTracker2 = new MyResourceTracker2();
      myResourceTracker2.registerNodeAction = NodeAction.SHUTDOWN;
      myResourceTracker2.shutDownMessage = "RM Shutting Down Node";
      nodeStatusUpdater.resourceTracker = myResourceTracker2;
      return nodeStatusUpdater;
    }
  };
  verifyNodeStartFailure(
        "Recieved SHUTDOWN signal from Resourcemanager ,"
      + "Registration of NodeManager failed, "
      + "Message from ResourceManager: RM Shutting Down Node");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestNodeStatusUpdater.java

示例6: testNodeRegistrationSuccess

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNodeRegistrationSuccess() throws Exception {
  writeToHostsFile("host2");
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile
      .getAbsolutePath());
  rm = new MockRM(conf);
  rm.start();

  ResourceTrackerService resourceTrackerService = rm.getResourceTrackerService();
  RegisterNodeManagerRequest req = Records.newRecord(
      RegisterNodeManagerRequest.class);
  NodeId nodeId = NodeId.newInstance("host2", 1234);
  Resource capability = BuilderUtils.newResource(1024, 1, 1);
  req.setResource(capability);
  req.setNodeId(nodeId);
  req.setHttpPort(1234);
  req.setNMVersion(YarnVersionInfo.getVersion());
  // trying to register a invalid node.
  RegisterNodeManagerResponse response = resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.NORMAL,response.getNodeAction());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestResourceTrackerService.java

示例7: testNodeRegistrationFailure

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNodeRegistrationFailure() throws Exception {
  writeToHostsFile("host1");
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile
      .getAbsolutePath());
  rm = new MockRM(conf);
  rm.start();
  
  ResourceTrackerService resourceTrackerService = rm.getResourceTrackerService();
  RegisterNodeManagerRequest req = Records.newRecord(
      RegisterNodeManagerRequest.class);
  NodeId nodeId = NodeId.newInstance("host2", 1234);
  req.setNodeId(nodeId);
  req.setHttpPort(1234);
  // trying to register a invalid node.
  RegisterNodeManagerResponse response = resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.SHUTDOWN,response.getNodeAction());
  Assert
    .assertEquals(
      "Disallowed NodeManager from  host2, Sending SHUTDOWN signal to the NodeManager.",
      response.getDiagnosticsMessage());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestResourceTrackerService.java

示例8: testReboot

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testReboot() throws Exception {
  Configuration conf = new Configuration();
  rm = new MockRM(conf);
  rm.start();

  MockNM nm1 = rm.registerNode("host1:1234", 5120);
  MockNM nm2 = rm.registerNode("host2:1234", 2048);

  int initialMetricCount = ClusterMetrics.getMetrics().getNumRebootedNMs();
  NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true);
  Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction()));

  nodeHeartbeat = nm2.nodeHeartbeat(
    new HashMap<ApplicationId, List<ContainerStatus>>(), true, -100);
  Assert.assertTrue(NodeAction.RESYNC.equals(nodeHeartbeat.getNodeAction()));
  Assert.assertEquals("Too far behind rm response id:0 nm response id:-100",
    nodeHeartbeat.getDiagnosticsMessage());
  checkRebootedNMCount(rm, ++initialMetricCount);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestResourceTrackerService.java

示例9: testRegisterNodeManagerResponsePBImpl

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
/**
 * Test RegisterNodeManagerResponsePBImpl. Test getters and setters. The
 * RegisterNodeManagerResponsePBImpl should generate a prototype and data
 * restore from prototype
 */
@Test
public void testRegisterNodeManagerResponsePBImpl() {
  RegisterNodeManagerResponsePBImpl original =
      new RegisterNodeManagerResponsePBImpl();
  original.setContainerTokenMasterKey(getMasterKey());
  original.setNMTokenMasterKey(getMasterKey());
  original.setNodeAction(NodeAction.NORMAL);
  original.setDiagnosticsMessage("testDiagnosticMessage");

  RegisterNodeManagerResponsePBImpl copy =
      new RegisterNodeManagerResponsePBImpl(
          original.getProto());
  assertEquals(1, copy.getContainerTokenMasterKey().getKeyId());
  assertEquals(1, copy.getNMTokenMasterKey().getKeyId());
  assertEquals(NodeAction.NORMAL, copy.getNodeAction());
  assertEquals("testDiagnosticMessage", copy.getDiagnosticsMessage());
  assertFalse(copy.getAreNodeLabelsAcceptedByRM());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:TestYarnServerApiClasses.java

示例10: testNodeHeartbeatResponsePBImpl

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
/**
 * Test NodeHeartbeatResponsePBImpl.
 */

@Test
public void testNodeHeartbeatResponsePBImpl() {
  NodeHeartbeatResponsePBImpl original = new NodeHeartbeatResponsePBImpl();

  original.setDiagnosticsMessage("testDiagnosticMessage");
  original.setContainerTokenMasterKey(getMasterKey());
  original.setNMTokenMasterKey(getMasterKey());
  original.setNextHeartBeatInterval(1000);
  original.setNodeAction(NodeAction.NORMAL);
  original.setResponseId(100);

  NodeHeartbeatResponsePBImpl copy = new NodeHeartbeatResponsePBImpl(
      original.getProto());
  assertEquals(100, copy.getResponseId());
  assertEquals(NodeAction.NORMAL, copy.getNodeAction());
  assertEquals(1000, copy.getNextHeartBeatInterval());
  assertEquals(1, copy.getContainerTokenMasterKey().getKeyId());
  assertEquals(1, copy.getNMTokenMasterKey().getKeyId());
  assertEquals("testDiagnosticMessage", copy.getDiagnosticsMessage());
  assertEquals(false, copy.getAreNodeLabelsAcceptedByRM());
 }
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:TestYarnServerApiClasses.java

示例11: registerNodeManager

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException {
  labels = request.getNodeLabels();
  RegisterNodeManagerResponse response =
      recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(NodeAction.NORMAL);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  response.setAreNodeLabelsAcceptedByRM(labels != null);
  synchronized (ResourceTrackerForLabels.class) {
    receivedNMRegister = true;
    ResourceTrackerForLabels.class.notifyAll();
  }
  return response;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:TestNodeStatusUpdaterForLabels.java

示例12: nodeHeartbeat

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Override
public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request)
    throws YarnException, IOException {
  System.out.println("RTS receive heartbeat : "
      + System.currentTimeMillis());
  labels = request.getNodeLabels();
  NodeStatus nodeStatus = request.getNodeStatus();
  nodeStatus.setResponseId(heartbeatID++);

  NodeHeartbeatResponse nhResponse =
      YarnServerBuilderUtils.newNodeHeartbeatResponse(heartbeatID,
          NodeAction.NORMAL, null, null, null, null, 1000L);

  // to ensure that heartbeats are sent only when required.
  nhResponse.setNextHeartBeatInterval(Long.MAX_VALUE);
  nhResponse.setAreNodeLabelsAcceptedByRM(labels != null);

  synchronized (ResourceTrackerForLabels.class) {
    receivedNMHeartbeat = true;
    ResourceTrackerForLabels.class.notifyAll();
  }
  return nhResponse;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:TestNodeStatusUpdaterForLabels.java

示例13: testNMShutdownForRegistrationFailure

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNMShutdownForRegistrationFailure() throws Exception {

  nm = new NodeManagerWithCustomNodeStatusUpdater() {
    @Override
    protected NodeStatusUpdater createUpdater(Context context,
        Dispatcher dispatcher, NodeHealthCheckerService healthChecker) {
      MyNodeStatusUpdater nodeStatusUpdater = new MyNodeStatusUpdater(
          context, dispatcher, healthChecker, metrics);
      MyResourceTracker2 myResourceTracker2 = new MyResourceTracker2();
      myResourceTracker2.registerNodeAction = NodeAction.SHUTDOWN;
      myResourceTracker2.shutDownMessage = "RM Shutting Down Node";
      nodeStatusUpdater.resourceTracker = myResourceTracker2;
      return nodeStatusUpdater;
    }
  };
  verifyNodeStartFailure(
        "Recieved SHUTDOWN signal from Resourcemanager, "
      + "Registration of NodeManager failed, "
      + "Message from ResourceManager: RM Shutting Down Node");
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:22,代码来源:TestNodeStatusUpdater.java

示例14: testNodeRegistrationSuccess

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNodeRegistrationSuccess() throws Exception {
  writeToHostsFile("host2");
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile
      .getAbsolutePath());
  rm = new MockRM(conf);
  rm.start();

  ResourceTrackerService resourceTrackerService = rm.getResourceTrackerService();
  RegisterNodeManagerRequest req = Records.newRecord(
      RegisterNodeManagerRequest.class);
  NodeId nodeId = NodeId.newInstance("host2", 1234);
  Resource capability = BuilderUtils.newResource(1024, 1);
  req.setResource(capability);
  req.setNodeId(nodeId);
  req.setHttpPort(1234);
  req.setNMVersion(YarnVersionInfo.getVersion());
  // trying to register a invalid node.
  RegisterNodeManagerResponse response =
      resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.NORMAL, response.getNodeAction());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:TestResourceTrackerService.java

示例15: testNMUnregistration

import org.apache.hadoop.yarn.server.api.records.NodeAction; //导入依赖的package包/类
@Test
public void testNMUnregistration() throws Exception {
  Configuration conf = new Configuration();
  rm = new MockRM(conf);
  rm.start();

  ResourceTrackerService resourceTrackerService = rm
      .getResourceTrackerService();
  MockNM nm1 = rm.registerNode("host1:1234", 5120);

  int shutdownNMsCount = ClusterMetrics.getMetrics()
      .getNumShutdownNMs();
  NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true);
  Assert.assertTrue(NodeAction.NORMAL.equals(nodeHeartbeat.getNodeAction()));

  UnRegisterNodeManagerRequest request = Records
      .newRecord(UnRegisterNodeManagerRequest.class);
  request.setNodeId(nm1.getNodeId());
  resourceTrackerService.unRegisterNodeManager(request);
  checkShutdownNMCount(rm, ++shutdownNMsCount);

  // The RM should remove the node after unregistration, hence send a reboot
  // command.
  nodeHeartbeat = nm1.nodeHeartbeat(true);
  Assert.assertTrue(NodeAction.RESYNC.equals(nodeHeartbeat.getNodeAction()));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestResourceTrackerService.java


注:本文中的org.apache.hadoop.yarn.server.api.records.NodeAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。