Package org.elasticsearch.gateway
Class PersistedClusterStateService
java.lang.Object
org.elasticsearch.gateway.PersistedClusterStateService
Stores cluster metadata in a bare Lucene index (per data path) split across a number of documents. This is used by master-eligible nodes
to record the last-accepted cluster state during publication. The metadata is written incrementally where possible, leaving alone any
documents that have not changed. The index has the following fields:
+------------------------------+-----------------------------+----------------------------------------------+
| "type" (string field) | "index_uuid" (string field) | "data" (stored binary field in SMILE format) |
+------------------------------+-----------------------------+----------------------------------------------+
| GLOBAL_TYPE_NAME == "global" | (omitted) | Global metadata |
| INDEX_TYPE_NAME == "index" | Index UUID | Index metadata |
+------------------------------+-----------------------------+----------------------------------------------+
Additionally each commit has the following user data:
+---------------------------+-------------------------+-------------------------------------------------------------------------------+
| Key symbol | Key literal | Value |
+---------------------------+-------------------------+-------------------------------------------------------------------------------+
| CURRENT_TERM_KEY | "current_term" | Node's "current" term (≥ last-accepted term and the terms of all sent joins) |
| LAST_ACCEPTED_VERSION_KEY | "last_accepted_version" | The cluster state version corresponding with the persisted metadata |
| NODE_ID_KEY | "node_id" | The (persistent) ID of the node that wrote this metadata |
| NODE_VERSION_KEY | "node_version" | The (ID of the) version of the node that wrote this metadata |
+---------------------------+-------------------------+-------------------------------------------------------------------------------+
(the last-accepted term is recorded in Metadata → CoordinationMetadata so does not need repeating here)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPersistedClusterStateService(Path[] dataPaths, String nodeId, org.elasticsearch.common.xcontent.NamedXContentRegistry namedXContentRegistry, BigArrays bigArrays, ClusterSettings clusterSettings, LongSupplier relativeTimeMillisSupplier)
PersistedClusterStateService(NodeEnvironment nodeEnvironment, org.elasticsearch.common.xcontent.NamedXContentRegistry namedXContentRegistry, BigArrays bigArrays, ClusterSettings clusterSettings, LongSupplier relativeTimeMillisSupplier)
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new disk-based writer for cluster statesstatic void
Remove all persisted cluster states from the given data paths, for use in tests.Path[]
Loads the best available on-disk cluster state.static NodeMetadata
nodeMetadata(Path... dataPaths)
Returns the node metadata for the given data paths, and checks if the node ids are uniquestatic void
overrideVersion(Version newVersion, Path... dataPaths)
Overrides the version field for the metadata in the given data path
-
Field Details
-
METADATA_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
SLOW_WRITE_LOGGING_THRESHOLD
-
-
Constructor Details
-
PersistedClusterStateService
public PersistedClusterStateService(NodeEnvironment nodeEnvironment, org.elasticsearch.common.xcontent.NamedXContentRegistry namedXContentRegistry, BigArrays bigArrays, ClusterSettings clusterSettings, LongSupplier relativeTimeMillisSupplier) -
PersistedClusterStateService
public PersistedClusterStateService(Path[] dataPaths, String nodeId, org.elasticsearch.common.xcontent.NamedXContentRegistry namedXContentRegistry, BigArrays bigArrays, ClusterSettings clusterSettings, LongSupplier relativeTimeMillisSupplier)
-
-
Method Details
-
getNodeId
-
createWriter
Creates a new disk-based writer for cluster states- Throws:
IOException
-
deleteAll
Remove all persisted cluster states from the given data paths, for use in tests. Should only be called when there is no openPersistedClusterStateService.Writer
on these paths.- Throws:
IOException
-
getDataPaths
-
nodeMetadata
Returns the node metadata for the given data paths, and checks if the node ids are unique- Parameters:
dataPaths
- the data paths to scan- Throws:
IOException
-
overrideVersion
Overrides the version field for the metadata in the given data path- Throws:
IOException
-
loadBestOnDiskState
Loads the best available on-disk cluster state. ReturnsPersistedClusterStateService.OnDiskState.NO_ON_DISK_STATE
if no such state was found.- Throws:
IOException
-