hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java
@Override
  public EndpointStateMachine.EndPointStates call() throws Exception {

    if (getDatanodeDetails() == null) {
      LOG.error("DatanodeDetails cannot be null in RegisterEndpoint task, " +
          "shutting down the endpoint.");
      return rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
    }

    rpcEndPoint.lock();
    try {

      // TODO : Add responses to the command Queue.
      SCMRegisteredCmdResponseProto response = rpcEndPoint.getEndPoint()
          .register(datanodeDetails.getProtoBufMessage(),
              conf.getStrings(ScmConfigKeys.OZONE_SCM_NAMES));
      Preconditions.checkState(UUID.fromString(response.getDatanodeUUID())
              .equals(datanodeDetails.getUuid()),
          "Unexpected datanode ID in the response.");
      Preconditions.checkState(!StringUtils.isBlank(response.getClusterID()),
          "Invalid cluster ID in the response.");
      if (response.hasHostname() && response.hasIpAddress()) {
        datanodeDetails.setHostName(response.getHostname());
        datanodeDetails.setIpAddress(response.getIpAddress());
      }
      EndpointStateMachine.EndPointStates nextState =
          rpcEndPoint.getState().getNextState();
      rpcEndPoint.setState(nextState);
      rpcEndPoint.zeroMissedCount();
    } catch (IOException ex) {
      rpcEndPoint.logIfNeeded(ex
      );
    } finally {
      rpcEndPoint.unlock();
    }

    return rpcEndPoint.getState();
  }
/**
   * Computes a result, or throws an exception if unable to do so.
   *
   * @return computed result
   * @throws Exception if unable to compute a result
   */
Computes a result, or throws an exception if unable to do so.
@return computed result
@throws Exception if unable to compute a result
Computes a result or throws an exception if unable to do so . @return computed result @throws Exception if unable to compute a result
@Override
  public EndpointStateMachine.EndPointStates call() throws Exception {
    if (getDatanodeDetails() == null) {
      LOG.error("DatanodeDetails cannot be null in RegisterEndpoint task, " +
          "shutting down the endpoint.");
      return rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
    }
    rpcEndPoint.lock();
    try {
      SCMRegisteredCmdResponseProto response = rpcEndPoint.getEndPoint()
          .register(datanodeDetails.getProtoBufMessage(),
              conf.getStrings(ScmConfigKeys.OZONE_SCM_NAMES));
      Preconditions.checkState(UUID.fromString(response.getDatanodeUUID())
              .equals(datanodeDetails.getUuid()),
          "Unexpected datanode ID in the response.");
      Preconditions.checkState(!StringUtils.isBlank(response.getClusterID()),
          "Invalid cluster ID in the response.");
      if (response.hasHostname() && response.hasIpAddress()) {
        datanodeDetails.setHostName(response.getHostname());
        datanodeDetails.setIpAddress(response.getIpAddress());
      }
      EndpointStateMachine.EndPointStates nextState =
          rpcEndPoint.getState().getNextState();
      rpcEndPoint.setState(nextState);
      rpcEndPoint.zeroMissedCount();
    } catch (IOException ex) {
      rpcEndPoint.logIfNeeded(ex
      );
    } finally {
      rpcEndPoint.unlock();
    }
    return rpcEndPoint.getState();
  }
@ Override public EndpointStateMachine . EndPointStates call ( ) throws Exception { if ( getDatanodeDetails ( ) == null ) { LOG . error ( "DatanodeDetails cannot be null in RegisterEndpoint task, " + "shutting down the endpoint." ) ; return rpcEndPoint . setState ( EndpointStateMachine . EndPointStates . SHUTDOWN ) ; } rpcEndPoint . lock ( ) ; try { SCMRegisteredCmdResponseProto response = rpcEndPoint . getEndPoint ( ) . register ( datanodeDetails . getProtoBufMessage ( ) , conf . getStrings ( ScmConfigKeys . OZONE_SCM_NAMES ) ) ; Preconditions . checkState ( UUID . fromString ( response . getDatanodeUUID ( ) ) . equals ( datanodeDetails . getUuid ( ) ) , "Unexpected datanode ID in the response." ) ; Preconditions . checkState ( ! StringUtils . isBlank ( response . getClusterID ( ) ) , "Invalid cluster ID in the response." ) ; if ( response . hasHostname ( ) && response . hasIpAddress ( ) ) { datanodeDetails . setHostName ( response . getHostname ( ) ) ; datanodeDetails . setIpAddress ( response . getIpAddress ( ) ) ; } EndpointStateMachine . EndPointStates nextState = rpcEndPoint . getState ( ) . getNextState ( ) ; rpcEndPoint . setState ( nextState ) ; rpcEndPoint . zeroMissedCount ( ) ; } catch ( IOException ex ) { rpcEndPoint . logIfNeeded ( ex ) ; } finally { rpcEndPoint . unlock ( ) ; } return rpcEndPoint . getState ( ) ; }
Computes a result, or throws an exception if unable to do so.
Computes a result or throws an exception if unable to do so .
// TODO : Add responses to the command Queue.