Search in sources :

Example 1 with VersionResponse

use of org.apache.hadoop.ozone.protocol.VersionResponse in project ozone by apache.

the class VersionEndpointTask method call.

/**
 * 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 {
    rpcEndPoint.lock();
    try {
        if (rpcEndPoint.getState().equals(EndpointStateMachine.EndPointStates.GETVERSION)) {
            SCMVersionResponseProto versionResponse = rpcEndPoint.getEndPoint().getVersion(null);
            VersionResponse response = VersionResponse.getFromProtobuf(versionResponse);
            rpcEndPoint.setVersion(response);
            if (!rpcEndPoint.isPassive()) {
                // If end point is passive, datanode does not need to check volumes.
                String scmId = response.getValue(OzoneConsts.SCM_ID);
                String clusterId = response.getValue(OzoneConsts.CLUSTER_ID);
                // Check volumes
                MutableVolumeSet volumeSet = ozoneContainer.getVolumeSet();
                volumeSet.writeLock();
                try {
                    Map<String, StorageVolume> volumeMap = volumeSet.getVolumeMap();
                    Preconditions.checkNotNull(scmId, "Reply from SCM: scmId cannot be null");
                    Preconditions.checkNotNull(clusterId, "Reply from SCM: clusterId cannot be null");
                    // create version file and also set scm ID or cluster ID.
                    for (Map.Entry<String, StorageVolume> entry : volumeMap.entrySet()) {
                        StorageVolume volume = entry.getValue();
                        boolean result = HddsVolumeUtil.checkVolume((HddsVolume) volume, scmId, clusterId, configuration, LOG);
                        if (!result) {
                            volumeSet.failVolume(volume.getStorageDir().getPath());
                        }
                    }
                    if (volumeSet.getVolumesList().size() == 0) {
                        // All volumes are in inconsistent state
                        throw new DiskOutOfSpaceException("All configured Volumes are in Inconsistent State");
                    }
                } finally {
                    volumeSet.writeUnlock();
                }
                // Start the container services after getting the version information
                ozoneContainer.start(clusterId);
            }
            EndpointStateMachine.EndPointStates nextState = rpcEndPoint.getState().getNextState();
            rpcEndPoint.setState(nextState);
            rpcEndPoint.zeroMissedCount();
        } else {
            LOG.debug("Cannot execute GetVersion task as endpoint state machine " + "is in {} state", rpcEndPoint.getState());
        }
    } catch (DiskOutOfSpaceException ex) {
        rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
    } catch (IOException ex) {
        rpcEndPoint.logIfNeeded(ex);
    } finally {
        rpcEndPoint.unlock();
    }
    return rpcEndPoint.getState();
}
Also used : VersionResponse(org.apache.hadoop.ozone.protocol.VersionResponse) IOException(java.io.IOException) DiskOutOfSpaceException(org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException) EndpointStateMachine(org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine) StorageVolume(org.apache.hadoop.ozone.container.common.volume.StorageVolume) MutableVolumeSet(org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet) Map(java.util.Map) SCMVersionResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMVersionResponseProto)

Aggregations

IOException (java.io.IOException)1 Map (java.util.Map)1 SCMVersionResponseProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMVersionResponseProto)1 EndpointStateMachine (org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine)1 MutableVolumeSet (org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet)1 StorageVolume (org.apache.hadoop.ozone.container.common.volume.StorageVolume)1 VersionResponse (org.apache.hadoop.ozone.protocol.VersionResponse)1 DiskOutOfSpaceException (org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException)1