HDFS-11568. Ozone: Create metadata path automatically after null checking. Contributed by Mukul Kumar Singh.

This commit is contained in:
Anu Engineer 2017-06-06 16:46:15 -07:00 committed by Owen O'Malley
parent d6dd557b24
commit f617b2dddb
3 changed files with 9 additions and 21 deletions

View File

@ -20,11 +20,11 @@ package org.apache.hadoop.ozone.scm.block;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtil;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.scm.container.Mapping; import org.apache.hadoop.ozone.scm.container.Mapping;
import org.apache.hadoop.ozone.scm.exceptions.SCMException; import org.apache.hadoop.ozone.scm.exceptions.SCMException;
import org.apache.hadoop.ozone.scm.node.NodeManager; import org.apache.hadoop.ozone.scm.node.NodeManager;
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
import org.apache.hadoop.scm.ScmConfigKeys; import org.apache.hadoop.scm.ScmConfigKeys;
import org.apache.hadoop.scm.container.common.helpers.AllocatedBlock; import org.apache.hadoop.scm.container.common.helpers.AllocatedBlock;
import org.apache.hadoop.scm.container.common.helpers.Pipeline; import org.apache.hadoop.scm.container.common.helpers.Pipeline;
@ -100,12 +100,8 @@ public class BlockManagerImpl implements BlockManager {
this.nodeManager = nodeManager; this.nodeManager = nodeManager;
this.containerManager = containerManager; this.containerManager = containerManager;
this.cacheSize = cacheSizeMB; this.cacheSize = cacheSizeMB;
String scmMetaDataDir = conf.get(OzoneConfigKeys File metaDir = OzoneUtils.getScmMetadirPath(conf);
.OZONE_CONTAINER_METADATA_DIRS); String scmMetaDataDir = metaDir.getPath();
if ((scmMetaDataDir == null) || (scmMetaDataDir.isEmpty())) {
throw
new IllegalArgumentException("SCM metadata directory is not valid.");
}
Options options = new Options(); Options options = new Options();
options.cacheSize(this.cacheSize * OzoneConsts.MB); options.cacheSize(this.cacheSize * OzoneConsts.MB);

View File

@ -22,12 +22,12 @@ import com.google.common.base.Preconditions;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ozone.protocol.proto.OzoneProtos; import org.apache.hadoop.ozone.protocol.proto.OzoneProtos;
import org.apache.hadoop.hdfs.protocol.DatanodeID; import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.scm.container.placement.algorithms.ContainerPlacementPolicy; import org.apache.hadoop.ozone.scm.container.placement.algorithms.ContainerPlacementPolicy;
import org.apache.hadoop.ozone.scm.container.placement.algorithms.SCMContainerPlacementRandom; import org.apache.hadoop.ozone.scm.container.placement.algorithms.SCMContainerPlacementRandom;
import org.apache.hadoop.ozone.scm.exceptions.SCMException; import org.apache.hadoop.ozone.scm.exceptions.SCMException;
import org.apache.hadoop.ozone.scm.node.NodeManager; import org.apache.hadoop.ozone.scm.node.NodeManager;
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
import org.apache.hadoop.scm.ScmConfigKeys; import org.apache.hadoop.scm.ScmConfigKeys;
import org.apache.hadoop.scm.client.ScmClient; import org.apache.hadoop.scm.client.ScmClient;
import org.apache.hadoop.scm.container.common.helpers.Pipeline; import org.apache.hadoop.scm.container.common.helpers.Pipeline;
@ -80,13 +80,8 @@ public class ContainerMapping implements Mapping {
this.nodeManager = nodeManager; this.nodeManager = nodeManager;
this.cacheSize = cacheSizeMB; this.cacheSize = cacheSizeMB;
// TODO: Fix this checking. File metaDir = OzoneUtils.getScmMetadirPath(conf);
String scmMetaDataDir = conf.get(OzoneConfigKeys String scmMetaDataDir = metaDir.getParent();
.OZONE_CONTAINER_METADATA_DIRS);
if ((scmMetaDataDir == null) || (scmMetaDataDir.isEmpty())) {
throw
new IllegalArgumentException("SCM metadata directory is not valid.");
}
Options options = new Options(); Options options = new Options();
options.cacheSize(this.cacheSize * OzoneConsts.MB); options.cacheSize(this.cacheSize * OzoneConsts.MB);

View File

@ -22,10 +22,10 @@ import com.google.common.base.Preconditions;
import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtil;
import org.apache.hadoop.hdfs.protocol.DatanodeID; import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos; import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration; import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.scm.exceptions.SCMException; import org.apache.hadoop.ozone.scm.exceptions.SCMException;
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
import org.apache.hadoop.utils.LevelDBStore; import org.apache.hadoop.utils.LevelDBStore;
import org.iq80.leveldb.DBIterator; import org.iq80.leveldb.DBIterator;
import org.iq80.leveldb.Options; import org.iq80.leveldb.Options;
@ -82,11 +82,8 @@ public final class SCMNodePoolManager implements NodePoolManager {
throws IOException { throws IOException {
final int cacheSize = conf.getInt(OZONE_SCM_DB_CACHE_SIZE_MB, final int cacheSize = conf.getInt(OZONE_SCM_DB_CACHE_SIZE_MB,
OZONE_SCM_DB_CACHE_SIZE_DEFAULT); OZONE_SCM_DB_CACHE_SIZE_DEFAULT);
String scmMetaDataDir = conf.get(OzoneConfigKeys File metaDir = OzoneUtils.getScmMetadirPath(conf);
.OZONE_CONTAINER_METADATA_DIRS); String scmMetaDataDir = metaDir.getPath();
if (scmMetaDataDir == null) {
throw new IllegalArgumentException("SCM metadata directory is invalid.");
}
Options options = new Options(); Options options = new Options();
options.cacheSize(cacheSize * OzoneConsts.MB); options.cacheSize(cacheSize * OzoneConsts.MB);