You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/10/23 09:40:04 UTC

[GitHub] [hadoop-ozone] bshashikant commented on a change in pull request #1513: HDDS-4366. SCM deletion service should delete configured number of blocks every interval.

bshashikant commented on a change in pull request #1513:
URL: https://github.com/apache/hadoop-ozone/pull/1513#discussion_r510761184



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
##########
@@ -127,62 +112,65 @@ public int getPriority() {
 
     @Override
     public EmptyTaskResult call() throws Exception {
-      int dnTxCount = 0;
       long startTime = Time.monotonicNow();
       // Scan SCM DB in HB interval and collect a throttled list of
       // to delete blocks.
-      LOG.debug("Running DeletedBlockTransactionScanner");
-      DatanodeDeletedBlockTransactions transactions = null;
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Running DeletedBlockTransactionScanner");
+      }
+
       List<DatanodeDetails> datanodes = nodeManager.getNodes(NodeState.HEALTHY);
-      Map<Long, Long> transactionMap = null;
       if (datanodes != null) {
-        transactions = new DatanodeDeletedBlockTransactions(containerManager,
-            blockDeleteLimitSize, datanodes.size());
         try {
-          transactionMap = deletedBlockLog.getTransactions(transactions);
+          DatanodeDeletedBlockTransactions transactions =
+              deletedBlockLog.getTransactions(blockDeleteLimitSize);
+          Map<Long, Long> containerIdToMaxTxnId =
+              transactions.getContainerIdToTxnIdMap();
+
+          if (transactions.isEmpty()) {
+            return EmptyTaskResult.newResult();
+          }
+
+          for (Map.Entry<UUID, List<DeletedBlocksTransaction>> entry :
+              transactions.getDatanodeTransactionMap().entrySet()) {
+            UUID dnId = entry.getKey();
+            List<DeletedBlocksTransaction> dnTXs = entry.getValue();
+            if (!dnTXs.isEmpty()) {
+              // TODO commandQueue needs a cap.
+              // We should stop caching new commands if num of un-processed
+              // command is bigger than a limit, e.g 50. In case datanode goes
+              // offline for sometime, the cached commands be flooded.
+              eventPublisher.fireEvent(SCMEvents.RETRIABLE_DATANODE_COMMAND,
+                  new CommandForDatanode<>(dnId,
+                      new DeleteBlocksCommand(dnTXs)));
+              if (LOG.isDebugEnabled()) {
+                LOG.debug(
+                    "Added delete block command for datanode {} in the queue,"
+                        + " number of delete block transactions: {}{}", dnId,
+                    dnTXs.size(), LOG.isTraceEnabled() ?
+                        ", TxID list: " + String.join(",",
+                            transactions.getTransactionIDList(dnId)) : "");
+              }
+            }
+          }
+
+          containerManager.updateDeleteTransactionId(containerIdToMaxTxnId);
+          LOG.info("Totally added {} blocks to be deleted for"
+                  + " {} datanodes, task elapsed time: {}ms",
+              transactions.getBlocksDeleted(),
+              transactions.getDatanodeTransactionMap().size(),
+              Time.monotonicNow() - startTime);
         } catch (IOException e) {
           // We may tolerant a number of failures for sometime

Review comment:
       tolerant ---> tolerate

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
##########
@@ -323,31 +322,54 @@ public void addTransactions(Map<Long, List<Long>> containerBlocksMap)
   public void close() throws IOException {
   }
 
+  private void getTransaction(DeletedBlocksTransaction tx,

Review comment:
       getTransaction -> getTransactions




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org