Java Code Examples for org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse

The following examples show how to use org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  NodeId nodeId = request.getNodeId();
  Resource resource = request.getResource();
  LOG.info("Registering " + nodeId.toString());
  // NOTE: this really should be checking against the config value
  InetSocketAddress expected = NetUtils.getConnectAddress(
      conf.getSocketAddr(YarnConfiguration.NM_ADDRESS, null, -1));
  Assert.assertEquals(NetUtils.getHostPortString(expected), nodeId.toString());
  Assert.assertEquals(5 * 1024, resource.getMemory());
  registeredNodes.add(nodeId);

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 2
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException,
    IOException {
  if (System.currentTimeMillis() - waitStartTime <= rmStartIntervalMS
      || rmNeverStart) {
    throw new java.net.ConnectException("Faking RM start failure as start "
        + "delay timer has not expired.");
  } else {
    NodeId nodeId = request.getNodeId();
    Resource resource = request.getResource();
    LOG.info("Registering " + nodeId.toString());
    // NOTE: this really should be checking against the config value
    InetSocketAddress expected = NetUtils.getConnectAddress(
        conf.getSocketAddr(YarnConfiguration.NM_ADDRESS, null, -1));
    Assert.assertEquals(NetUtils.getHostPortString(expected),
        nodeId.toString());
    Assert.assertEquals(5 * 1024, resource.getMemory());
    registeredNodes.add(nodeId);

    RegisterNodeManagerResponse response = recordFactory
        .newRecordInstance(RegisterNodeManagerResponse.class);
    triggered = true;
    return response;
  }
}
 
Example 3
Source Project: hadoop   Source File: MockNM.java    License: Apache License 2.0 6 votes vote down vote up
public RegisterNodeManagerResponse registerNode(
    List<NMContainerStatus> containerReports,
    List<ApplicationId> runningApplications) throws Exception {
  RegisterNodeManagerRequest req = Records.newRecord(
      RegisterNodeManagerRequest.class);
  req.setNodeId(nodeId);
  req.setHttpPort(httpPort);
  Resource resource = BuilderUtils.newResource(memory, vCores, gCores);
  req.setResource(resource);
  req.setContainerStatuses(containerReports);
  req.setNMVersion(version);
  req.setRunningApplications(runningApplications);
  RegisterNodeManagerResponse registrationResponse =
      resourceTracker.registerNodeManager(req);
  this.currentContainerTokenMasterKey =
      registrationResponse.getContainerTokenMasterKey();
  this.currentNMTokenMasterKey = registrationResponse.getNMTokenMasterKey();
  return registrationResponse;    
}
 
Example 4
Source Project: hadoop   Source File: TestResourceTrackerService.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 5
Source Project: hadoop   Source File: TestResourceTrackerService.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 6
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  NodeId nodeId = request.getNodeId();
  Resource resource = request.getResource();
  LOG.info("Registering " + nodeId.toString());
  // NOTE: this really should be checking against the config value
  InetSocketAddress expected = NetUtils.getConnectAddress(
      conf.getSocketAddr(YarnConfiguration.NM_ADDRESS, null, -1));
  Assert.assertEquals(NetUtils.getHostPortString(expected), nodeId.toString());
  Assert.assertEquals(5 * 1024, resource.getMemory());
  registeredNodes.add(nodeId);

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 7
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException,
    IOException {
  if (System.currentTimeMillis() - waitStartTime <= rmStartIntervalMS
      || rmNeverStart) {
    throw new java.net.ConnectException("Faking RM start failure as start "
        + "delay timer has not expired.");
  } else {
    NodeId nodeId = request.getNodeId();
    Resource resource = request.getResource();
    LOG.info("Registering " + nodeId.toString());
    // NOTE: this really should be checking against the config value
    InetSocketAddress expected = NetUtils.getConnectAddress(
        conf.getSocketAddr(YarnConfiguration.NM_ADDRESS, null, -1));
    Assert.assertEquals(NetUtils.getHostPortString(expected),
        nodeId.toString());
    Assert.assertEquals(5 * 1024, resource.getMemory());
    registeredNodes.add(nodeId);

    RegisterNodeManagerResponse response = recordFactory
        .newRecordInstance(RegisterNodeManagerResponse.class);
    triggered = true;
    return response;
  }
}
 
Example 8
Source Project: big-c   Source File: MockNM.java    License: Apache License 2.0 6 votes vote down vote up
public RegisterNodeManagerResponse registerNode(
    List<NMContainerStatus> containerReports,
    List<ApplicationId> runningApplications) throws Exception {
  RegisterNodeManagerRequest req = Records.newRecord(
      RegisterNodeManagerRequest.class);
  req.setNodeId(nodeId);
  req.setHttpPort(httpPort);
  Resource resource = BuilderUtils.newResource(memory, vCores);
  req.setResource(resource);
  req.setContainerStatuses(containerReports);
  req.setNMVersion(version);
  req.setRunningApplications(runningApplications);
  RegisterNodeManagerResponse registrationResponse =
      resourceTracker.registerNodeManager(req);
  this.currentContainerTokenMasterKey =
      registrationResponse.getContainerTokenMasterKey();
  this.currentNMTokenMasterKey = registrationResponse.getNMTokenMasterKey();
  return registrationResponse;    
}
 
Example 9
Source Project: big-c   Source File: TestResourceTrackerService.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 10
Source Project: big-c   Source File: TestResourceTrackerService.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 11
Source Project: hadoop   Source File: ResourceTrackerPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerRequestProto requestProto = ((RegisterNodeManagerRequestPBImpl)request).getProto();
  try {
    return new RegisterNodeManagerResponsePBImpl(proxy.registerNodeManager(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 12
Source Project: hadoop   Source File: TestResourceTrackerPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException {
  if (exception) {
    throw new YarnException("testMessage");
  }
  return recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
}
 
Example 13
Source Project: hadoop   Source File: TestYSCRPCFactories.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
 
Example 14
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction );
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  response.setDiagnosticsMessage(shutDownMessage);
  response.setRMVersion(rmVersion);
  return response;
}
 
Example 15
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {

  RegisterNodeManagerResponse response =
      recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 16
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException {
  RegisterNodeManagerResponse response =
      recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 17
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction );
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 18
Source Project: hadoop   Source File: MockNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { new Integer(123)
    .byteValue() }));
  response.setContainerTokenMasterKey(masterKey);
  response.setNMTokenMasterKey(masterKey);
  return response;
}
 
Example 19
Source Project: hadoop   Source File: LocalRMInterface.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerResponse response = recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { new Integer(123)
    .byteValue() }));
  response.setContainerTokenMasterKey(masterKey);
  response.setNMTokenMasterKey(masterKey);
  return response;
}
 
Example 20
Source Project: hadoop   Source File: TestResourceTrackerService.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNodeRegistrationVersionLessThanRM() throws Exception {
  writeToHostsFile("host2");
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile
      .getAbsolutePath());
  conf.set(YarnConfiguration.RM_NODEMANAGER_MINIMUM_VERSION,"EqualToRM" );
  rm = new MockRM(conf);
  rm.start();
  String nmVersion = "1.9.9";

  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(nmVersion);
  // trying to register a invalid node.
  RegisterNodeManagerResponse response = resourceTrackerService.registerNodeManager(req);
  Assert.assertEquals(NodeAction.SHUTDOWN,response.getNodeAction());
  Assert.assertTrue("Diagnostic message did not contain: 'Disallowed NodeManager " +
      "Version "+ nmVersion + ", is less than the minimum version'",
      response.getDiagnosticsMessage().contains("Disallowed NodeManager Version " +
          nmVersion + ", is less than the minimum version "));

}
 
Example 21
Source Project: hadoop   Source File: TestResourceTrackerService.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSetRMIdentifierInRegistration() throws Exception {

  Configuration conf = new Configuration();
  rm = new MockRM(conf);
  rm.start();

  MockNM nm = new MockNM("host1:1234", 5120, rm.getResourceTrackerService());
  RegisterNodeManagerResponse response = nm.registerNode();

  // Verify the RMIdentifier is correctly set in RegisterNodeManagerResponse
  Assert.assertEquals(ResourceManager.getClusterTimeStamp(),
    response.getRMIdentifier());
}
 
Example 22
Source Project: hadoop   Source File: ProtocolHATestBase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  resetStartFailoverFlag(true);
  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());
  return super.registerNodeManager(request);
}
 
Example 23
Source Project: big-c   Source File: ResourceTrackerPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerRequestProto requestProto = ((RegisterNodeManagerRequestPBImpl)request).getProto();
  try {
    return new RegisterNodeManagerResponsePBImpl(proxy.registerNodeManager(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 24
Source Project: big-c   Source File: TestResourceTrackerPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException {
  if (exception) {
    throw new YarnException("testMessage");
  }
  return recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
}
 
Example 25
Source Project: big-c   Source File: TestYSCRPCFactories.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
 
Example 26
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction );
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  response.setDiagnosticsMessage(shutDownMessage);
  response.setRMVersion(rmVersion);
  return response;
}
 
Example 27
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {

  RegisterNodeManagerResponse response =
      recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 28
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException, IOException {
  RegisterNodeManagerResponse response =
      recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 29
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setNodeAction(registerNodeAction );
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 30
Source Project: big-c   Source File: MockNodeStatusUpdater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { new Integer(123)
    .byteValue() }));
  response.setContainerTokenMasterKey(masterKey);
  response.setNMTokenMasterKey(masterKey);
  return response;
}