LeonGao91 commented on a change in pull request #2288:
URL: https://github.com/apache/hadoop/pull/2288#discussion_r516381949
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
##########
@@ -190,6 +193,18 @@
}
this.conf = conf;
this.fileIoProvider = fileIoProvider;
+ this.enableSameDiskTiering =
+ conf.getBoolean(DFSConfigKeys.DFS_DATANODE_ALLOW_SAME_DISK_TIERING,
+ DFSConfigKeys.DFS_DATANODE_ALLOW_SAME_DISK_TIERING_DEFAULT);
+ if (enableSameDiskTiering) {
Review comment:
Will do
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeList.java
##########
@@ -62,9 +63,13 @@
private final VolumeChoosingPolicy<FsVolumeImpl> blockChooser;
private final BlockScanner blockScanner;
+ private boolean enableSameDiskTiering;
+ private MountVolumeMap mountVolumeMap;
Review comment:
+1, will fix
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeList.java
##########
@@ -291,6 +304,11 @@ public String toString() {
void addVolume(FsVolumeReference ref) {
FsVolumeImpl volume = (FsVolumeImpl) ref.getVolume();
volumes.add(volume);
+ if (enableSameDiskTiering &&
Review comment:
Good idea, will do that
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/MountVolumeInfo.java
##########
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
+
+import java.nio.channels.ClosedChannelException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * MountVolumeInfo is a wrapper of
+ * detailed volume information for MountVolumeMap.
+ */
[email protected]
+class MountVolumeInfo {
+ private ConcurrentMap<StorageType, FsVolumeImpl>
Review comment:
will do
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/MountVolumeInfo.java
##########
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
+
+import java.nio.channels.ClosedChannelException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * MountVolumeInfo is a wrapper of
+ * detailed volume information for MountVolumeMap.
+ */
[email protected]
+class MountVolumeInfo {
+ private ConcurrentMap<StorageType, FsVolumeImpl>
+ storageTypeVolumeMap;
+ private double reservedForArchiveDefault;
+
+ MountVolumeInfo(Configuration conf) {
+ storageTypeVolumeMap = new ConcurrentHashMap<>();
+ reservedForArchiveDefault = conf.getDouble(
+ DFSConfigKeys.DFS_DATANODE_RESERVE_FOR_ARCHIVE_DEFAULT_PERCENTAGE,
+ DFSConfigKeys
+ .DFS_DATANODE_RESERVE_FOR_ARCHIVE_DEFAULT_PERCENTAGE_DEFAULT);
+ if (reservedForArchiveDefault > 1) {
+ FsDatasetImpl.LOG.warn("Value of reserve-for-archival is > 100%." +
+ " Setting it to 100%.");
+ reservedForArchiveDefault = 1;
+ }
+ }
+
+ FsVolumeReference getVolumeRef(StorageType storageType) {
+ try {
+ FsVolumeImpl volumeImpl = storageTypeVolumeMap
+ .getOrDefault(storageType, null);
+ if (volumeImpl != null) {
+ return volumeImpl.obtainReference();
+ }
+ } catch (ClosedChannelException e) {
+ FsDatasetImpl.LOG.warn("Volume closed when getting volume" +
+ " by storage type: " + storageType);
+ }
+ return null;
+ }
+
+ /**
+ * Return configured capacity ratio.
+ * If the volume is the only one on the mount,
+ * return 1 to avoid unnecessary allocation.
Review comment:
will do
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/MountVolumeInfo.java
##########
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
+
+import java.nio.channels.ClosedChannelException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * MountVolumeInfo is a wrapper of
+ * detailed volume information for MountVolumeMap.
+ */
[email protected]
+class MountVolumeInfo {
+ private ConcurrentMap<StorageType, FsVolumeImpl>
+ storageTypeVolumeMap;
+ private double reservedForArchiveDefault;
+
+ MountVolumeInfo(Configuration conf) {
+ storageTypeVolumeMap = new ConcurrentHashMap<>();
+ reservedForArchiveDefault = conf.getDouble(
+ DFSConfigKeys.DFS_DATANODE_RESERVE_FOR_ARCHIVE_DEFAULT_PERCENTAGE,
+ DFSConfigKeys
+ .DFS_DATANODE_RESERVE_FOR_ARCHIVE_DEFAULT_PERCENTAGE_DEFAULT);
+ if (reservedForArchiveDefault > 1) {
+ FsDatasetImpl.LOG.warn("Value of reserve-for-archival is > 100%." +
+ " Setting it to 100%.");
+ reservedForArchiveDefault = 1;
+ }
+ }
+
+ FsVolumeReference getVolumeRef(StorageType storageType) {
+ try {
+ FsVolumeImpl volumeImpl = storageTypeVolumeMap
+ .getOrDefault(storageType, null);
+ if (volumeImpl != null) {
+ return volumeImpl.obtainReference();
+ }
+ } catch (ClosedChannelException e) {
+ FsDatasetImpl.LOG.warn("Volume closed when getting volume" +
+ " by storage type: " + storageType);
+ }
+ return null;
+ }
+
+ /**
+ * Return configured capacity ratio.
+ * If the volume is the only one on the mount,
+ * return 1 to avoid unnecessary allocation.
+ */
+ double getCapacityRatio(StorageType storageType) {
+ if (storageTypeVolumeMap.containsKey(storageType)
+ && storageTypeVolumeMap.size() > 1) {
+ if (storageType == StorageType.ARCHIVE) {
+ return reservedForArchiveDefault;
+ } else if (storageType == StorageType.DISK) {
+ return 1 - reservedForArchiveDefault;
+ }
+ }
+ return 1;
+ }
+
+ void addVolume(FsVolumeImpl volume) {
+ if (storageTypeVolumeMap.containsKey(volume.getStorageType())) {
+ FsDatasetImpl.LOG.error("Found storage type already exist." +
Review comment:
I have already put a pre-check in
[activateVolume](https://github.com/apache/hadoop/pull/2288/files#diff-fdc214a7b539eb556207a2d53a26a42816516f8380094fafbc72d8bb3711e657R475),
following how other check is done. This seems cleaner and following the
existing ways to validate volumes before doing any operation.
In that case, we should never run into this, I was thinking to keep it just
for debugging in case of some weird bug results in this situation.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/MountVolumeMap.java
##########
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * MountVolumeMap contains information of the relationship
+ * between underlying filesystem mount and datanode volumes.
+ *
+ * This is useful when configuring block tiering on same disk mount
+ * (HDFS-15548). For now,
+ * we don't configure multiple volumes with same storage type on one mount.
+ */
[email protected]
+class MountVolumeMap {
+ private ConcurrentMap<String, MountVolumeInfo>
+ mountVolumeMapping;
Review comment:
+1 will do
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]