Class MetaData
- java.lang.Object
-
- org.elasticsearch.cluster.metadata.MetaData
-
- All Implemented Interfaces:
java.lang.Iterable<IndexMetaData>
,Diffable<MetaData>
,Writeable
,ToXContent
,ToXContentFragment
public class MetaData extends java.lang.Object implements java.lang.Iterable<IndexMetaData>, Diffable<MetaData>, 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.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.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_GATEWAY
static java.lang.String
CONTEXT_MODE_PARAM
static java.lang.String
CONTEXT_MODE_SNAPSHOT
static MetaData
EMPTY_META_DATA
static MetaDataStateFormat<MetaData>
FORMAT
State format forMetaData
to write to and load from diskstatic java.lang.String
GLOBAL_STATE_FILE_PREFIX
static Setting<java.lang.Integer>
SETTING_CLUSTER_MAX_SHARDS_PER_NODE
static Setting<java.lang.Boolean>
SETTING_READ_ONLY_ALLOW_DELETE_SETTING
static Setting<java.lang.Boolean>
SETTING_READ_ONLY_SETTING
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Method Summary
Modifier and Type Method Description static MetaData.Builder
builder()
static MetaData.Builder
builder(MetaData metaData)
java.lang.String
clusterUUID()
<T extends MetaData.Custom>
Tcustom(java.lang.String type)
ImmutableOpenMap<java.lang.String,MetaData.Custom>
customs()
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(java.lang.String[] aliases, 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 or match partially with the indices via wildcards.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(XContentParser parser)
java.util.SortedMap<java.lang.String,AliasOrIndex>
getAliasAndIndexLookup()
java.lang.String[]
getConcreteAllClosedIndices()
java.lang.String[]
getConcreteAllIndices()
Returns all the concrete indices.java.lang.String[]
getConcreteAllOpenIndices()
ImmutableOpenMap<java.lang.String,MetaData.Custom>
getCustoms()
IndexMetaData
getIndexSafe(Index index)
Returns theIndexMetaData
for this index.ImmutableOpenMap<java.lang.String,IndexMetaData>
getIndices()
int
getNumberOfShards()
Gets the number of primary shards from all indices, not including replicas.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)
boolean
hasIndex(java.lang.String 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 parent, java.lang.String routing, java.lang.String aliasOrIndex)
Returns indexing routing for the given index.java.lang.String
resolveWriteIndexRouting(java.lang.String parent, java.lang.String routing, java.lang.String aliasOrIndex)
Returns indexing routing for the givenaliasOrIndex
.boolean
routingRequired(java.lang.String concreteIndex, java.lang.String type)
Settings
settings()
Returns the merged transient and persistent settings.ImmutableOpenMap<java.lang.String,IndexTemplateMetaData>
templates()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
Settings
transientSettings()
long
version()
void
writeTo(StreamOutput out)
Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
ALL
public static final java.lang.String ALL
- See Also:
- Constant Field Values
-
API_ONLY
public static 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 persisted
-
API_AND_GATEWAY
public static 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 state
-
API_AND_SNAPSHOT
public static 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 restarts
-
ALL_CONTEXTS
public 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 restarts
-
SETTING_CLUSTER_MAX_SHARDS_PER_NODE
public static final Setting<java.lang.Integer> SETTING_CLUSTER_MAX_SHARDS_PER_NODE
-
SETTING_READ_ONLY_SETTING
public static final Setting<java.lang.Boolean> SETTING_READ_ONLY_SETTING
-
CLUSTER_READ_ONLY_BLOCK
public static final ClusterBlock CLUSTER_READ_ONLY_BLOCK
-
SETTING_READ_ONLY_ALLOW_DELETE_SETTING
public static final Setting<java.lang.Boolean> SETTING_READ_ONLY_ALLOW_DELETE_SETTING
-
CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
public static final ClusterBlock CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
-
EMPTY_META_DATA
public static final MetaData EMPTY_META_DATA
-
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
-
GLOBAL_STATE_FILE_PREFIX
public static final java.lang.String GLOBAL_STATE_FILE_PREFIX
- See Also:
- Constant Field Values
-
FORMAT
public static final MetaDataStateFormat<MetaData> FORMAT
State format forMetaData
to write to and load from disk
-
-
Method Detail
-
version
public long version()
-
clusterUUID
public java.lang.String clusterUUID()
-
settings
public Settings settings()
Returns the merged transient and persistent settings.
-
transientSettings
public Settings transientSettings()
-
persistentSettings
public Settings persistentSettings()
-
hasAlias
public boolean hasAlias(java.lang.String alias)
-
equalsAliases
public boolean equalsAliases(MetaData other)
-
getAliasAndIndexLookup
public java.util.SortedMap<java.lang.String,AliasOrIndex> getAliasAndIndexLookup()
-
findAliases
public ImmutableOpenMap<java.lang.String,java.util.List<AliasMetaData>> findAliases(java.lang.String[] aliases, 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 or match partially with the indices via wildcards.- Parameters:
aliases
- The names of the index aliases to findconcreteIndices
- The concrete indexes the index aliases must point to order to be returned.- Returns:
- a map of index to a list of alias metadata, the list corresponding to a concrete index will be empty if no aliases are present for that index
-
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.IOException
Finds 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()
-
getConcreteAllIndices
public java.lang.String[] getConcreteAllIndices()
Returns all the concrete indices.
-
getConcreteAllOpenIndices
public java.lang.String[] getConcreteAllOpenIndices()
-
getConcreteAllClosedIndices
public java.lang.String[] getConcreteAllClosedIndices()
-
resolveWriteIndexRouting
public java.lang.String resolveWriteIndexRouting(@Nullable java.lang.String parent, @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 parent, @Nullable java.lang.String routing, java.lang.String aliasOrIndex)
Returns indexing routing for the given index.
-
hasIndex
public boolean hasIndex(java.lang.String index)
-
hasConcreteIndex
public boolean hasConcreteIndex(java.lang.String index)
-
index
public IndexMetaData index(java.lang.String index)
-
index
public IndexMetaData index(Index index)
-
hasIndexMetaData
public boolean hasIndexMetaData(IndexMetaData indexMetaData)
Returns true iff existing index has the sameIndexMetaData
instance
-
getIndexSafe
public IndexMetaData getIndexSafe(Index index)
Returns theIndexMetaData
for this index.- Throws:
IndexNotFoundException
- if no metadata for this index is found
-
indices
public ImmutableOpenMap<java.lang.String,IndexMetaData> indices()
-
getIndices
public ImmutableOpenMap<java.lang.String,IndexMetaData> getIndices()
-
templates
public ImmutableOpenMap<java.lang.String,IndexTemplateMetaData> templates()
-
getTemplates
public ImmutableOpenMap<java.lang.String,IndexTemplateMetaData> getTemplates()
-
customs
public ImmutableOpenMap<java.lang.String,MetaData.Custom> customs()
-
getCustoms
public ImmutableOpenMap<java.lang.String,MetaData.Custom> getCustoms()
-
indexGraveyard
public IndexGraveyard indexGraveyard()
The collection of index deletions in the cluster.
-
custom
public <T extends MetaData.Custom> T custom(java.lang.String type)
-
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.
-
getNumberOfShards
public int getNumberOfShards()
Gets the number of primary shards from all indices, not including replicas.- Returns:
- The number of primary 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, java.lang.String type)
- Parameters:
concreteIndex
- The concrete index to check if routing is requiredtype
- The type to check if routing is required- Returns:
- Whether routing is required according to the mapping for the specified index and type
-
iterator
public java.util.Iterator<IndexMetaData> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<IndexMetaData>
-
isGlobalStateEquals
public static boolean isGlobalStateEquals(MetaData metaData1, MetaData metaData2)
-
diff
public Diff<MetaData> diff(MetaData previousState)
Description copied from interface:Diffable
Returns serializable object representing differences between this and previousState
-
readDiffFrom
public static Diff<MetaData> readDiffFrom(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
fromXContent
public static MetaData fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
readFrom
public static MetaData readFrom(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Writeable
Write this into the StreamOutput.
-
builder
public static MetaData.Builder builder()
-
builder
public static MetaData.Builder builder(MetaData metaData)
-
-