Class FileSettingsService
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClusterStateListener
,LifecycleComponent
,Releasable
The service expects that the operator directory will contain a single JSON file with all the settings that need to be applied to the cluster state. The name of the file is fixed to be settings.json. The operator directory name can be configured by setting the 'path.config.operator_directory' in the node properties.
The FileSettingsService
is active always, but enabled only on the current master node. We register
the service as a listener to cluster state changes, so that we can enable the file watcher thread when this
node becomes a master node.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Error subclass that is thrown when we encounter a fatal error while applying the operator cluster state at Elasticsearch boot time. -
Field Summary
FieldsFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorsConstructorDescriptionFileSettingsService
(ClusterService clusterService, ReservedClusterStateService stateService, Environment environment) Constructs theFileSettingsService
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when cluster state changes.protected void
doClose()
protected void
doStart()
protected void
doStop()
void
handleSnapshotRestore
(ClusterState clusterState, Metadata.Builder mdBuilder) Used by snapshot restore serviceRestoreService
to prepare the reserved state of the snapshot for the current cluster.Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
SETTINGS_FILE_NAME
- See Also:
-
NAMESPACE
- See Also:
-
OPERATOR_DIRECTORY
- See Also:
-
-
Constructor Details
-
FileSettingsService
public FileSettingsService(ClusterService clusterService, ReservedClusterStateService stateService, Environment environment) Constructs theFileSettingsService
- Parameters:
clusterService
- so we can register ourselves as a cluster state change listenerstateService
- an instance of the immutable cluster state controller, so we can perform the cluster state changesenvironment
- we need the environment to pull the location of the config and operator directories
-
-
Method Details
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClose
in classAbstractLifecycleComponent
-
clusterChanged
Description copied from interface:ClusterStateListener
Called when cluster state changes.Cluster states are applied one-by-one which means they can be a performance bottleneck. Implementations of this method should therefore be fast, so please consider forking work into the background rather than doing everything inline.
- Specified by:
clusterChanged
in interfaceClusterStateListener
-
handleSnapshotRestore
Used by snapshot restore serviceRestoreService
to prepare the reserved state of the snapshot for the current cluster.If the current cluster where we are restoring the snapshot into has any operator file based settings, we'll reset the reserved state version to 0.
If there's no file based settings file in this cluster, we'll remove all state reservations for file based settings from the cluster state.
- Parameters:
clusterState
- the cluster state before snapshot restoremdBuilder
- the current metadata builder for the new cluster state
-