use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMVersionResponseProto 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();
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMVersionResponseProto in project ozone by apache.
the class TestEndPoint method testGetVersion.
@Test
public /**
* This test asserts that we are able to make a version call to SCM server
* and gets back the expected values.
*/
void testGetVersion() throws Exception {
try (EndpointStateMachine rpcEndPoint = createEndpoint(SCMTestUtils.getConf(), serverAddress, 1000)) {
SCMVersionResponseProto responseProto = rpcEndPoint.getEndPoint().getVersion(null);
Assert.assertNotNull(responseProto);
Assert.assertEquals(VersionInfo.DESCRIPTION_KEY, responseProto.getKeys(0).getKey());
Assert.assertEquals(VersionInfo.getLatestVersion().getDescription(), responseProto.getKeys(0).getValue());
}
}
Aggregations