java.lang.Object
org.elasticsearch.cluster.metadata.Metadata
- All Implemented Interfaces:
Diffable<Metadata>,Writeable,ChunkedToXContent
Metadata is the part of the ClusterState which persists across restarts. This persistence is XContent-based, so a
round-trip through XContent must be faithful in Metadata.XContentContext.GATEWAY context.
The details of how this is persisted are covered in PersistedClusterStateService.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceCluster-level custom metadata that persists (via XContent) across restarts.static interfacestatic classTemporary exception indicating a call togetSingleProject()when there are multiple projects.static interfaceProject-level custom metadata that persists (via XContent) across restarts.static enumNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final EnumSet<Metadata.XContentContext> Indicates that this custom metadata will be returned as part of an API call, stored as a part of a snapshot global state, and will be persisted between node restartsstatic final EnumSet<Metadata.XContentContext> Indicates that this custom metadata will be returned as part of an API call and will be persisted between node restarts, but will not be a part of a snapshot global statestatic final EnumSet<Metadata.XContentContext> Indicates that this custom metadata will be returned as part of an API call and stored as a part of a snapshot global state, but will not be persisted between node restartsstatic final EnumSet<Metadata.XContentContext> Indicates that this custom metadata will be returned as part of an API call but will not be persistedstatic final ClusterBlockstatic final ClusterBlockstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final ProjectIdstatic final Metadatastatic final Stringstatic final Runnablestatic final StringFields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTY -
Method Summary
Modifier and TypeMethodDescriptionstatic Metadata.Builderbuilder()static Metadata.BuilderbooleanWhether the current node with the given cluster state is locked into the cluster with the UUID returned byclusterUUID(), meaning that it will not accept any cluster state with a different clusterUUID.copyAndUpdate(Consumer<Metadata.Builder> updater) copyAndUpdateProject(ProjectId projectId, Consumer<ProjectMetadata.Builder> updater) <T extends Metadata.ClusterCustom>
T<T extends Metadata.ClusterCustom>
Tcustoms()Returns serializable object representing differences between this and previousStateThis method is similar toindexMetadata(org.elasticsearch.index.Index).static MetadatafromXContent(XContentParser parser) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.getProject(ProjectId projectId) <T extends Metadata.ProjectCustom>
TgetSingleProjectCustom(String type) Utility method that allows retrieving aMetadata.ProjectCustomfrom a project.Utility method that allows retrieving a project that has a certainMetadata.ProjectCustom.intintintGets the total number of open shards of all indices across all projects.booleanbooleanhasProject(ProjectId projectId) indexMetadata(Index index) Attempt to find the IndexMetadata for the suppliedIndex.static booleanisGlobalStateEquals(Metadata metadata1, Metadata metadata2) lookupProject(Index index) Attempt to find a project for the suppliedIndex.projectFor(Index index) Attempt to find a project for the suppliedIndex.projects()static MetadatareadFrom(StreamInput in) Returns the fullReservedStateMetadataMap for all reserved state namespaces.settings()Returns the merged transient and persistent settings.Iterator<? extends ToXContent> Create an iterator ofToXContentchunks for a REST response.longversion()withAddedIndex(IndexMetadata index) Creates a copy of this instance with the givenindexadded.withCoordinationMetadata(CoordinationMetadata coordinationMetadata) withLastCommittedValues(boolean clusterUUIDCommitted, CoordinationMetadata.VotingConfiguration lastCommittedConfiguration) withLifecycleState(Index index, LifecycleExecutionState lifecycleState) Given an index and lifecycle state, returns a metadata where the lifecycle state will be associated with the given index.withUpdatedProject(ProjectMetadata updatedProject) Updates a single project in the metadata.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
isFragment, toXContentChunked, toXContentChunkedV8
-
Field Details
-
ON_NEXT_INDEX_FIND_MAPPINGS_NOOP
-
ALL
- See Also:
-
UNKNOWN_CLUSTER_UUID
- See Also:
-
DEFAULT_PROJECT_ID
-
API_ONLY
Indicates that this custom metadata will be returned as part of an API call but will not be persisted -
API_AND_GATEWAY
Indicates that this custom metadata will be returned as part of an API call and will be persisted between node restarts, but will not be a part of a snapshot global state -
API_AND_SNAPSHOT
Indicates that this custom metadata will be returned as part of an API call and stored as a part of a snapshot global state, but will not be persisted between node restarts -
ALL_CONTEXTS
Indicates that this custom metadata will be returned as part of an API call, stored as a part of a snapshot global state, and will be persisted between node restarts -
SETTING_READ_ONLY_SETTING
-
CLUSTER_READ_ONLY_BLOCK
-
SETTING_READ_ONLY_ALLOW_DELETE_SETTING
-
CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
-
EMPTY_METADATA
-
CONTEXT_MODE_PARAM
- See Also:
-
CONTEXT_MODE_SNAPSHOT
-
CONTEXT_MODE_GATEWAY
-
CONTEXT_MODE_API
-
DEDUPLICATED_MAPPINGS_PARAM
- See Also:
-
GLOBAL_STATE_FILE_PREFIX
- See Also:
-
-
Method Details
-
withIncrementedVersion
-
withLifecycleState
Given an index and lifecycle state, returns a metadata where the lifecycle state will be associated with the given index. The passed-in index must already be present in the cluster state, this method cannot be used to add an index.- Parameters:
index- A non-null indexlifecycleState- A non-null lifecycle execution state- Returns:
- a
Metadatainstance where the index has the provided lifecycle state
-
withCoordinationMetadata
-
withLastCommittedValues
public Metadata withLastCommittedValues(boolean clusterUUIDCommitted, CoordinationMetadata.VotingConfiguration lastCommittedConfiguration) -
withAddedIndex
Creates a copy of this instance with the givenindexadded.- Parameters:
index- index to add- Returns:
- copy with added index
-
withUpdatedProject
Updates a single project in the metadata. This offers a more performant way of updating a single project compared to the Builder. -
version
public long version() -
clusterUUID
- Returns:
- A UUID which identifies this cluster. Nodes record the UUID of the cluster they first join on disk, and will then refuse to
join clusters with different UUIDs. Note that when the cluster is forming for the first time this value may not yet be committed,
and therefore it may change. Check
clusterUUIDCommitted()to verify that the value is committed if needed.
-
clusterUUIDCommitted
public boolean clusterUUIDCommitted()Whether the current node with the given cluster state is locked into the cluster with the UUID returned byclusterUUID(), meaning that it will not accept any cluster state with a different clusterUUID. -
settings
Returns the merged transient and persistent settings. -
transientSettings
-
persistentSettings
-
hashesOfConsistentSettings
-
coordinationMetadata
-
projects
-
indicesAllProjects
-
getProject
Deprecated, for removal: This API element is subject to removal in a future version.TODO: Remove as part of multi-project -
getDefaultProject
Deprecated, for removal: This API element is subject to removal in a future version. -
hasProject
-
getProject
-
getTotalOpenIndexShards
public int getTotalOpenIndexShards()Gets the total number of open shards of all indices across all projects. Includes replicas, but does not include shards that are part of closed indices. -
getSingleProjectCustom
Utility method that allows retrieving aMetadata.ProjectCustomfrom a project. Throws an exception when multiple projects have thatMetadata.ProjectCustom.- Returns:
- the
Metadata.ProjectCustomif and only if it's present in a single project. If it's not present in any project, returns null
-
getSingleProjectWithCustom
Utility method that allows retrieving a project that has a certainMetadata.ProjectCustom. Throws an exception when multiple projects have thatMetadata.ProjectCustom.- Returns:
- the project that has the
Metadata.ProjectCustomif and only if it's present in a single project. If it's not present in any project, returns null
-
getTotalNumberOfShards
public int getTotalNumberOfShards()- Returns:
- The total number of shards across all projects in this cluster
-
getTotalNumberOfIndices
public int getTotalNumberOfIndices()- Returns:
- The total number of indices across all projects in this cluster
-
hasAnyIndices
public boolean hasAnyIndices()- Returns:
- {code true} if there are any indices in any project in this cluster
-
oldestIndexVersionAllProjects
- Returns:
- The oldest
IndexVersionof indices across all projects
-
nodeShutdowns
-
customs
-
reservedStateMetadata
Returns the fullReservedStateMetadataMap for all reserved state namespaces.- Returns:
- a map of namespace to
ReservedStateMetadata
-
custom
-
custom
-
isGlobalStateEquals
-
diff
Description copied from interface:DiffableReturns serializable object representing differences between this and previousState -
readDiffFrom
- Throws:
IOException
-
fromXContent
- Throws:
IOException
-
toXContentChunked
Description copied from interface:ChunkedToXContentCreate an iterator ofToXContentchunks for a REST response. Each chunk is serialized with the sameXContentBuilderandToXContent.Params, which is also the same as theToXContent.Paramspassed as theparamsargument. For best results, all chunks should beO(1)size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelperfor some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Specified by:
toXContentChunkedin interfaceChunkedToXContent- Returns:
- iterator over chunks of
ToXContent
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
builder
-
builder
-
copyAndUpdate
-
copyAndUpdateProject
public Metadata copyAndUpdateProject(ProjectId projectId, Consumer<ProjectMetadata.Builder> updater) -
lookupProject
Attempt to find a project for the suppliedIndex. -
projectFor
Attempt to find a project for the suppliedIndex.- Throws:
IndexNotFoundException- if the index does not exist in any project
-
indexMetadata
Attempt to find the IndexMetadata for the suppliedIndex.- Throws:
IndexNotFoundException- if the index does not exist in any project
-
findIndex
This method is similar toindexMetadata(org.elasticsearch.index.Index). But it returns anOptionalinstead of throwing when either the project or the index is not found.
-