public interface LocalGroupMember extends GroupMember
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
leave()
Leaves the membership group.
|
Listener<Long> |
onElection(Consumer<Long> callback)
Registers a callback to be called when this member is elected leader.
|
<T> Listener<T> |
onMessage(String topic,
Consumer<T> consumer)
Handles a message to the member.
|
CompletableFuture<Void> |
remove(String property)
Removes a property of the member.
|
CompletableFuture<Void> |
resign()
Resigns from leadership.
|
CompletableFuture<Void> |
set(String property,
Object value)
Sets the value of a property of the member.
|
CompletableFuture<Void> set(String property, Object value)
property - The property to set.value - The value of the property to set.CompletableFuture<Void> remove(String property)
property - The property to remove.<T> Listener<T> onMessage(String topic, Consumer<T> consumer)
T - The message type.topic - The message topic.consumer - The message consumer.Listener<Long> onElection(Consumer<Long> callback)
callback - The callback to call.CompletableFuture<Void> resign()
CompletableFuture<Void> leave()
When this member leaves the membership group, the membership lists of this and all other instances
in the group are guaranteed to be updated before the CompletableFuture returned by
this method is completed. Once this instance has left the group, the returned future will be completed.
This method returns a CompletableFuture which can be used to block until the operation completes
or to be notified in a separate thread once the operation completes. To block until the operation completes,
use the CompletableFuture.join() method to block the calling thread:
member.leave().join();
Alternatively, to execute the operation asynchronous and be notified once the lock is acquired in a different
thread, use one of the many completable future callbacks:
member.leave().thenRun(() -> System.out.println("Left the group!")));
Copyright © 2013–2016. All rights reserved.