Class SecurityIndexManager
java.lang.Object
org.elasticsearch.xpack.security.support.SecurityIndexManager
- All Implemented Interfaces:
org.elasticsearch.cluster.ClusterStateListener
public class SecurityIndexManager
extends Object
implements org.elasticsearch.cluster.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 classState of the security index. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener for notifications on state changes to the configured index.static SecurityIndexManagerbuildSecurityIndexManager(org.elasticsearch.client.internal.Client client, org.elasticsearch.cluster.service.ClusterService clusterService, org.elasticsearch.indices.SystemIndexDescriptor descriptor) static booleancheckIndexMappingVersionMatches(String indexName, org.elasticsearch.cluster.ClusterState clusterState, org.apache.logging.log4j.Logger logger, Predicate<org.elasticsearch.Version> predicate) voidcheckIndexVersionThenExecute(Consumer<Exception> consumer, Runnable andThen) Validates that the index is up to date and does not need to be migrated.voidclusterChanged(org.elasticsearch.cluster.ClusterChangedEvent event) freeze()org.elasticsearch.ElasticsearchExceptionbooleanbooleanstatic booleanisIndexDeleted(SecurityIndexManager.State previousState, SecurityIndexManager.State currentState) Return true if the state moves from the index existing to the index not existing.booleanReturns whether the index is on the current format if it exists.booleanstatic booleanisMoveFromRedToNonRed(SecurityIndexManager.State previousState, SecurityIndexManager.State currentState) Return true if the state moves from an unhealthy ("RED") index state to a healthy ("non-RED") state.booleanvoidonStateRecovered(Consumer<SecurityIndexManager.State> recoveredStateConsumer) voidprepareIndexIfNeededThenExecute(Consumer<Exception> consumer, Runnable andThen) Prepares the index by creating it if it doesn't exist, then executes the runnable.voidRemove a listener from notifications on state changes to the configured index.
-
Field Details
-
SECURITY_VERSION_STRING
- See Also:
-
-
Method Details
-
buildSecurityIndexManager
public static SecurityIndexManager buildSecurityIndexManager(org.elasticsearch.client.internal.Client client, org.elasticsearch.cluster.service.ClusterService clusterService, org.elasticsearch.indices.SystemIndexDescriptor descriptor) -
freeze
-
aliasName
-
indexExists
public boolean indexExists() -
getCreationTime
-
isIndexUpToDate
public boolean isIndexUpToDate()Returns whether the index is on the current format if it exists. If the index does not exist we treat the index as up to date as we expect it to be created with the current format. -
isAvailable
public boolean isAvailable() -
isMappingUpToDate
public boolean isMappingUpToDate() -
isStateRecovered
public boolean isStateRecovered() -
addStateListener
public void addStateListener(BiConsumer<SecurityIndexManager.State, SecurityIndexManager.State> listener) Add a listener for notifications on state changes to the configured index. The previous and current state are provided. -
removeStateListener
public void removeStateListener(BiConsumer<SecurityIndexManager.State, SecurityIndexManager.State> listener) Remove a listener from notifications on state changes to the configured index. -
clusterChanged
public void clusterChanged(org.elasticsearch.cluster.ClusterChangedEvent event) - Specified by:
clusterChangedin interfaceorg.elasticsearch.cluster.ClusterStateListener
-
onStateRecovered
-
checkIndexMappingVersionMatches
-
checkIndexVersionThenExecute
Validates that the index is up to date and does not need to be migrated. If it is not, the consumer is called with an exception. If the index is up to date, the runnable will be executed. NOTE: this method does not check the availability of the index; this check is left to the caller so that this condition can be handled appropriately. -
prepareIndexIfNeededThenExecute
Prepares the index by creating it if it doesn't exist, then executes the runnable.- Parameters:
consumer- a handler for any exceptions that are raised either during preparation or executionandThen- executed if the index exists or after preparation is performed successfully
-
isMoveFromRedToNonRed
public static boolean isMoveFromRedToNonRed(SecurityIndexManager.State previousState, SecurityIndexManager.State 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.State previousState, SecurityIndexManager.State currentState) Return true if the state moves from the index existing to the index not existing.
-