Package org.apache.curator.test
Class Timing
java.lang.Object
org.apache.curator.test.Timing
Utility to get various testing times
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
acquireSemaphore
(Semaphore semaphore) Wait on the given semaphoreboolean
acquireSemaphore
(Semaphore semaphore, int n) Wait on the given semaphoreboolean
awaitLatch
(CountDownLatch latch) Wait on the given latchint
Return the value to use for ZK connection timeoutReturn a new timing with the standard multiple for waiting on latches, etc.int
Return the base time in millisecondsmultiple
(double n) Return a new timing that is a multiple of the this timingint
seconds()
Return the base time in secondsint
session()
Return the value to use for ZK session timeoutvoid
Sleep for a small amount of time
-
Constructor Details
-
Timing
public Timing()Use the default base time -
Timing
public Timing(double multiple) Use a multiple of the default base time- Parameters:
multiple
- the multiple
-
Timing
public Timing(double multiple, int waitingMultiple) Use a multiple of the default base time- Parameters:
multiple
- the multiplewaitingMultiple
- multiple of main timing to use when waiting
-
Timing
- Parameters:
value
- base timeunit
- base time unit
-
Timing
- Parameters:
value
- base timeunit
- base time unitwaitingMultiple
- multiple of main timing to use when waiting
-
-
Method Details
-
milliseconds
public int milliseconds()Return the base time in milliseconds- Returns:
- time ms
-
seconds
public int seconds()Return the base time in seconds- Returns:
- time secs
-
awaitLatch
Wait on the given latch- Parameters:
latch
- latch to wait on- Returns:
- result of
CountDownLatch.await(long, TimeUnit)
-
acquireSemaphore
Wait on the given semaphore- Parameters:
semaphore
- the semaphore- Returns:
- result of
Semaphore.tryAcquire()
-
acquireSemaphore
Wait on the given semaphore- Parameters:
semaphore
- the semaphoren
- number of permits to acquire- Returns:
- result of
Semaphore.tryAcquire(int, long, TimeUnit)
-
multiple
Return a new timing that is a multiple of the this timing- Parameters:
n
- the multiple- Returns:
- this timing times the multiple
-
forWaiting
Return a new timing with the standard multiple for waiting on latches, etc.- Returns:
- this timing multiplied
-
sleepABit
Sleep for a small amount of time- Throws:
InterruptedException
- if interrupted
-
session
public int session()Return the value to use for ZK session timeout- Returns:
- session timeout
-
connection
public int connection()Return the value to use for ZK connection timeout- Returns:
- connection timeout
-