Package org.opensearch.cluster.metadata
Class Metadata
java.lang.Object
org.opensearch.cluster.metadata.Metadata
- All Implemented Interfaces:
java.lang.Iterable<IndexMetadata>
,Diffable<Metadata>
,Writeable
,org.opensearch.common.xcontent.ToXContent
,org.opensearch.common.xcontent.ToXContentFragment
public class Metadata extends java.lang.Object implements java.lang.Iterable<IndexMetadata>, Diffable<Metadata>, org.opensearch.common.xcontent.ToXContentFragment
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Metadata.Builder
static interface
Metadata.Custom
static class
Metadata.XContentContext
Nested classes/interfaces inherited from interface org.opensearch.common.xcontent.ToXContent
org.opensearch.common.xcontent.ToXContent.DelegatingMapParams, org.opensearch.common.xcontent.ToXContent.MapParams, org.opensearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.opensearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALL
static java.util.EnumSet<Metadata.XContentContext>
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 restartsstatic java.util.EnumSet<Metadata.XContentContext>
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 statestatic java.util.EnumSet<Metadata.XContentContext>
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 restartsstatic java.util.EnumSet<Metadata.XContentContext>
API_ONLY
Indicates that this custom metadata will be returned as part of an API call but will not be persistedstatic ClusterBlock
CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
static ClusterBlock
CLUSTER_READ_ONLY_BLOCK
static java.lang.String
CONTEXT_MODE_API
static java.lang.String
CONTEXT_MODE_GATEWAY
static java.lang.String
CONTEXT_MODE_PARAM
static java.lang.String
CONTEXT_MODE_SNAPSHOT
static Metadata
EMPTY_METADATA
static MetadataStateFormat<Metadata>
FORMAT
State format forMetadata
to write to and load from diskstatic java.lang.String
GLOBAL_STATE_FILE_PREFIX
static java.util.regex.Pattern
NUMBER_PATTERN
static Setting<java.lang.Boolean>
SETTING_READ_ONLY_ALLOW_DELETE_SETTING
static Setting<java.lang.Boolean>
SETTING_READ_ONLY_SETTING
static java.lang.String
UNKNOWN_CLUSTER_UUID
-
Method Summary
Modifier and Type Method Description static Metadata.Builder
builder()
static Metadata.Builder
builder(Metadata metadata)
java.lang.String
clusterUUID()
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.java.util.Map<java.lang.String,ComponentTemplate>
componentTemplates()
CoordinationMetadata
coordinationMetadata()
<T extends Metadata.Custom>
Tcustom(java.lang.String type)
ImmutableOpenMap<java.lang.String,Metadata.Custom>
customs()
java.util.Map<java.lang.String,DataStream>
dataStreams()
Diff<Metadata>
diff(Metadata previousState)
Returns serializable object representing differences between this and previousStateboolean
equalsAliases(Metadata other)
ImmutableOpenMap<java.lang.String,java.util.List<AliasMetadata>>
findAliases(AliasesRequest aliasesRequest, java.lang.String[] concreteIndices)
Finds the specific index aliases that match with the specified aliases directly or partially via wildcards, and that point to the specified concrete indices (directly or matching indices via wildcards).ImmutableOpenMap<java.lang.String,java.util.List<AliasMetadata>>
findAllAliases(java.lang.String[] concreteIndices)
Finds the specific index aliases that point to the requested concrete indices directly or that match with the indices via wildcards.ImmutableOpenMap<java.lang.String,IndexAbstraction.DataStream>
findDataStreams(java.lang.String[] concreteIndices)
Finds the parent data streams, if any, for the specified concrete indices.ImmutableOpenMap<java.lang.String,ImmutableOpenMap<java.lang.String,MappingMetadata>>
findMappings(java.lang.String[] concreteIndices, java.lang.String[] types, java.util.function.Function<java.lang.String,java.util.function.Predicate<java.lang.String>> fieldFilter)
Finds all mappings for types and concrete indices.static Metadata
fromXContent(org.opensearch.common.xcontent.XContentParser parser)
java.lang.String[]
getConcreteAllClosedIndices()
Returns all of the concrete indices that are closed.java.lang.String[]
getConcreteAllIndices()
Returns all the concrete indices.java.lang.String[]
getConcreteAllOpenIndices()
Returns all of the concrete indices that are open.java.lang.String[]
getConcreteVisibleClosedIndices()
Returns all of the concrete indices that are closed and not hidden.java.lang.String[]
getConcreteVisibleIndices()
Returns all the concrete indices that are not hidden.java.lang.String[]
getConcreteVisibleOpenIndices()
Returns all of the concrete indices that are open and not hidden.ImmutableOpenMap<java.lang.String,Metadata.Custom>
getCustoms()
IndexMetadata
getIndexSafe(Index index)
Returns theIndexMetadata
for this index.ImmutableOpenMap<java.lang.String,IndexMetadata>
getIndices()
java.util.SortedMap<java.lang.String,IndexAbstraction>
getIndicesLookup()
ImmutableOpenMap<java.lang.String,IndexTemplateMetadata>
getTemplates()
int
getTotalNumberOfShards()
Gets the total number of shards from all indices, including replicas and closed indices.int
getTotalOpenIndexShards()
Gets the total number of open shards from all indices.boolean
hasAlias(java.lang.String alias)
boolean
hasAliases(java.lang.String[] aliases, java.lang.String[] concreteIndices)
Checks if at least one of the specified aliases exists in the specified concrete indices.boolean
hasConcreteIndex(java.lang.String index)
java.util.Map<java.lang.String,java.lang.String>
hashesOfConsistentSettings()
boolean
hasIndex(java.lang.String index)
boolean
hasIndex(Index index)
boolean
hasIndexMetadata(IndexMetadata indexMetadata)
Returns true iff existing index has the sameIndexMetadata
instanceIndexMetadata
index(java.lang.String index)
IndexMetadata
index(Index index)
IndexGraveyard
indexGraveyard()
The collection of index deletions in the cluster.ImmutableOpenMap<java.lang.String,IndexMetadata>
indices()
static boolean
isAllTypes(java.lang.String[] types)
Identifies whether the array containing type names given as argument refers to all types The empty or null array identifies all typesstatic boolean
isExplicitAllType(java.lang.String[] types)
Identifies whether the array containing type names given as argument explicitly refers to all types The empty or null array doesn't explicitly map to all typesstatic boolean
isGlobalStateEquals(Metadata metadata1, Metadata metadata2)
java.util.Iterator<IndexMetadata>
iterator()
Settings
persistentSettings()
static Diff<Metadata>
readDiffFrom(StreamInput in)
static Metadata
readFrom(StreamInput in)
java.lang.String
resolveIndexRouting(java.lang.String routing, java.lang.String aliasOrIndex)
Returns indexing routing for the given index.java.lang.String
resolveWriteIndexRouting(java.lang.String routing, java.lang.String aliasOrIndex)
Returns indexing routing for the givenaliasOrIndex
.boolean
routingRequired(java.lang.String concreteIndex)
Settings
settings()
Returns the merged transient and persistent settings.ImmutableOpenMap<java.lang.String,IndexTemplateMetadata>
templates()
java.util.Map<java.lang.String,ComposableIndexTemplate>
templatesV2()
org.opensearch.common.xcontent.XContentBuilder
toXContent(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params)
Settings
transientSettings()
long
version()
void
writeTo(StreamOutput out)
Write this into the StreamOutput.
-
Field Details
-
ALL
public static final java.lang.String ALL- See Also:
- Constant Field Values
-
UNKNOWN_CLUSTER_UUID
public static final java.lang.String UNKNOWN_CLUSTER_UUID- See Also:
- Constant Field Values
-
NUMBER_PATTERN
public static final java.util.regex.Pattern NUMBER_PATTERN -
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
public static final java.lang.String CONTEXT_MODE_PARAM- See Also:
- Constant Field Values
-
CONTEXT_MODE_SNAPSHOT
public static final java.lang.String CONTEXT_MODE_SNAPSHOT -
CONTEXT_MODE_GATEWAY
public static final java.lang.String CONTEXT_MODE_GATEWAY -
CONTEXT_MODE_API
public static final java.lang.String CONTEXT_MODE_API -
GLOBAL_STATE_FILE_PREFIX
public static final java.lang.String GLOBAL_STATE_FILE_PREFIX- See Also:
- Constant Field Values
-
FORMAT
State format forMetadata
to write to and load from disk
-
-
Method Details
-
version
public long version() -
clusterUUID
public java.lang.String clusterUUID() -
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
public java.util.Map<java.lang.String,java.lang.String> hashesOfConsistentSettings() -
coordinationMetadata
-
hasAlias
public boolean hasAlias(java.lang.String alias) -
equalsAliases
-
getIndicesLookup
-
findAllAliases
public ImmutableOpenMap<java.lang.String,java.util.List<AliasMetadata>> findAllAliases(java.lang.String[] concreteIndices)Finds the specific index aliases that point to the requested concrete indices directly or that match with the indices via wildcards.- Parameters:
concreteIndices
- The concrete indices that the aliases must point to in order to be returned.- Returns:
- A map of index name to the list of aliases metadata. If a concrete index does not have matching aliases then the result will not include the index's key.
-
findAliases
public ImmutableOpenMap<java.lang.String,java.util.List<AliasMetadata>> findAliases(AliasesRequest aliasesRequest, java.lang.String[] concreteIndices)Finds the specific index aliases that match with the specified aliases directly or partially via wildcards, and that point to the specified concrete indices (directly or matching indices via wildcards).- Parameters:
aliasesRequest
- The request to find aliases forconcreteIndices
- The concrete indices that the aliases must point to in order to be returned.- Returns:
- A map of index name to the list of aliases metadata. If a concrete index does not have matching aliases then the result will not include the index's key.
-
hasAliases
public boolean hasAliases(java.lang.String[] aliases, java.lang.String[] concreteIndices)Checks if at least one of the specified aliases exists in the specified concrete indices. Wildcards are supported in the alias names for partial matches.- Parameters:
aliases
- The names of the index aliases to findconcreteIndices
- The concrete indexes the index aliases must point to order to be returned.- Returns:
- whether at least one of the specified aliases exists in one of the specified concrete indices.
-
findMappings
public ImmutableOpenMap<java.lang.String,ImmutableOpenMap<java.lang.String,MappingMetadata>> findMappings(java.lang.String[] concreteIndices, java.lang.String[] types, java.util.function.Function<java.lang.String,java.util.function.Predicate<java.lang.String>> fieldFilter) throws java.io.IOExceptionFinds all mappings for types and concrete indices. Types are expanded to include all types that match the glob patterns in the types array. Empty types array, null or {"_all"} will be expanded to all types available for the given indices. Only fields that match the provided field filter will be returned (default is a predicate that always returns true, which can be overridden via plugins)- Throws:
java.io.IOException
- See Also:
MapperPlugin.getFieldFilter()
-
findDataStreams
public ImmutableOpenMap<java.lang.String,IndexAbstraction.DataStream> findDataStreams(java.lang.String[] concreteIndices)Finds the parent data streams, if any, for the specified concrete indices. -
getConcreteAllIndices
public java.lang.String[] getConcreteAllIndices()Returns all the concrete indices. -
getConcreteVisibleIndices
public java.lang.String[] getConcreteVisibleIndices()Returns all the concrete indices that are not hidden. -
getConcreteAllOpenIndices
public java.lang.String[] getConcreteAllOpenIndices()Returns all of the concrete indices that are open. -
getConcreteVisibleOpenIndices
public java.lang.String[] getConcreteVisibleOpenIndices()Returns all of the concrete indices that are open and not hidden. -
getConcreteAllClosedIndices
public java.lang.String[] getConcreteAllClosedIndices()Returns all of the concrete indices that are closed. -
getConcreteVisibleClosedIndices
public java.lang.String[] getConcreteVisibleClosedIndices()Returns all of the concrete indices that are closed and not hidden. -
resolveWriteIndexRouting
public java.lang.String resolveWriteIndexRouting(@Nullable java.lang.String routing, java.lang.String aliasOrIndex)Returns indexing routing for the givenaliasOrIndex
. Resolves routing from the alias metadata used in the write index. -
resolveIndexRouting
public java.lang.String resolveIndexRouting(@Nullable java.lang.String routing, java.lang.String aliasOrIndex)Returns indexing routing for the given index. -
hasIndex
public boolean hasIndex(java.lang.String index) -
hasIndex
-
hasConcreteIndex
public boolean hasConcreteIndex(java.lang.String index) -
index
-
index
-
hasIndexMetadata
Returns true iff existing index has the sameIndexMetadata
instance -
getIndexSafe
Returns theIndexMetadata
for this index.- Throws:
IndexNotFoundException
- if no metadata for this index is found
-
indices
-
getIndices
-
templates
-
getTemplates
-
componentTemplates
-
templatesV2
-
dataStreams
-
customs
-
getCustoms
-
indexGraveyard
The collection of index deletions in the cluster. -
custom
-
getTotalNumberOfShards
public int getTotalNumberOfShards()Gets the total number of shards from all indices, including replicas and closed indices.- Returns:
- The total number shards from all indices.
-
getTotalOpenIndexShards
public int getTotalOpenIndexShards()Gets the total number of open shards from all indices. Includes replicas, but does not include shards that are part of closed indices.- Returns:
- The total number of open shards from all indices.
-
isAllTypes
public static boolean isAllTypes(java.lang.String[] types)Identifies whether the array containing type names given as argument refers to all types The empty or null array identifies all types- Parameters:
types
- the array containing types- Returns:
- true if the provided array maps to all types, false otherwise
-
isExplicitAllType
public static boolean isExplicitAllType(java.lang.String[] types)Identifies whether the array containing type names given as argument explicitly refers to all types The empty or null array doesn't explicitly map to all types- Parameters:
types
- the array containing index names- Returns:
- true if the provided array explicitly maps to all types, false otherwise
-
routingRequired
public boolean routingRequired(java.lang.String concreteIndex)- Parameters:
concreteIndex
- The concrete index to check if routing is required- Returns:
- Whether routing is required according to the mapping for the specified index and type
-
iterator
- Specified by:
iterator
in interfacejava.lang.Iterable<IndexMetadata>
-
isGlobalStateEquals
-
diff
Description copied from interface:Diffable
Returns serializable object representing differences between this and previousState -
readDiffFrom
- Throws:
java.io.IOException
-
fromXContent
public static Metadata fromXContent(org.opensearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
toXContent
public org.opensearch.common.xcontent.XContentBuilder toXContent(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContent
in interfaceorg.opensearch.common.xcontent.ToXContent
- Throws:
java.io.IOException
-
readFrom
- Throws:
java.io.IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput. -
builder
-
builder
-