Package org.apache.drill.exec.testing
Class CountDownLatchInjectionImpl
java.lang.Object
org.apache.drill.exec.testing.Injection
org.apache.drill.exec.testing.CountDownLatchInjectionImpl
- All Implemented Interfaces:
AutoCloseable
,AutoCloseables.Closeable
,CountDownLatchInjection
See
CountDownLatchInjection
Degenerates to
PauseInjection.pause()
, if initialized to zero count. In any case, this injection
provides more control than PauseInjection.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
await()
Causes the current thread to wait until the latch has counted down to zero, unless the thread isinterrupted
.void
Await without interruption.void
close()
Close the latch.void
Decrements the count of the latch, releasing all waiting threads if the count reaches zero.void
initialize
(int count) Initializes the underlying latchprotected boolean
This function checks if it is the right time for the injection to happen.Methods inherited from class org.apache.drill.exec.testing.Injection
getDesc, getMsPause, getSiteClass, isValidForBit, toString
-
Method Details
-
injectNow
protected boolean injectNow()Description copied from class:Injection
This function checks if it is the right time for the injection to happen. -
initialize
public void initialize(int count) Description copied from interface:CountDownLatchInjection
Initializes the underlying latch- Specified by:
initialize
in interfaceCountDownLatchInjection
- Parameters:
count
- the number of timesCountDownLatchInjection.countDown()
must be invoke before threads can pass throughCountDownLatchInjection.await()
-
await
Description copied from interface:CountDownLatchInjection
Causes the current thread to wait until the latch has counted down to zero, unless the thread isinterrupted
.- Specified by:
await
in interfaceCountDownLatchInjection
- Throws:
InterruptedException
-
awaitUninterruptibly
public void awaitUninterruptibly()Description copied from interface:CountDownLatchInjection
Await without interruption. In the case of interruption, log a warning and continue to wait.- Specified by:
awaitUninterruptibly
in interfaceCountDownLatchInjection
-
countDown
public void countDown()Description copied from interface:CountDownLatchInjection
Decrements the count of the latch, releasing all waiting threads if the count reaches zero.- Specified by:
countDown
in interfaceCountDownLatchInjection
-
close
public void close()Description copied from interface:CountDownLatchInjection
Close the latch.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceAutoCloseables.Closeable
- Specified by:
close
in interfaceCountDownLatchInjection
-