use of org.apache.hadoop.ozone.common.InconsistentStorageStateException in project ozone by apache.
the class HddsVolume method readVersionFile.
/**
* Read Version File and update property fields.
* Get common storage fields.
* Should be overloaded if additional fields need to be read.
*
* @throws IOException on error
*/
private void readVersionFile() throws IOException {
File versionFile = getVersionFile();
Properties props = DatanodeVersionFile.readFrom(versionFile);
if (props.isEmpty()) {
throw new InconsistentStorageStateException("Version file " + versionFile + " is missing");
}
LOG.debug("Reading Version file from disk, {}", versionFile);
this.storageID = HddsVolumeUtil.getStorageID(props, versionFile);
this.clusterID = HddsVolumeUtil.getClusterID(props, versionFile, this.clusterID);
this.datanodeUuid = HddsVolumeUtil.getDatanodeUUID(props, versionFile, this.datanodeUuid);
this.cTime = HddsVolumeUtil.getCreationTime(props, versionFile);
this.layoutVersion = HddsVolumeUtil.getLayOutVersion(props, versionFile);
}
use of org.apache.hadoop.ozone.common.InconsistentStorageStateException in project ozone by apache.
the class GeneratorDatanode method call.
@Override
public Void call() throws Exception {
init();
config = createOzoneConfiguration();
BlockManager blockManager = new BlockManagerImpl(config);
chunkManager = ChunkManagerFactory.createChunkManager(config, blockManager, null);
final Collection<String> storageDirs = HddsServerUtil.getDatanodeStorageDirs(config);
String firstStorageDir = StorageLocation.parse(storageDirs.iterator().next()).getUri().getPath();
final Path hddsDir = Paths.get(firstStorageDir, "hdds");
if (!Files.exists(hddsDir)) {
throw new NoSuchFileException(hddsDir + " doesn't exist. Please start a real cluster to initialize the " + "VERSION descriptors, and re-start this generator after the files" + " are created (but after cluster is stopped).");
}
scmId = getScmIdFromStoragePath(hddsDir);
final File versionFile = new File(firstStorageDir, "hdds/VERSION");
Properties props = DatanodeVersionFile.readFrom(versionFile);
if (props.isEmpty()) {
throw new InconsistentStorageStateException("Version file " + versionFile + " is missing");
}
String clusterId = HddsVolumeUtil.getProperty(props, OzoneConsts.CLUSTER_ID, versionFile);
datanodeId = HddsVolumeUtil.getProperty(props, OzoneConsts.DATANODE_UUID, versionFile);
volumeSet = new MutableVolumeSet(datanodeId, clusterId, config, null, StorageVolume.VolumeType.DATA_VOLUME, null);
volumeChoosingPolicy = new RoundRobinVolumeChoosingPolicy();
final OzoneClientConfig ozoneClientConfig = config.getObject(OzoneClientConfig.class);
checksum = new Checksum(ozoneClientConfig.getChecksumType(), ozoneClientConfig.getBytesPerChecksum());
timer = getMetrics().timer("datanode-generator");
runTests(this::generateData);
return null;
}
use of org.apache.hadoop.ozone.common.InconsistentStorageStateException in project ozone by apache.
the class TestDatanodeVersionFile method testVerifyLayOut.
@Test
public void testVerifyLayOut() throws IOException {
int invalidLayOutVersion = 100;
dnVersionFile = new DatanodeVersionFile(storageID, clusterID, datanodeUUID, cTime, invalidLayOutVersion);
dnVersionFile.createVersionFile(versionFile);
Properties props = dnVersionFile.readFrom(versionFile);
try {
HddsVolumeUtil.getLayOutVersion(props, versionFile);
fail("Test failure in testVerifyLayOut");
} catch (InconsistentStorageStateException ex) {
GenericTestUtils.assertExceptionContains("Invalid layOutVersion.", ex);
}
}
use of org.apache.hadoop.ozone.common.InconsistentStorageStateException in project ozone by apache.
the class ContainerCommands method getDatanodeUUID.
private String getDatanodeUUID(String storageDir, ConfigurationSource config) throws IOException {
final File versionFile = new File(storageDir, "hdds/VERSION");
Properties props = DatanodeVersionFile.readFrom(versionFile);
if (props.isEmpty()) {
throw new InconsistentStorageStateException("Version file " + versionFile + " is missing");
}
return HddsVolumeUtil.getProperty(props, OzoneConsts.DATANODE_UUID, versionFile);
}
Aggregations