Ejemplo n.º 1
0
 protected void register() {
   // Register
   InetSocketAddress serviceAddr = null;
   if (clientService != null) {
     serviceAddr = clientService.getBindAddress();
   }
   try {
     RegisterApplicationMasterRequest request =
         recordFactory.newRecordInstance(RegisterApplicationMasterRequest.class);
     if (serviceAddr != null) {
       request.setHost(serviceAddr.getHostName());
       request.setRpcPort(serviceAddr.getPort());
       request.setTrackingUrl(serviceAddr.getHostName() + ":" + clientService.getHttpPort());
     }
     RegisterApplicationMasterResponse response = scheduler.registerApplicationMaster(request);
     maxContainerCapability = response.getMaximumResourceCapability();
     this.context.getClusterInfo().setMaxContainerCapability(maxContainerCapability);
     if (UserGroupInformation.isSecurityEnabled()) {
       setClientToAMToken(response.getClientToAMTokenMasterKey());
     }
     this.applicationACLs = response.getApplicationACLs();
     LOG.info("maxContainerCapability: " + maxContainerCapability.getMemory());
   } catch (Exception are) {
     LOG.error("Exception while registering", are);
     throw new YarnRuntimeException(are);
   }
 }
  public RegisterApplicationMasterResponse registerApplicationMaster(String host, int port)
      throws YarnRemoteException {

    if (amResourceManager == null)
      throw new IllegalStateException(
          "Cannot register application master before connecting to the resource manager!");

    RegisterApplicationMasterRequest request =
        Records.newRecord(RegisterApplicationMasterRequest.class);

    request.setApplicationAttemptId(appAttemptId);
    request.setHost(host);
    request.setRpcPort(port);
    request.setTrackingUrl("http://some-place.com/some/endpoint");

    LOG.info(
        "Sending application registration request"
            + ", masterHost="
            + request.getHost()
            + ", masterRpcPort="
            + request.getRpcPort()
            + ", trackingUrl="
            + request.getTrackingUrl()
            + ", applicationAttempt="
            + request.getApplicationAttemptId()
            + ", applicationId="
            + request.getApplicationAttemptId().getApplicationId());

    RegisterApplicationMasterResponse response =
        amResourceManager.registerApplicationMaster(request);
    LOG.debug(
        "Received a registration response"
            + ", min="
            + response.getMinimumResourceCapability().getMemory()
            + ", max="
            + response.getMaximumResourceCapability().getMemory());

    return response;
  }