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
  • Field Details

  • 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 by clusterUUID(), meaning that it will not accept any cluster state with a different clusterUUID.
    • settings

      public Settings settings()
      Returns the merged transient and persistent settings.
    • transientSettings

      public Settings transientSettings()
    • persistentSettings

      public Settings persistentSettings()
    • hashesOfConsistentSettings

      public java.util.Map<java.lang.String,​java.lang.String> hashesOfConsistentSettings()
    • coordinationMetaData

      public CoordinationMetaData coordinationMetaData()
    • hasAlias

      public boolean hasAlias​(java.lang.String alias)
    • equalsAliases

      public boolean equalsAliases​(MetaData other)
    • getAliasAndIndexLookup

      public java.util.SortedMap<java.lang.String,​AliasOrIndex> getAliasAndIndexLookup()
    • 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 for
      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.
    • 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 find
      concreteIndices - 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 routing, java.lang.String aliasOrIndex)
      Returns indexing routing for the given aliasOrIndex. 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)
    • 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 same IndexMetaData instance
    • getIndexSafe

      public IndexMetaData getIndexSafe​(Index index)
      Returns the IndexMetaData 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.
    • 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

      public java.util.Iterator<IndexMetaData> iterator()
      Specified by:
      iterator in interface java.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
      Specified by:
      diff in interface Diffable<MetaData>
    • 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 interface ToXContent
      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.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • builder

      public static MetaData.Builder builder()
    • builder

      public static MetaData.Builder builder​(MetaData metaData)