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

The following examples show how to use org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse. 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 File: TestResourceTrackerService.java    From big-c with 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 #2
Source File: TestNodeStatusUpdater.java    From hadoop with 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 #3
Source File: TestNodeStatusUpdater.java    From big-c with 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 #4
Source File: TestResourceTrackerService.java    From big-c with 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 #5
Source File: MockNM.java    From big-c with 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 #6
Source File: TestNodeStatusUpdater.java    From hadoop with 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 #7
Source File: TestResourceTrackerService.java    From hadoop with 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 #8
Source File: TestNodeStatusUpdater.java    From big-c with 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 #9
Source File: TestResourceTrackerService.java    From hadoop with 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 #10
Source File: MockNM.java    From hadoop with 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 #11
Source File: TestResourceTrackerPBClientImpl.java    From big-c with 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 #12
Source File: ResourceTrackerPBClientImpl.java    From hadoop with 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 #13
Source File: TestYSCRPCFactories.java    From big-c with 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 File: TestNodeStatusUpdater.java    From big-c with 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 File: TestNodeStatusUpdater.java    From big-c with 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 File: TestNodeStatusUpdater.java    From big-c with 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 File: TestNodeStatusUpdater.java    From big-c with 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 File: MockNodeStatusUpdater.java    From big-c with 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 File: LocalRMInterface.java    From big-c with 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 File: TestResourceTrackerService.java    From big-c with 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);
  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 File: TestResourceTrackerService.java    From big-c with 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 File: ProtocolHATestBase.java    From big-c with 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 File: ResourceTrackerPBClientImpl.java    From big-c with 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 File: ProtocolHATestBase.java    From hadoop with 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 #25
Source File: TestResourceTrackerService.java    From hadoop with 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 #26
Source File: TestResourceTrackerService.java    From hadoop with 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 #27
Source File: TestResourceTrackerPBClientImpl.java    From hadoop with 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 #28
Source File: TestYSCRPCFactories.java    From hadoop with 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 #29
Source File: LocalRMInterface.java    From hadoop with 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 #30
Source File: MockNodeStatusUpdater.java    From hadoop with 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;
}