org.ros.internal.node
Class CountDownRegistrantListener<T>

java.lang.Object
  extended by org.ros.internal.node.CountDownRegistrantListener<T>
All Implemented Interfaces:
RegistrantListener<T>
Direct Known Subclasses:
CountDownPublisherListener, CountDownServiceServerListener, CountDownSubscriberListener

public class CountDownRegistrantListener<T>
extends java.lang.Object
implements RegistrantListener<T>


Constructor Summary
CountDownRegistrantListener()
          Construct a CountDownPublisherListener with all counts set to 1.
CountDownRegistrantListener(java.util.concurrent.CountDownLatch masterRegistrationSuccessLatch, java.util.concurrent.CountDownLatch masterRegistrationFailureLatch, java.util.concurrent.CountDownLatch masterUnregistrationSuccessLatch, java.util.concurrent.CountDownLatch masterUnregistrationFailureLatch)
           
CountDownRegistrantListener(int masterRegistrationSuccessCount, int masterRegistrationFailureCount, int masterUnregistrationSuccessCount, int masterUnregistrationFailureCount)
           
 
Method Summary
 void awaitMasterRegistrationFailure()
          Wait for the requested number of failed registrations.
 boolean awaitMasterRegistrationFailure(long timeout, java.util.concurrent.TimeUnit unit)
          Wait for the requested number of failed registrations within the given time period.
 void awaitMasterRegistrationSuccess()
          Wait for the requested number of successful registrations.
 boolean awaitMasterRegistrationSuccess(long timeout, java.util.concurrent.TimeUnit unit)
          Wait for the requested number of successful registrations within the given time period.
 void awaitMasterUnregistrationFailure()
          Wait for the requested number of failed unregistrations.
 boolean awaitMasterUnregistrationFailure(long timeout, java.util.concurrent.TimeUnit unit)
          Wait for the requested number of failed unregistrations within the given time period.
 void awaitMasterUnregistrationSuccess()
          Wait for the requested number of successful unregistrations.
 boolean awaitMasterUnregistrationSuccess(long timeout, java.util.concurrent.TimeUnit unit)
          Wait for the requested number of successful unregistrations within the given time period.
 void onMasterRegistrationFailure(T registrant)
          The registrant has failed to register with the master.
 void onMasterRegistrationSuccess(T registrant)
          The registrant has been registered with the master.
 void onMasterUnregistrationFailure(T registrant)
          The registrant has failed to unregister with the master.
 void onMasterUnregistrationSuccess(T registrant)
          The registrant has been unregistered with the master.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountDownRegistrantListener

public CountDownRegistrantListener()
Construct a CountDownPublisherListener with all counts set to 1.


CountDownRegistrantListener

public CountDownRegistrantListener(int masterRegistrationSuccessCount,
                                   int masterRegistrationFailureCount,
                                   int masterUnregistrationSuccessCount,
                                   int masterUnregistrationFailureCount)
Parameters:
masterRegistrationSuccessCount - the number of successful master registrations to wait for
masterRegistrationFailureCount - the number of failing master registrations to wait for
masterUnregistrationSuccessCount - the number of successful master unregistrations to wait for
masterUnregistrationFailureCount - the number of failing master unregistrations to wait for

CountDownRegistrantListener

public CountDownRegistrantListener(java.util.concurrent.CountDownLatch masterRegistrationSuccessLatch,
                                   java.util.concurrent.CountDownLatch masterRegistrationFailureLatch,
                                   java.util.concurrent.CountDownLatch masterUnregistrationSuccessLatch,
                                   java.util.concurrent.CountDownLatch masterUnregistrationFailureLatch)
Method Detail

onMasterRegistrationSuccess

public void onMasterRegistrationSuccess(T registrant)
Description copied from interface: RegistrantListener
The registrant has been registered with the master.

Specified by:
onMasterRegistrationSuccess in interface RegistrantListener<T>
Parameters:
registrant - the registrant which has been registered

onMasterRegistrationFailure

public void onMasterRegistrationFailure(T registrant)
Description copied from interface: RegistrantListener
The registrant has failed to register with the master.

This may be called multiple times per registrant since master registration will be retried until success.

Specified by:
onMasterRegistrationFailure in interface RegistrantListener<T>
Parameters:
registrant - the registrant which has been registered

onMasterUnregistrationSuccess

public void onMasterUnregistrationSuccess(T registrant)
Description copied from interface: RegistrantListener
The registrant has been unregistered with the master.

Specified by:
onMasterUnregistrationSuccess in interface RegistrantListener<T>
Parameters:
registrant - the registrant which has been unregistered

onMasterUnregistrationFailure

public void onMasterUnregistrationFailure(T registrant)
Description copied from interface: RegistrantListener
The registrant has failed to unregister with the master.

This may be called multiple times per registrant since master unregistration will be retried until success.

Specified by:
onMasterUnregistrationFailure in interface RegistrantListener<T>
Parameters:
registrant - the registrant which has been unregistered

awaitMasterRegistrationSuccess

public void awaitMasterRegistrationSuccess()
                                    throws java.lang.InterruptedException
Wait for the requested number of successful registrations.

Throws:
java.lang.InterruptedException

awaitMasterRegistrationSuccess

public boolean awaitMasterRegistrationSuccess(long timeout,
                                              java.util.concurrent.TimeUnit unit)
                                       throws java.lang.InterruptedException
Wait for the requested number of successful registrations within the given time period.

Parameters:
timeout - the maximum time to wait
unit - the TimeUnit of the timeout argument
Returns:
true if the registration happened within the time period, false otherwise
Throws:
java.lang.InterruptedException

awaitMasterUnregistrationSuccess

public void awaitMasterUnregistrationSuccess()
                                      throws java.lang.InterruptedException
Wait for the requested number of successful unregistrations.

Throws:
java.lang.InterruptedException

awaitMasterUnregistrationSuccess

public boolean awaitMasterUnregistrationSuccess(long timeout,
                                                java.util.concurrent.TimeUnit unit)
                                         throws java.lang.InterruptedException
Wait for the requested number of successful unregistrations within the given time period.

Parameters:
timeout - the maximum time to wait
unit - the TimeUnit of the timeout argument
Returns:
true if the unregistration happened within the time period, false otherwise
Throws:
java.lang.InterruptedException

awaitMasterRegistrationFailure

public void awaitMasterRegistrationFailure()
                                    throws java.lang.InterruptedException
Wait for the requested number of failed registrations.

Throws:
java.lang.InterruptedException

awaitMasterRegistrationFailure

public boolean awaitMasterRegistrationFailure(long timeout,
                                              java.util.concurrent.TimeUnit unit)
                                       throws java.lang.InterruptedException
Wait for the requested number of failed registrations within the given time period.

Parameters:
timeout - the maximum time to wait
unit - the TimeUnit of the timeout argument
Returns:
true if the registration happened within the time period, false otherwise
Throws:
java.lang.InterruptedException

awaitMasterUnregistrationFailure

public void awaitMasterUnregistrationFailure()
                                      throws java.lang.InterruptedException
Wait for the requested number of failed unregistrations.

Throws:
java.lang.InterruptedException

awaitMasterUnregistrationFailure

public boolean awaitMasterUnregistrationFailure(long timeout,
                                                java.util.concurrent.TimeUnit unit)
                                         throws java.lang.InterruptedException
Wait for the requested number of failed unregistrations within the given time period.

Parameters:
timeout - the maximum time to wait
unit - the TimeUnit of the timeout argument
Returns:
true if the unregistration happened within the time period, false otherwise
Throws:
java.lang.InterruptedException