From 74ab30399325efc78c286c89780c749ba2a2ff07 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Tue, 6 Jun 2017 16:46:15 -0700 Subject: [PATCH] HDFS-11568. Ozone: Create metadata path automatically after null checking. Contributed by Mukul Kumar Singh. --- .../hadoop/ozone/scm/block/BlockManagerImpl.java | 10 +++------- .../hadoop/ozone/scm/container/ContainerMapping.java | 11 +++-------- .../hadoop/ozone/scm/node/SCMNodePoolManager.java | 9 +++------ 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java index 80027db44a6..8e49b5f9397 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/block/BlockManagerImpl.java @@ -20,11 +20,11 @@ package org.apache.hadoop.ozone.scm.block; import com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.DFSUtil; -import org.apache.hadoop.ozone.OzoneConfigKeys; import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.scm.container.Mapping; import org.apache.hadoop.ozone.scm.exceptions.SCMException; 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.container.common.helpers.AllocatedBlock; import org.apache.hadoop.scm.container.common.helpers.Pipeline; @@ -100,12 +100,8 @@ public class BlockManagerImpl implements BlockManager { this.nodeManager = nodeManager; this.containerManager = containerManager; this.cacheSize = cacheSizeMB; - String scmMetaDataDir = conf.get(OzoneConfigKeys - .OZONE_CONTAINER_METADATA_DIRS); - if ((scmMetaDataDir == null) || (scmMetaDataDir.isEmpty())) { - throw - new IllegalArgumentException("SCM metadata directory is not valid."); - } + File metaDir = OzoneUtils.getScmMetadirPath(conf); + String scmMetaDataDir = metaDir.getPath(); Options options = new Options(); options.cacheSize(this.cacheSize * OzoneConsts.MB); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java index 95fd9fe15d6..2b572494cac 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java @@ -22,12 +22,12 @@ import com.google.common.base.Preconditions; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.ozone.protocol.proto.OzoneProtos; import org.apache.hadoop.hdfs.protocol.DatanodeID; -import org.apache.hadoop.ozone.OzoneConfigKeys; 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.SCMContainerPlacementRandom; import org.apache.hadoop.ozone.scm.exceptions.SCMException; 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.client.ScmClient; import org.apache.hadoop.scm.container.common.helpers.Pipeline; @@ -80,13 +80,8 @@ public class ContainerMapping implements Mapping { this.nodeManager = nodeManager; this.cacheSize = cacheSizeMB; - // TODO: Fix this checking. - String scmMetaDataDir = conf.get(OzoneConfigKeys - .OZONE_CONTAINER_METADATA_DIRS); - if ((scmMetaDataDir == null) || (scmMetaDataDir.isEmpty())) { - throw - new IllegalArgumentException("SCM metadata directory is not valid."); - } + File metaDir = OzoneUtils.getScmMetadirPath(conf); + String scmMetaDataDir = metaDir.getParent(); Options options = new Options(); options.cacheSize(this.cacheSize * OzoneConsts.MB); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java index 3ec5c1c86d7..9c1821fdb75 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/node/SCMNodePoolManager.java @@ -22,10 +22,10 @@ import com.google.common.base.Preconditions; import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.protocol.DatanodeID; 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.OzoneConsts; import org.apache.hadoop.ozone.scm.exceptions.SCMException; +import org.apache.hadoop.ozone.web.utils.OzoneUtils; import org.apache.hadoop.utils.LevelDBStore; import org.iq80.leveldb.DBIterator; import org.iq80.leveldb.Options; @@ -82,11 +82,8 @@ public final class SCMNodePoolManager implements NodePoolManager { throws IOException { final int cacheSize = conf.getInt(OZONE_SCM_DB_CACHE_SIZE_MB, OZONE_SCM_DB_CACHE_SIZE_DEFAULT); - String scmMetaDataDir = conf.get(OzoneConfigKeys - .OZONE_CONTAINER_METADATA_DIRS); - if (scmMetaDataDir == null) { - throw new IllegalArgumentException("SCM metadata directory is invalid."); - } + File metaDir = OzoneUtils.getScmMetadirPath(conf); + String scmMetaDataDir = metaDir.getPath(); Options options = new Options(); options.cacheSize(cacheSize * OzoneConsts.MB);