public class Timing2 extends Object
Constructor and Description |
---|
Timing2()
Use the default base time
|
Timing2(double multiple)
Use a multiple of the default base time
|
Timing2(double multiple,
int waitingMultiple)
Use a multiple of the default base time
|
Timing2(long value,
TimeUnit unit) |
Timing2(long value,
TimeUnit unit,
int waitingMultiple) |
Modifier and Type | Method and Description |
---|---|
boolean |
acquireSemaphore(Semaphore semaphore)
Wait on the given semaphore
|
boolean |
acquireSemaphore(Semaphore semaphore,
int n)
Wait on the given semaphore
|
boolean |
awaitLatch(CountDownLatch latch)
Wait on the given latch
|
int |
connection()
Return the value to use for ZK connection timeout
|
Timing2 |
forSessionSleep()
Return a new timing with a multiple that ensures a ZK session timeout
|
Timing2 |
forSleepingABit()
Return a new timing with a multiple for sleeping a smaller amount of time
|
Timing2 |
forWaiting()
Return a new timing with the standard multiple for waiting on latches, etc.
|
int |
milliseconds()
Return the base time in milliseconds
|
Timing2 |
multiple(double n)
Return a new timing that is a multiple of the this timing
|
Timing2 |
multiple(double n,
int waitingMultiple)
Return a new timing that is a multiple of the this timing
|
int |
seconds()
Return the base time in seconds
|
int |
session()
Return the value to use for ZK session timeout
|
void |
sleep()
Sleep for a the full amount of time
|
void |
sleepABit()
Sleep for a small amount of time
|
<T> T |
takeFromQueue(BlockingQueue<T> queue)
Try to take an item from the given queue
|
int |
tickTime()
Value to use for server "tickTime"
|
public Timing2()
public Timing2(double multiple)
multiple
- the multiplepublic Timing2(double multiple, int waitingMultiple)
multiple
- the multiplewaitingMultiple
- multiple of main timing to use when waitingpublic Timing2(long value, TimeUnit unit)
value
- base timeunit
- base time unitpublic Timing2(long value, TimeUnit unit, int waitingMultiple)
value
- base timeunit
- base time unitwaitingMultiple
- multiple of main timing to use when waitingpublic int milliseconds()
public int seconds()
public boolean awaitLatch(CountDownLatch latch)
latch
- latch to wait onCountDownLatch.await(long, java.util.concurrent.TimeUnit)
public <T> T takeFromQueue(BlockingQueue<T> queue) throws Exception
queue
- queueException
- interrupted or timed outpublic boolean acquireSemaphore(Semaphore semaphore)
semaphore
- the semaphoreSemaphore.tryAcquire()
public boolean acquireSemaphore(Semaphore semaphore, int n)
semaphore
- the semaphoren
- number of permits to acquireSemaphore.tryAcquire(int, long, java.util.concurrent.TimeUnit)
public Timing2 multiple(double n)
n
- the multiplepublic Timing2 multiple(double n, int waitingMultiple)
n
- the multiplewaitingMultiple
- new waitingMultiplepublic Timing2 forWaiting()
public Timing2 forSessionSleep()
public Timing2 forSleepingABit()
public void sleepABit() throws InterruptedException
InterruptedException
- if interruptedpublic void sleep() throws InterruptedException
InterruptedException
- if interruptedpublic int session()
public int connection()
public int tickTime()
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.