[ https://issues.apache.org/jira/browse/HDFS-15548?focusedWorklogId=506973&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-506973 ]
ASF GitHub Bot logged work on HDFS-15548: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Nov/20 14:06 Start Date: 03/Nov/20 14:06 Worklog Time Spent: 10m Work Description: Jing9 commented on a change in pull request #2288: URL: https://github.com/apache/hadoop/pull/2288#discussion_r516356685 ########## 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. + */ +@InterfaceAudience.Private +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: we can add a TODO here explaining we plan to support different ratios per mount point. ########## 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. + */ +@InterfaceAudience.Private +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: Do we need to throw an exception here? Silently dropping the volume may not be a good option. ########## 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: maybe consider putting this check into a method ########## 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: These two fields can be declared as "final" ########## 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. + */ +@InterfaceAudience.Private +class MountVolumeInfo { + private ConcurrentMap<StorageType, FsVolumeImpl> Review comment: This field can be declared as "final" ########## 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. + */ +@InterfaceAudience.Private +class MountVolumeMap { + private ConcurrentMap<String, MountVolumeInfo> + mountVolumeMapping; Review comment: This field can be declared as "final" ########## 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: let's also add a check " && usage != null" ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 506973) Time Spent: 7h 50m (was: 7h 40m) > Allow configuring DISK/ARCHIVE storage types on same device mount > ----------------------------------------------------------------- > > Key: HDFS-15548 > URL: https://issues.apache.org/jira/browse/HDFS-15548 > Project: Hadoop HDFS > Issue Type: Sub-task > Components: datanode > Reporter: Leon Gao > Assignee: Leon Gao > Priority: Major > Labels: pull-request-available > Time Spent: 7h 50m > Remaining Estimate: 0h > > We can allow configuring DISK/ARCHIVE storage types on the same device mount > on two separate directories. > Users should be able to configure the capacity for each. Also, the datanode > usage report should report stats correctly. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org