Interface CDSShardAccess
-
@Beta public interface CDSShardAccess
Unprivileged access interface to shard information. Provides read-only access to operational details about a CDS shard.- Author:
- Robert Varga
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NonNull LeaderLocationgetLeaderLocation()Return the shard leader location relative to the local node.@NonNull DOMDataTreeIdentifiergetShardIdentifier()Return the shard identifier.@NonNull CompletionStage<Void>makeLeaderLocal()Request the shard leader to be moved to the local node.<L extends LeaderLocationListener>
@NonNull LeaderLocationListenerRegistration<L>registerLeaderLocationListener(@NonNull L listener)Register a listener to shard location changes.
-
-
-
Method Detail
-
getShardIdentifier
@NonNull DOMDataTreeIdentifier getShardIdentifier()
Return the shard identifier.- Returns:
- Shard identifier.
- Throws:
IllegalStateException- if theCDSDataTreeProducerfrom which the associatedCDSDataTreeProduceris no longer valid.
-
getLeaderLocation
@NonNull LeaderLocation getLeaderLocation()
Return the shard leader location relative to the local node.- Returns:
- Shard leader location.
- Throws:
IllegalStateException- if theCDSDataTreeProducerfrom which the associatedCDSDataTreeProduceris no longer valid.
-
makeLeaderLocal
@NonNull CompletionStage<Void> makeLeaderLocal()
Request the shard leader to be moved to the local node. The request will be evaluated against shard state and satisfied if leader movement is possible. If current shard policy or state prevents the movement from happening, the returnedCompletionStagewill report an exception.This is a one-time operation, which does not prevent further movement happening in future. Even if this request succeeds, there is no guarantee that the leader will remain local in face of failures, shutdown or any future movement requests from other nodes.
Note that due to asynchronous nature of CDS, the leader may no longer be local by the time the returned
CompletionStagereports success.- Returns:
- A
CompletionStagerepresenting the request. - Throws:
IllegalStateException- if theCDSDataTreeProducerfrom which the associatedCDSDataTreeProduceris no longer valid.
-
registerLeaderLocationListener
<L extends LeaderLocationListener> @NonNull LeaderLocationListenerRegistration<L> registerLeaderLocationListener(@NonNull L listener)
Register a listener to shard location changes. Each listener object can be registered at most once.- Parameters:
listener- Listener object- Returns:
- A
LeaderLocationListenerRegistrationfor the listener. - Throws:
IllegalArgumentException- if the specified listener is already registered.IllegalStateException- if theCDSDataTreeProducerfrom which the associatedCDSDataTreeProduceris no longer valid.NullPointerException- if listener is null.
-
-