T - The type of return messages expected from the broadcastpublic class Broadcaster<T> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Broadcaster.Action<T>
Interface describing the action to take.
|
| Constructor and Description |
|---|
Broadcaster(Collection<NodeInfo> destinations,
Broadcaster.Action<T> action,
Consumer<T> onNextCallback)
Initialize the broadcaster to send to given
destinations using the given action, invoking the
given onNextCallback when replies are received. |
| Modifier and Type | Method and Description |
|---|---|
void |
broadcast(int timeout,
TimeUnit unit)
Send a broadcast, waiting at most the given
waitTime for results to come back. |
public Broadcaster(Collection<NodeInfo> destinations, Broadcaster.Action<T> action, Consumer<T> onNextCallback)
destinations using the given action, invoking the
given onNextCallback when replies are received.destinations - The destinations to broadcast messages toaction - The action to take for each destinationonNextCallback - The callback to invoke when results are receivedpublic void broadcast(int timeout,
TimeUnit unit)
throws InterruptedException
waitTime for results to come back. This method returns when
all responses have been received, or the timeout has been reached.timeout - The amount of time to wait for all responsesunit - The unit of timeInterruptedException - when the thread was interrupted while waitingCopyright © 2017–2018. All rights reserved.