use of org.apache.hadoop.ozone.container.metadata.DatanodeStoreSchemaOneImpl in project ozone by apache.
the class KeyValueContainerUtil method createContainerMetaData.
/**
* @param containerMetaDataPath
* @throws IOException
*/
/**
* creates metadata path, chunks path and metadata DB for the specified
* container.
*
* @param containerMetaDataPath Path to the container's metadata directory.
* @param chunksPath Path were chunks for this container should be stored.
* @param dbFile Path to the container's .db file.
* @param schemaVersion The schema version of the container. If this method
* has not been updated after a schema version addition
* and does not recognize the latest SchemaVersion, an
* {@link IllegalArgumentException} is thrown.
* @param conf The configuration to use for this container.
* @throws IOException
*/
public static void createContainerMetaData(long containerID, File containerMetaDataPath, File chunksPath, File dbFile, String schemaVersion, ConfigurationSource conf) throws IOException {
Preconditions.checkNotNull(containerMetaDataPath);
Preconditions.checkNotNull(conf);
if (!containerMetaDataPath.mkdirs()) {
LOG.error("Unable to create directory for metadata storage. Path: {}", containerMetaDataPath);
throw new IOException("Unable to create directory for metadata storage." + " Path: " + containerMetaDataPath);
}
if (!chunksPath.mkdirs()) {
LOG.error("Unable to create chunks directory Container {}", chunksPath);
// clean up container metadata path and metadata db
FileUtils.deleteDirectory(containerMetaDataPath);
FileUtils.deleteDirectory(containerMetaDataPath.getParentFile());
throw new IOException("Unable to create directory for data storage." + " Path: " + chunksPath);
}
DatanodeStore store;
if (schemaVersion.equals(OzoneConsts.SCHEMA_V1)) {
store = new DatanodeStoreSchemaOneImpl(conf, containerID, dbFile.getAbsolutePath(), false);
} else if (schemaVersion.equals(OzoneConsts.SCHEMA_V2)) {
store = new DatanodeStoreSchemaTwoImpl(conf, containerID, dbFile.getAbsolutePath(), false);
} else {
throw new IllegalArgumentException("Unrecognized schema version for container: " + schemaVersion);
}
ReferenceCountedDB db = new ReferenceCountedDB(store, dbFile.getAbsolutePath());
// add db handler into cache
BlockUtils.addDB(db, dbFile.getAbsolutePath(), conf);
}
Aggregations