Module org.elasticsearch.security
Class SecurityIndexManager
java.lang.Object
org.elasticsearch.xpack.security.support.SecurityIndexManager
- All Implemented Interfaces:
ClusterStateListener
Manages the lifecycle, mapping and data upgrades/migrations of the
RestrictedIndicesNames#SECURITY_MAIN_ALIAS
and RestrictedIndicesNames#SECURITY_MAIN_ALIAS alias-index pair.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhen checking availability, check for availability of search or availability of all primariesclassstatic enumstatic enum -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStateListener(TriConsumer<ProjectId, SecurityIndexManager.IndexState, SecurityIndexManager.IndexState> listener) Add a listener for notifications on state changes to the configured index.static SecurityIndexManagerbuildSecurityIndexManager(Client client, ClusterService clusterService, FeatureService featureService, ProjectResolver projectResolver, SystemIndexDescriptor descriptor) voidRetrieves the project scoped index state for thecurrent project.static intgetMigrationVersionFromIndexMetadata(IndexMetadata indexMetadata) getProject(ProjectId project) Retrieves the project scoped index state.static booleanisIndexDeleted(SecurityIndexManager.IndexState previousState, SecurityIndexManager.IndexState currentState) Return true if the state moves from the index existing to the index not existing.static booleanisMoveFromRedToNonRed(SecurityIndexManager.IndexState previousState, SecurityIndexManager.IndexState currentState) Return true if the state moves from an unhealthy ("RED") index state to a healthy ("non-RED") state.voidremoveStateListener(TriConsumer<ProjectId, SecurityIndexManager.IndexState, SecurityIndexManager.IndexState> listener) Remove a listener from notifications on state changes to the configured index.static IndexMetadataresolveConcreteIndex(String indexOrAliasName, ProjectMetadata project) Resolves a concrete index name or alias to aIndexMetadatainstance.voidResolves a freshSecurityIndexManager.IndexStatefor the current project once the security index is available for search, waiting up toSECURITY_INDEX_WAIT_TIMEOUTwhen shards are temporarily unavailable.voidwhenProjectStateAvailable(ProjectId targetProject, Consumer<SecurityIndexManager.IndexState> stateConsumer)
-
Field Details
-
SECURITY_VERSION_STRING
- See Also:
-
FILE_SETTINGS_METADATA_NAMESPACE
- See Also:
-
-
Method Details
-
buildSecurityIndexManager
public static SecurityIndexManager buildSecurityIndexManager(Client client, ClusterService clusterService, FeatureService featureService, ProjectResolver projectResolver, SystemIndexDescriptor descriptor) -
forCurrentProject
Retrieves the project scoped index state for thecurrent project.- See Also:
-
getProject
Retrieves the project scoped index state. This is a point-in-time copy of the current state of the index in that project. Its internal representation will not change even if the index's underlying state changes in the cluster metadata. -
tryAwaitIndexAvailableForSearch
public void tryAwaitIndexAvailableForSearch(ActionListener<SecurityIndexManager.IndexState> listener) Resolves a freshSecurityIndexManager.IndexStatefor the current project once the security index is available for search, waiting up toSECURITY_INDEX_WAIT_TIMEOUTwhen shards are temporarily unavailable.Behavior:
- If the index is already available for search, completes immediately with the current snapshot.
- If the index is unavailable for a non-shards reason (e.g. closed, version mismatch, not found), completes immediately with that failure.
- If shards are unavailable and the wait timeout is zero, completes immediately with the
UnavailableShardsException. - Otherwise waits via
SecurityIndexManager.IndexState.onIndexAvailableForSearch(org.elasticsearch.action.ActionListener<java.lang.Void>, org.elasticsearch.core.TimeValue)and, after the wait fires (success or timeout), performs a single fresh re-check: completes successfully with the fresh snapshot if shards are now available, or with the freshSecurityIndexManager.IndexState.getUnavailableReason(Availability)otherwise. A timeout from the wait itself is never propagated to the listener.
-
aliasName
-
addStateListener
public void addStateListener(TriConsumer<ProjectId, SecurityIndexManager.IndexState, SecurityIndexManager.IndexState> listener) Add a listener for notifications on state changes to the configured index. The previous and current state are provided. -
removeStateListener
public void removeStateListener(TriConsumer<ProjectId, SecurityIndexManager.IndexState, SecurityIndexManager.IndexState> listener) Remove a listener from notifications on state changes to the configured index. -
clusterChanged
- Specified by:
clusterChangedin interfaceClusterStateListener
-
getMigrationVersionFromIndexMetadata
-
whenProjectStateAvailable
public void whenProjectStateAvailable(ProjectId targetProject, Consumer<SecurityIndexManager.IndexState> stateConsumer) -
resolveConcreteIndex
Resolves a concrete index name or alias to aIndexMetadatainstance. Requires that if supplied with an alias, the alias resolves to at most one concrete index. -
isMoveFromRedToNonRed
public static boolean isMoveFromRedToNonRed(SecurityIndexManager.IndexState previousState, SecurityIndexManager.IndexState currentState) Return true if the state moves from an unhealthy ("RED") index state to a healthy ("non-RED") state. -
isIndexDeleted
public static boolean isIndexDeleted(SecurityIndexManager.IndexState previousState, SecurityIndexManager.IndexState currentState) Return true if the state moves from the index existing to the index not existing.
-