hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nitay Joffe (JIRA)" <j...@apache.org>
Subject [jira] Created: (HBASE-1000) Sleeper.sleep does not go back to sleep when interrupted and no stop flag given.
Date Thu, 13 Nov 2008 19:20:44 GMT
Sleeper.sleep does not go back to sleep when interrupted and no stop flag given.
--------------------------------------------------------------------------------

                 Key: HBASE-1000
                 URL: https://issues.apache.org/jira/browse/HBASE-1000
             Project: Hadoop HBase
          Issue Type: Bug
          Components: util
            Reporter: Nitay Joffe
            Priority: Trivial


When interrupted, the Sleeper.sleep method should exit if the stop flag was given, otherwise
it should continue sleeping. Currently it seems to exits regardless, which means the stop
flag is meaningless.

Here is the relevant code, from src/java/org/apache/hadoop/hbase/util/Sleeper.java:

  public void sleep(final long startTime) {
    if (this.stop.get()) {
      return;
    }
    long now = System.currentTimeMillis();
    long waitTime = this.period - (now - startTime);
    if (waitTime > this.period) {
      LOG.warn("Calculated wait time > " + this.period +
        "; setting to this.period: " + System.currentTimeMillis() + ", " +
        startTime);
    }
    if (waitTime > 0) {
      try {
        Thread.sleep(waitTime);
        long slept = System.currentTimeMillis() - now;
        if (slept > (10 * this.period)) {
          LOG.warn("We slept " + slept + "ms, ten times longer than scheduled: " +
            this.period);
        }
      } catch(InterruptedException iex) {
        // We we interrupted because we're meant to stop?  If not, just
        // continue ignoring the interruption
        if (this.stop.get()) {
          return;
        }
      }
    }
  }

Essentially, the 'if (waitTime > 0)' portion needs to change to a while loop so that the
sleeping will continue after an interruption occurs. I'll attach a patch when I get around
to fixing it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message