Interface CoordinationService
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
CoordinationServiceImpl
Interface for the coordination service. Provides abstraction for distributed locks and leader election.
-
Method Summary
Modifier and TypeMethodDescription<T> LeaderElection<T>getLeaderElection(Class<T> clazz, String path, Consumer<LeaderElectionState> stateChangesListener) Create a newLeaderElectioncontroller.<T> LockManager<T>getLockManager(Class<T> clazz) <T> LockManager<T>getLockManager(MetadataSerde<T> serde) getNextCounterValue(String path) Increment a counter identified by the specified path and return the current value.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
getLeaderElection
<T> LeaderElection<T> getLeaderElection(Class<T> clazz, String path, Consumer<LeaderElectionState> stateChangesListener) Create a newLeaderElectioncontroller.- Parameters:
clazz- the class type to be used for serialization/deserializationpath- the path to use for the leader electionstateChangesListener- a listener that will be passed all the state changes- Returns:
-
getLockManager
-
getLockManager
-
getNextCounterValue
Increment a counter identified by the specified path and return the current value. The counter value will be guaranteed to be unique within the context of the path. It will retry whenMetadataStoreExceptionhappened. If the maximum number of retries is reached and still failed, the feature will complete with exceptionMetadataStoreException.- Parameters:
path- the path that identifies a particular counter- Returns:
- a future that will track the completion of the operation
- Throws:
CoordinationServiceException- if there's a failure in incrementing the counter
-