org.apache.curator.test
Class Timing

java.lang.Object
  extended by org.apache.curator.test.Timing

public class Timing
extends Object

Utility to get various testing times


Constructor Summary
Timing()
          Use the default base time
Timing(double multiple)
          Use a multiple of the default base time
Timing(double multiple, int waitingMultiple)
          Use a multiple of the default base time
Timing(long value, TimeUnit unit)
           
Timing(long value, TimeUnit unit, int waitingMultiple)
           
 
Method Summary
 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
 Timing forWaiting()
          Return a new timing with the standard multiple for waiting on latches, etc.
 int milliseconds()
          Return the base time in milliseconds
 Timing multiple(double n)
          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 sleepABit()
          Sleep for a small amount of time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 multiple
waitingMultiple - multiple of main timing to use when waiting

Timing

public Timing(long value,
              TimeUnit unit)
Parameters:
value - base time
unit - base time unit

Timing

public Timing(long value,
              TimeUnit unit,
              int waitingMultiple)
Parameters:
value - base time
unit - base time unit
waitingMultiple - multiple of main timing to use when waiting
Method Detail

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

public boolean awaitLatch(CountDownLatch latch)
Wait on the given latch

Parameters:
latch - latch to wait on
Returns:
result of CountDownLatch.await(long, TimeUnit)

acquireSemaphore

public boolean acquireSemaphore(Semaphore semaphore)
Wait on the given semaphore

Parameters:
semaphore - the semaphore
Returns:
result of Semaphore.tryAcquire()

acquireSemaphore

public boolean acquireSemaphore(Semaphore semaphore,
                                int n)
Wait on the given semaphore

Parameters:
semaphore - the semaphore
n - number of permits to acquire
Returns:
result of Semaphore.tryAcquire(int, long, TimeUnit)

multiple

public Timing multiple(double n)
Return a new timing that is a multiple of the this timing

Parameters:
n - the multiple
Returns:
this timing times the multiple

forWaiting

public Timing forWaiting()
Return a new timing with the standard multiple for waiting on latches, etc.

Returns:
this timing multiplied

sleepABit

public void sleepABit()
               throws InterruptedException
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


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.