You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "guohao-rosicky (via GitHub)" <gi...@apache.org> on 2023/07/12 03:47:40 UTC
[GitHub] [ozone] guohao-rosicky opened a new pull request, #5047: HDDS-8995. Refactor the datanode DeleteBlockService
guohao-rosicky opened a new pull request, #5047:
URL: https://github.com/apache/ozone/pull/5047
## What changes were proposed in this pull request?
This pr refactors the DeleteBlockService.
At present, DeleteBlockService in datanode is bound to KeyValueContainer, in this PR, DeleteBlockService is abstracted to common, and DeleteBlockTask is implemented in keyvalue container, which realizes decoupling, more conducive to the subsequent expansion of other types of containers on datanode.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-8995
## How was this patch tested?
ut
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi merged pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi merged PR #5047:
URL: https://github.com/apache/ozone/pull/5047
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a diff in pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #5047:
URL: https://github.com/apache/ozone/pull/5047#discussion_r1302793909
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/BlockDeletingService.java:
##########
@@ -0,0 +1,290 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.ozone.container.common.impl;
+
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.hdds.utils.BackgroundService;
+import org.apache.hadoop.hdds.utils.BackgroundTask;
+import org.apache.hadoop.hdds.utils.BackgroundTaskQueue;
+import org.apache.hadoop.ozone.container.common.helpers.BlockDeletingServiceMetrics;
+import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils;
+import org.apache.hadoop.ozone.container.common.interfaces.ContainerDeletionChoosingPolicy;
+import org.apache.hadoop.ozone.container.common.statemachine.DatanodeConfiguration;
+import org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis;
+import org.apache.hadoop.ozone.container.keyvalue.statemachine.background.BlockDeletingTask;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+
+/**
+ * A per-datanode container block deleting service takes in charge
+ * of deleting staled ozone blocks.
+ */
+public class BlockDeletingService extends BackgroundService {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(BlockDeletingService.class);
+
+ private final OzoneContainer ozoneContainer;
+ private final ContainerDeletionChoosingPolicy containerDeletionPolicy;
+ private final ConfigurationSource conf;
+
+ private final int blockLimitPerInterval;
+
+ private final BlockDeletingServiceMetrics metrics;
+
+ // Task priority is useful when a to-delete block has weight.
+ private static final int TASK_PRIORITY_DEFAULT = 1;
+
+ public BlockDeletingService(OzoneContainer ozoneContainer,
+ long serviceInterval, long serviceTimeout,
+ TimeUnit timeUnit, int workerSize,
+ ConfigurationSource conf) {
+ super("BlockDeletingService", serviceInterval, timeUnit,
+ workerSize, serviceTimeout);
+ this.ozoneContainer = ozoneContainer;
+ try {
+ containerDeletionPolicy = conf.getClass(
+ ScmConfigKeys.OZONE_SCM_KEY_VALUE_CONTAINER_DELETION_CHOOSING_POLICY,
+ TopNOrderedContainerDeletionChoosingPolicy.class,
+ ContainerDeletionChoosingPolicy.class).newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.conf = conf;
+ DatanodeConfiguration dnConf = conf.getObject(DatanodeConfiguration.class);
+ this.blockLimitPerInterval = dnConf.getBlockDeletionLimit();
+ metrics = BlockDeletingServiceMetrics.create();
+ }
+
+ /**
+ * Pair of container data and the number of blocks to delete.
+ */
+ public static class ContainerBlockInfo {
+ private final ContainerData containerData;
+ private final Long numBlocksToDelete;
+
+ public ContainerBlockInfo(ContainerData containerData, Long blocks) {
+ this.containerData = containerData;
+ this.numBlocksToDelete = blocks;
+ }
+
+ public ContainerData getContainerData() {
+ return containerData;
+ }
+
+ public Long getBlocks() {
+ return numBlocksToDelete;
+ }
+
+ }
+
+ @Override
+ public BackgroundTaskQueue getTasks() {
+ BackgroundTaskQueue queue = new BackgroundTaskQueue();
+
+ try {
+ // We at most list a number of containers a time,
+ // in case there are too many containers and start too many workers.
+ // We must ensure there is no empty container in this result.
+ // The chosen result depends on what container deletion policy is
+ // configured.
+ List<ContainerBlockInfo> containers =
+ chooseContainerForBlockDeletion(blockLimitPerInterval,
+ containerDeletionPolicy);
+
+ BackgroundTask
+ containerBlockInfos = null;
+ long totalBlocks = 0;
+ for (ContainerBlockInfo containerBlockInfo : containers) {
+ BlockDeletingTaskBuilder builder =
+ new BlockDeletingTaskBuilder();
+ builder.setBlockDeletingService(this)
+ .setContainerBlockInfo(containerBlockInfo)
+ .setPriority(TASK_PRIORITY_DEFAULT);
+ containerBlockInfos = builder.build();
+ queue.add(containerBlockInfos);
+ totalBlocks += containerBlockInfo.getBlocks();
Review Comment:
the deleted blocks count is containerBlockInfo.numBlocksToDelete.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/BlockDeletingService.java:
##########
@@ -0,0 +1,290 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.ozone.container.common.impl;
+
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.hdds.utils.BackgroundService;
+import org.apache.hadoop.hdds.utils.BackgroundTask;
+import org.apache.hadoop.hdds.utils.BackgroundTaskQueue;
+import org.apache.hadoop.ozone.container.common.helpers.BlockDeletingServiceMetrics;
+import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils;
+import org.apache.hadoop.ozone.container.common.interfaces.ContainerDeletionChoosingPolicy;
+import org.apache.hadoop.ozone.container.common.statemachine.DatanodeConfiguration;
+import org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis;
+import org.apache.hadoop.ozone.container.keyvalue.statemachine.background.BlockDeletingTask;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+
+/**
+ * A per-datanode container block deleting service takes in charge
+ * of deleting staled ozone blocks.
+ */
+public class BlockDeletingService extends BackgroundService {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(BlockDeletingService.class);
+
+ private final OzoneContainer ozoneContainer;
+ private final ContainerDeletionChoosingPolicy containerDeletionPolicy;
+ private final ConfigurationSource conf;
+
+ private final int blockLimitPerInterval;
+
+ private final BlockDeletingServiceMetrics metrics;
+
+ // Task priority is useful when a to-delete block has weight.
+ private static final int TASK_PRIORITY_DEFAULT = 1;
+
+ public BlockDeletingService(OzoneContainer ozoneContainer,
+ long serviceInterval, long serviceTimeout,
+ TimeUnit timeUnit, int workerSize,
+ ConfigurationSource conf) {
+ super("BlockDeletingService", serviceInterval, timeUnit,
+ workerSize, serviceTimeout);
+ this.ozoneContainer = ozoneContainer;
+ try {
+ containerDeletionPolicy = conf.getClass(
+ ScmConfigKeys.OZONE_SCM_KEY_VALUE_CONTAINER_DELETION_CHOOSING_POLICY,
+ TopNOrderedContainerDeletionChoosingPolicy.class,
+ ContainerDeletionChoosingPolicy.class).newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.conf = conf;
+ DatanodeConfiguration dnConf = conf.getObject(DatanodeConfiguration.class);
+ this.blockLimitPerInterval = dnConf.getBlockDeletionLimit();
+ metrics = BlockDeletingServiceMetrics.create();
+ }
+
+ /**
+ * Pair of container data and the number of blocks to delete.
+ */
+ public static class ContainerBlockInfo {
+ private final ContainerData containerData;
+ private final Long numBlocksToDelete;
+
+ public ContainerBlockInfo(ContainerData containerData, Long blocks) {
+ this.containerData = containerData;
+ this.numBlocksToDelete = blocks;
+ }
+
+ public ContainerData getContainerData() {
+ return containerData;
+ }
+
+ public Long getBlocks() {
+ return numBlocksToDelete;
+ }
+
+ }
+
+ @Override
+ public BackgroundTaskQueue getTasks() {
+ BackgroundTaskQueue queue = new BackgroundTaskQueue();
+
+ try {
+ // We at most list a number of containers a time,
+ // in case there are too many containers and start too many workers.
+ // We must ensure there is no empty container in this result.
+ // The chosen result depends on what container deletion policy is
+ // configured.
+ List<ContainerBlockInfo> containers =
+ chooseContainerForBlockDeletion(blockLimitPerInterval,
+ containerDeletionPolicy);
+
+ BackgroundTask
+ containerBlockInfos = null;
+ long totalBlocks = 0;
+ for (ContainerBlockInfo containerBlockInfo : containers) {
+ BlockDeletingTaskBuilder builder =
+ new BlockDeletingTaskBuilder();
+ builder.setBlockDeletingService(this)
+ .setContainerBlockInfo(containerBlockInfo)
+ .setPriority(TASK_PRIORITY_DEFAULT);
+ containerBlockInfos = builder.build();
+ queue.add(containerBlockInfos);
+ totalBlocks += containerBlockInfo.getBlocks();
Review Comment:
the deleted blocks count is containerBlockInfo.numBlocksToDelete().
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guohao-rosicky commented on pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "guohao-rosicky (via GitHub)" <gi...@apache.org>.
guohao-rosicky commented on PR #5047:
URL: https://github.com/apache/ozone/pull/5047#issuecomment-1635229437
ci passed, see: [CI](https://github.com/guohao-rosicky/ozone/actions/runs/5527333803)
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a diff in pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #5047:
URL: https://github.com/apache/ozone/pull/5047#discussion_r1302776230
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ContainerUtils.java:
##########
@@ -326,4 +327,15 @@ public static long retrieveContainerIdFromTarName(String tarName)
tarName);
}
}
+
+ public static long getPendingDeletionBlocks(ContainerData containerData) {
+ if (containerData.getContainerType()
+ .equals(ContainerProtos.ContainerType.KeyValueContainer)) {
+ return ((KeyValueContainerData) containerData)
+ .getNumPendingDeletionBlocks();
+ } else {
+ // If another ContainerType is available later, implement it
+ return 0L;
Review Comment:
Please throw the exception here.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #5047:
URL: https://github.com/apache/ozone/pull/5047#issuecomment-1692826795
Thanks @guohao-rosicky for the contribution.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guohao-rosicky commented on pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "guohao-rosicky (via GitHub)" <gi...@apache.org>.
guohao-rosicky commented on PR #5047:
URL: https://github.com/apache/ozone/pull/5047#issuecomment-1691306708
ci passed, see: https://github.com/guohao-rosicky/ozone/actions/runs/5959164796
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #5047:
URL: https://github.com/apache/ozone/pull/5047#issuecomment-1691214802
The last patch LGTM. Wait for the CI to pass.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guohao-rosicky commented on pull request #5047: HDDS-8995. Refactor the datanode DeleteBlockService
Posted by "guohao-rosicky (via GitHub)" <gi...@apache.org>.
guohao-rosicky commented on PR #5047:
URL: https://github.com/apache/ozone/pull/5047#issuecomment-1631805498
PTAL @ChenSammi Thanks.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a diff in pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #5047:
URL: https://github.com/apache/ozone/pull/5047#discussion_r1302786783
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java:
##########
@@ -494,7 +494,8 @@ public void testPendingDeleteBlockReset() throws Exception {
});
OzoneContainer ozoneContainer =
mockDependencies(containerSet, keyValueHandler);
- BlockDeletingService svc = new BlockDeletingService(ozoneContainer,
+ BlockDeletingService
Review Comment:
Could you revert this one and the next change? It's preferred to have more content in one line unless it's exceeds the line length limitation.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a diff in pull request #5047: HDDS-8995. Refactor the datanode BlockDeletingService
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #5047:
URL: https://github.com/apache/ozone/pull/5047#discussion_r1302788163
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java:
##########
@@ -546,4 +546,8 @@ StorageVolumeChecker getVolumeChecker(ConfigurationSource conf) {
public ContainerMetrics getMetrics() {
return metrics;
}
+
+ public BlockDeletingService getBlockDeletingService() {
Review Comment:
This API is not used anywhere. Suggest to remove it.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org