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] Commented: (HBASE-1000) Sleeper.sleep does not go back to sleep when interrupted and no stop flag given.
Date Fri, 05 Dec 2008 05:08:44 GMT

    [ https://issues.apache.org/jira/browse/HBASE-1000?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653631#action_12653631
] 

Nitay Joffe commented on HBASE-1000:
------------------------------------

Duplicate local variable "woke" on line 74. Get rid of the long keyword and use the variable
previously defined.

Also, the if on line 65 for the weird case where startTime is greater than now and causes
a positive offset says that we're setting the waitTime to this.period,
but we don't actually do it.

> 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
>             Fix For: 0.19.0
>
>         Attachments: 1000-v3.patch, hbase-1000-v2.patch, hbase-1000.patch
>
>
> 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:
> {code}
>   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;
>         }
>       }
>     }
>   }
> {code}
> 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