ChenSammi commented on code in PR #3783:
URL: https://github.com/apache/ozone/pull/3783#discussion_r984185738


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/events/FixedThreadPoolWithAffinityExecutor.java:
##########
@@ -154,15 +175,77 @@ public long scheduledEvents() {
     return scheduled.value();
   }
 
+  @Override
+  public long droppedEvents() {
+    return dropped.value();
+  }
+
   @Override
   public void close() {
+    isRunning.set(false);
     for (ThreadPoolExecutor executor : executors) {
       executor.shutdown();
     }
+    EXECUTOR_MAP.clear();
   }
 
   @Override
   public String getName() {
     return name;
   }
+
+  /**
+   * Runnable class to perform execution of payload.
+   */
+  public static class ReportExecutor<P> implements Runnable {
+    private BlockingQueue<P> queue;
+    private AtomicBoolean isRunning;
+
+    public ReportExecutor(BlockingQueue<P> queue, AtomicBoolean isRunning) {
+      this.queue = queue;
+      this.isRunning = isRunning;
+    }
+
+    @Override
+    public void run() {
+      while (isRunning.get()) {
+        try {
+          Object report = queue.poll(1, TimeUnit.MILLISECONDS);
+          if (report == null) {
+            continue;
+          }
+
+          FixedThreadPoolWithAffinityExecutor executor = EXECUTOR_MAP.get(
+              report.getClass().getName());
+          if (null == executor) {
+            continue;
+          }
+
+          executor.scheduled.incr();
+          try {
+            executor.eventHandler.onMessage(report,
+                executor.eventPublisher);
+            executor.done.incr();
+          } catch (Exception ex) {
+            LOG.error("Error on execution message {}", report, ex);
+            executor.failed.incr();
+          }
+          if (Thread.currentThread().isInterrupted()) {
+            LOG.warn("Interrupt of execution of Reports");
+            return;
+          }
+        } catch (InterruptedException e) {
+          LOG.warn("Interrupt of execution of Reports");
+          return;

Review Comment:
    Add "Thread.currentThread().interrupt();" statement.



-- 
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