org.apache.hadoop.hbase.util
Class DrainBarrier

java.lang.Object
  extended by org.apache.hadoop.hbase.util.DrainBarrier

@InterfaceAudience.Private
public class DrainBarrier
extends Object

A simple barrier that can be used by classes that need to wait for some operations to finish before stopping/closing/etc. forever.


Constructor Summary
DrainBarrier()
           
 
Method Summary
 boolean beginOp()
          Tries to start an operation.
 void endOp()
          Ends the operation.
 void stopAndDrainOps()
          Blocks new operations from starting, waits for the current ones to drain.
 void stopAndDrainOpsOnce()
          Blocks new operations from starting, waits for the current ones to drain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrainBarrier

public DrainBarrier()
Method Detail

beginOp

public boolean beginOp()
Tries to start an operation.

Returns:
false iff the stop is in progress, and the operation cannot be started.

endOp

public void endOp()
Ends the operation. Unblocks the blocked caller of stop, if necessary.


stopAndDrainOps

public void stopAndDrainOps()
                     throws InterruptedException
Blocks new operations from starting, waits for the current ones to drain. If someone already called it, returns immediately, which is currently unavoidable as most of the users stop and close things right and left, and hope for the best. stopAndWaitForOpsOnce asserts instead.

Throws:
InterruptedException - the wait for operations has been interrupted.

stopAndDrainOpsOnce

public void stopAndDrainOpsOnce()
                         throws InterruptedException
Blocks new operations from starting, waits for the current ones to drain. Can only be called once.

Throws:
InterruptedException - the wait for operations has been interrupted.


Copyright © 2015 The Apache Software Foundation. All Rights Reserved.