hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r723589 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/Chore.java src/java/org/apache/hadoop/hbase/util/Sleeper.java
Date Fri, 05 Dec 2008 05:26:29 GMT
Author: stack
Date: Thu Dec  4 21:26:28 2008
New Revision: 723589

URL: http://svn.apache.org/viewvc?rev=723589&view=rev
Log:
HBASE-1000 Sleeper.sleep does not go back to sleep when interrupted and no stop flag given.

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Chore.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Sleeper.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=723589&r1=723588&r2=723589&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Dec  4 21:26:28 2008
@@ -99,6 +99,8 @@
    HBASE-1039  Compaction fails if bloomfilters are enabled
    HBASE-1027  Make global flusher check work with percentages rather than
                hard code memory sizes
+   HBASE-1000  Sleeper.sleep does not go back to sleep when interrupted
+               and no stop flag given.
 
   IMPROVEMENTS
    HBASE-901   Add a limit to key length, check key and value length on client side

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Chore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Chore.java?rev=723589&r1=723588&r2=723589&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Chore.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Chore.java Thu Dec  4 21:26:28 2008
@@ -59,19 +59,21 @@
         this.sleeper.sleep();
       }
       this.sleeper.sleep();
-      while(!this.stop.get()) {
+      while (!this.stop.get()) {
+        long startTime = System.currentTimeMillis();
         try {
-          long startTime = System.currentTimeMillis();
           chore();
-          this.sleeper.sleep(startTime);
         } catch (Exception e) {
           LOG.error("Caught exception", e);
+          if (this.stop.get()) {
+            continue;
+          }
         }
+        this.sleeper.sleep(startTime);
       }
     } catch (Throwable t) {
       LOG.fatal("Caught error. Starting shutdown.", t);
       this.stop.set(true);
-      
     } finally {
       LOG.info(getName() + " exiting");
     }
@@ -97,4 +99,4 @@
   protected void sleep() {
     this.sleeper.sleep();
   }
-}
\ No newline at end of file
+}

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Sleeper.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Sleeper.java?rev=723589&r1=723588&r2=723589&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Sleeper.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Sleeper.java Thu Dec  4 21:26:28
2008
@@ -66,11 +66,14 @@
       LOG.warn("Calculated wait time > " + this.period +
         "; setting to this.period: " + System.currentTimeMillis() + ", " +
         startTime);
+      waitTime = this.period;
     }
-    if (waitTime > 0) {
+    while (waitTime > 0) {
+      long woke = -1;
       try {
         Thread.sleep(waitTime);
-        long slept = System.currentTimeMillis() - now;
+        woke = System.currentTimeMillis();
+        long slept = woke - now;
         if (slept > (10 * this.period)) {
           LOG.warn("We slept " + slept + "ms, ten times longer than scheduled: " +
             this.period);
@@ -82,6 +85,9 @@
           return;
         }
       }
+      // Recalculate waitTime.
+      woke = (woke == -1)? System.currentTimeMillis(): woke;
+      waitTime = this.period - (woke - startTime);
     }
   }
 }



Mime
View raw message