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) | "page" | "last_page" |
+------------------------------+-----------------------------+----------------------------------------------+--------+-------------+
| GLOBAL_TYPE_NAME == "global" | (omitted) | Global metadata | large docs are |
| INDEX_TYPE_NAME == "index" | Index UUID | Index metadata | split into pages |
+------------------------------+-----------------------------+----------------------------------------------+--------+-------------+
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
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPersistedClusterStateService
(Path[] dataPaths, String nodeId, org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry, ClusterSettings clusterSettings, LongSupplier relativeTimeMillisSupplier) PersistedClusterStateService
(NodeEnvironment nodeEnvironment, org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry, 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
-
TYPE_FIELD_NAME
- See Also:
-
GLOBAL_TYPE_NAME
- See Also:
-
INDEX_TYPE_NAME
- See Also:
-
PAGE_FIELD_NAME
- See Also:
-
LAST_PAGE_FIELD_NAME
- See Also:
-
IS_LAST_PAGE
public static final int IS_LAST_PAGE- See Also:
-
IS_NOT_LAST_PAGE
public static final int IS_NOT_LAST_PAGE- See Also:
-
METADATA_DIRECTORY_NAME
- See Also:
-
SLOW_WRITE_LOGGING_THRESHOLD
-
DOCUMENT_PAGE_SIZE
-
-
Constructor Details
-
PersistedClusterStateService
public PersistedClusterStateService(NodeEnvironment nodeEnvironment, org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry, ClusterSettings clusterSettings, LongSupplier relativeTimeMillisSupplier) -
PersistedClusterStateService
public PersistedClusterStateService(Path[] dataPaths, String nodeId, org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry, 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
-