Interface Coordinator
- All Superinterfaces:
AutoCloseable
,Closeable
Simple tooling for coordination across a Terracotta cluster.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Builder forCoordinator
instances. -
Method Summary
Modifier and TypeMethodDescriptionacquireRole
(String role, Duration timeout) Try to acquire the given role within the supplied time.Return the current set of members in this coordinator.Return the name of the current holder of a given role.tryAcquireRole
(String role) Try to acquire the given role.
-
Method Details
-
getMembers
Return the current set of members in this coordinator.- Returns:
- the coordinator members
-
holder
Return the name of the current holder of a given role.- Parameters:
role
- role of interest- Returns:
- the current role holder
-
tryAcquireRole
Try to acquire the given role.If the role is acquired then tasks can be run as the role holder using the returned
Role
object. If the role cannot be acquired then an emptyOptional
will be returned.- Parameters:
role
- role to be acquired- Returns:
- a handle representing the role, or an empty
Optional
-
acquireRole
Try to acquire the given role within the supplied time.If the role is acquired then tasks can be run as the role holder using the returned
Role
object. If the role cannot be acquired within the given time than aTimeoutException
is thrown.- Parameters:
role
- role to be acquiredtimeout
- time available to acquire the role; ifDuration.ZERO
, acquires the role if, and only if, it is immediately available- Returns:
- a handle representing the role
- Throws:
TimeoutException
- if the role cannot be acquired before timeoutInterruptedException
- if the thread is interrupted on entry or while acquiring the role
-