arp7 commented on a change in pull request #620: HDDS-1205. Refactor 
ReplicationManager to handle QUASI_CLOSED contain…
URL: https://github.com/apache/hadoop/pull/620#discussion_r267587317
 
 

 ##########
 File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ReplicationManager.java
 ##########
 @@ -192,24 +193,19 @@ public void stop() {
    * ReplicationMonitor thread runnable. This wakes up at configured
    * interval and processes all the containers in the system.
    */
-  private void run() {
+  private synchronized void run() {
     try {
       while (running) {
-        try {
-          final long start = Time.monotonicNow();
-          final Set<ContainerID> containerIds =
-              containerManager.getContainerIDs();
-          containerIds.forEach(this::processContainer);
-          LOG.info("Replication Monitor Thread took {} milliseconds for" +
-                  " processing {} containers.", Time.monotonicNow() - start,
-              containerIds.size());
-          if (!Thread.interrupted()) {
-            Thread.sleep(interval);
-          }
-        } catch (InterruptedException ex) {
-          // Wakeup and process the containers.
-          LOG.debug("Replication Monitor Thread got interrupted.");
-        }
+        final long start = Time.monotonicNow();
+        final Set<ContainerID> containerIds =
+            containerManager.getContainerIDs();
+        containerIds.forEach(this::processContainer);
+
+        LOG.info("Replication Monitor Thread took {} milliseconds for" +
+                " processing {} containers.", Time.monotonicNow() - start,
+            containerIds.size());
+
+        wait(interval);
       }
     } catch (Throwable t) {
       // When we get runtime exception, we should terminate SCM.
 
 Review comment:
   Don't call terminate if running is false. In that case, just exit the 
thread. See RedundancyMonitor#run in HDFS BlockManager.java.

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


With regards,
Apache Git Services

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

Reply via email to