public class CountDownSubscriberListener<T> extends CountDownRegistrantListener<Subscriber<T>> implements SubscriberListener<T>
SubscriberListener
which uses separate CountDownLatch
instances for all messages.Modifier and Type | Method and Description |
---|---|
void |
awaitNewPublisher()
Wait for the requested number of new publishers.
|
boolean |
awaitNewPublisher(long timeout,
java.util.concurrent.TimeUnit unit)
Wait for the requested number of new publishers within the given time
period.
|
void |
awaitShutdown()
Wait for shutdown.
|
boolean |
awaitShutdown(long timeout,
java.util.concurrent.TimeUnit unit)
Wait for shutdown within the given time period.
|
static <T> CountDownSubscriberListener<T> |
newDefault()
Construct a
CountDownSubscriberListener with all counts set to 1. |
static <T> CountDownSubscriberListener<T> |
newFromCounts(int masterRegistrationSuccessCount,
int masterRegistrationFailureCount,
int masterUnregistrationSuccessCount,
int masterUnregistrationFailureCount,
int newSubscriberCount) |
void |
onNewPublisher(Subscriber<T> subscriber,
PublisherIdentifier publisherIdentifier)
A new
Publisher has connected to the Subscriber . |
void |
onShutdown(Subscriber<T> subscriber)
The
Subscriber has been shut down. |
awaitMasterRegistrationFailure, awaitMasterRegistrationFailure, awaitMasterRegistrationSuccess, awaitMasterRegistrationSuccess, awaitMasterUnregistrationFailure, awaitMasterUnregistrationFailure, awaitMasterUnregistrationSuccess, awaitMasterUnregistrationSuccess, onMasterRegistrationFailure, onMasterRegistrationSuccess, onMasterUnregistrationFailure, onMasterUnregistrationSuccess
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onMasterRegistrationFailure, onMasterRegistrationSuccess, onMasterUnregistrationFailure, onMasterUnregistrationSuccess
public static <T> CountDownSubscriberListener<T> newDefault()
CountDownSubscriberListener
with all counts set to 1.public static <T> CountDownSubscriberListener<T> newFromCounts(int masterRegistrationSuccessCount, int masterRegistrationFailureCount, int masterUnregistrationSuccessCount, int masterUnregistrationFailureCount, int newSubscriberCount)
masterRegistrationSuccessCount
- the number of successful master registrations to wait formasterRegistrationFailureCount
- the number of failing master registrations to wait formasterUnregistrationSuccessCount
- the number of successful master unregistrations to wait formasterUnregistrationFailureCount
- the number of failing master unregistrations to wait fornewSubscriberCount
- the number of counts to wait for for a new publisherpublic void onNewPublisher(Subscriber<T> subscriber, PublisherIdentifier publisherIdentifier)
SubscriberListener
Publisher
has connected to the Subscriber
.onNewPublisher
in interface SubscriberListener<T>
subscriber
- the Subscriber
that the Publisher
connected topublisherIdentifier
- the PublisherIdentifier
of the new Publisher
public void onShutdown(Subscriber<T> subscriber)
SubscriberListener
Subscriber
has been shut down.onShutdown
in interface SubscriberListener<T>
subscriber
- the Subscriber
that was shut downpublic void awaitNewPublisher() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean awaitNewPublisher(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumenttrue
if the new publishers connected within the time
period, false
otherwisejava.lang.InterruptedException
public void awaitShutdown() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean awaitShutdown(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumenttrue
if the shutdowns happened within the time period,
false
otherwisejava.lang.InterruptedException