Package io.hekate.coordinate
Interface CoordinationContext
-
- All Superinterfaces:
HekateSupport
- All Known Subinterfaces:
CoordinatorContext
public interface CoordinationContext extends HekateSupport
Coordination context forCoordinationHandler
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
broadcast(Object request, CoordinationBroadcastCallback callback)
Asynchronously sends the specified request to allmembers
of this coordination process.void
broadcast(Object request, BooleanSupplier preCondition, Predicate<CoordinationMember> filter, CoordinationBroadcastCallback callback)
Asynchronously sends the specified request to those members that do match the specified filter and only if the specified precondition istrue
.void
broadcast(Object request, Predicate<CoordinationMember> filter, CoordinationBroadcastCallback callback)
Asynchronously sends the specified request to those members that do match the specified filter.CoordinationMember
coordinator()
Returns the coordinator.Object
getAttachment()
Returns a user-defined object that is attached to this context (seesetAttachment(Object)
).boolean
isCancelled()
Returnstrue
if this coordination process wascancelled
.boolean
isCoordinator()
Returnstrue
if local node is the coordinator.boolean
isDone()
Returnstrue
if this coordination process is complete (eithersuccessfully
or byCoordinationHandler.cancel(CoordinationContext)
cancellation).CoordinationMember
localMember()
Returns the local node member.CoordinationMember
memberOf(ClusterNode node)
Returns member by its cluster node.CoordinationMember
memberOf(ClusterNodeId nodeId)
Returns member by its cluster node identifier.List<CoordinationMember>
members()
Returns all members of this coordination process.void
setAttachment(Object attachment)
Sets the user-defined object that should be attached to this context.int
size()
Returns the size ofmembers()
.ClusterTopology
topology()
Returns the cluster topology of this coordination process.-
Methods inherited from interface io.hekate.core.HekateSupport
hekate
-
-
-
-
Method Detail
-
isCoordinator
boolean isCoordinator()
Returnstrue
if local node is the coordinator.- Returns:
true
if local node is the coordinator.
-
coordinator
CoordinationMember coordinator()
Returns the coordinator.- Returns:
- Coordinator.
-
topology
ClusterTopology topology()
Returns the cluster topology of this coordination process.- Returns:
- Cluster topology.
-
isDone
boolean isDone()
Returnstrue
if this coordination process is complete (eithersuccessfully
or byCoordinationHandler.cancel(CoordinationContext)
cancellation).- Returns:
true
if this coordination process is complete.
-
isCancelled
boolean isCancelled()
Returnstrue
if this coordination process wascancelled
.- Returns:
true
if this coordination process wascancelled
.
-
localMember
CoordinationMember localMember()
Returns the local node member.- Returns:
- Local node.
-
members
List<CoordinationMember> members()
Returns all members of this coordination process.- Returns:
- Coordination members.
-
memberOf
CoordinationMember memberOf(ClusterNode node)
Returns member by its cluster node.- Parameters:
node
- Cluster node.- Returns:
- Member or
null
if there is no such member.
-
memberOf
CoordinationMember memberOf(ClusterNodeId nodeId)
Returns member by its cluster node identifier.- Parameters:
nodeId
- Cluster node identifier.- Returns:
- Member or
null
if there is no such member.
-
broadcast
void broadcast(Object request, CoordinationBroadcastCallback callback)
Asynchronously sends the specified request to allmembers
of this coordination process.Note: Request will be sent to all members including the local node.
- Parameters:
request
- Request.callback
- Callback to be notified once responses have been received from all members.- See Also:
CoordinationHandler.process(CoordinationRequest, CoordinationContext)
-
broadcast
void broadcast(Object request, Predicate<CoordinationMember> filter, CoordinationBroadcastCallback callback)
Asynchronously sends the specified request to those members that do match the specified filter.If the filtered members list is empty then the message will not be submitted and the specified callback will
complete
with an empty result on the caller thread.- Parameters:
request
- Request.filter
- Filter.callback
- Callback to be notified once responses have been received from all members.- See Also:
CoordinationHandler.process(CoordinationRequest, CoordinationContext)
-
broadcast
void broadcast(Object request, BooleanSupplier preCondition, Predicate<CoordinationMember> filter, CoordinationBroadcastCallback callback)
Asynchronously sends the specified request to those members that do match the specified filter and only if the specified precondition istrue
.If precondition is
false
or if the filtered members list is empty then the message will not be submitted and the specified callback willcomplete
with an empty result on the caller thread.- Parameters:
request
- Request.preCondition
- Precondition.filter
- Filter.callback
- Callback to be notified once responses have been received from all members.- See Also:
CoordinationHandler.process(CoordinationRequest, CoordinationContext)
-
getAttachment
Object getAttachment()
Returns a user-defined object that is attached to this context (seesetAttachment(Object)
).- Returns:
- Attachment.
-
setAttachment
void setAttachment(Object attachment)
Sets the user-defined object that should be attached to this context.- Parameters:
attachment
- Attachment.
-
-