jojochuang commented on a change in pull request #2420:
URL: https://github.com/apache/ozone/pull/2420#discussion_r672938152



##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java
##########
@@ -76,34 +84,177 @@
   private final ConfigurationSource conf;
   private int invocationCount;
   private long totalTime;
-  private boolean cmdExecuted;
+  private final ExecutorService executor;
+  private final LinkedBlockingQueue<DeleteCmdInfo> deleteCommandQueues;
+  private final Daemon handlerThread;
 
   public DeleteBlocksCommandHandler(ContainerSet cset,
-      ConfigurationSource conf) {
+      ConfigurationSource conf, int threadPoolSize, int queueLimit) {
     this.containerSet = cset;
     this.conf = conf;
+    this.executor = new ThreadPoolExecutor(
+        0, threadPoolSize, 60, TimeUnit.SECONDS,
+        new LinkedBlockingQueue<>(),
+        new ThreadFactoryBuilder().setDaemon(true)
+            .setNameFormat("DeleteBlocksCommandHandlerThread-%d")
+            .build());
+    this.deleteCommandQueues = new LinkedBlockingQueue<>(queueLimit);
+    handlerThread = new Daemon(new DeleteCmdWorker());
+    handlerThread.start();
   }
 
   @Override
   public void handle(SCMCommand command, OzoneContainer container,
       StateContext context, SCMConnectionManager connectionManager) {
-    cmdExecuted = false;
-    long startTime = Time.monotonicNow();
-    ContainerBlocksDeletionACKProto blockDeletionACK = null;
+    if (command.getType() != SCMCommandProto.Type.deleteBlocksCommand) {
+      LOG.warn("Skipping handling command, expected command "
+              + "type {} but found {}",
+          SCMCommandProto.Type.deleteBlocksCommand, command.getType());
+      return;
+    }
+
     try {
-      if (command.getType() != SCMCommandProto.Type.deleteBlocksCommand) {
-        LOG.warn("Skipping handling command, expected command "
-                + "type {} but found {}",
-            SCMCommandProto.Type.deleteBlocksCommand, command.getType());
-        return;
+      DeleteCmdInfo cmd = new DeleteCmdInfo((DeleteBlocksCommand) command,
+          container, context, connectionManager);
+      deleteCommandQueues.add(cmd);
+    } catch (Exception e) {
+      LOG.warn("Command is discarded because of the command queue is full");

Review comment:
       is this right? Looking at AbstractQueue, the add() can throw these 
exceptions:
   
   IllegalStateException - if the element cannot be added at this time due to 
capacity restrictions
   ClassCastException - if the class of the specified element prevents it from 
being added to this queue
   NullPointerException - if the specified element is null and this queue does 
not permit null elements
   IllegalArgumentException - if some property of this element prevents it from 
being added to this queue




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to