public class IndexMetaData extends java.lang.Object implements Diffable<IndexMetaData>, ToXContent
Modifier and Type | Class and Description |
---|---|
static class |
IndexMetaData.Builder |
static interface |
IndexMetaData.Custom
Deprecated.
|
static class |
IndexMetaData.State |
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
EMPTY_PARAMS
Modifier and Type | Method and Description |
---|---|
static Settings |
addHumanReadableSettings(Settings settings)
Adds human readable version and creation date settings.
|
static IndexMetaData.Builder |
builder(IndexMetaData indexMetaData) |
static IndexMetaData.Builder |
builder(java.lang.String index) |
<T extends IndexMetaData.Custom> |
custom(java.lang.String type) |
Diff<IndexMetaData> |
diff(IndexMetaData previousState)
Returns serializable object representing differences between this and previousState
|
boolean |
equals(java.lang.Object o) |
DiscoveryNodeFilters |
excludeFilters() |
static IndexMetaData |
fromXContent(XContentParser parser) |
ImmutableOpenMap<java.lang.String,AliasMetaData> |
getAliases() |
long |
getCreationDate() |
Version |
getCreationVersion()
Return the
Version on which this index has been created. |
ImmutableOpenMap<java.lang.String,IndexMetaData.Custom> |
getCustoms() |
Index |
getIndex() |
java.lang.String |
getIndexUUID() |
DiscoveryNodeFilters |
getInitialRecoveryFilters() |
ImmutableOpenIntMap<java.util.Set<java.lang.String>> |
getInSyncAllocationIds() |
ImmutableOpenMap<java.lang.String,MappingMetaData> |
getMappings() |
Index |
getMergeSourceIndex() |
int |
getNumberOfReplicas() |
int |
getNumberOfShards() |
int |
getRoutingFactor()
Returns the routing factor for this index.
|
static int |
getRoutingFactor(IndexMetaData sourceIndexMetadata,
int targetNumberOfShards)
Returns the routing factor for and shrunk index with the given number of target shards.
|
int |
getRoutingNumShards()
Returns the number of shards that should be used for routing.
|
int |
getRoutingPartitionSize() |
Settings |
getSettings() |
IndexMetaData.State |
getState() |
int |
getTotalNumberOfShards() |
Version |
getUpgradedVersion()
Return the
Version on which this index has been upgraded. |
long |
getVersion() |
ActiveShardCount |
getWaitForActiveShards()
Returns the configured
SETTING_WAIT_FOR_ACTIVE_SHARDS , which defaults
to an active shard count of 1 if not specified. |
int |
hashCode() |
DiscoveryNodeFilters |
includeFilters() |
java.util.Set<java.lang.String> |
inSyncAllocationIds(int shardId) |
static boolean |
isIndexUsingShadowReplicas(Settings settings)
Returns
true iff the given settings indicate that the index associated
with these settings uses shadow replicas. |
static boolean |
isOnSharedFilesystem(Settings settings)
Returns
true iff the given settings indicate that the index
associated with these settings allocates it's shards on a shared
filesystem. |
boolean |
isRoutingPartitionedIndex() |
boolean |
isSameUUID(java.lang.String otherUUID)
Test whether the current index UUID is the same as the given one.
|
static <T extends IndexMetaData.Custom> |
lookupPrototype(java.lang.String type) |
static <T extends IndexMetaData.Custom> |
lookupPrototypeSafe(java.lang.String type) |
MappingMetaData |
mapping(java.lang.String mappingType) |
MappingMetaData |
mappingOrDefault(java.lang.String mappingType)
Sometimes, the default mapping exists and an actual mapping is not created yet (introduced),
in this case, we want to return the default mapping in case it has some default mapping definitions.
|
long |
primaryTerm(int shardId)
The term of the current selected primary.
|
static Diff<IndexMetaData> |
readDiffFrom(StreamInput in) |
static IndexMetaData |
readFrom(StreamInput in) |
static void |
registerPrototype(java.lang.String type,
IndexMetaData.Custom proto)
Register a custom index meta data factory.
|
DiscoveryNodeFilters |
requireFilters() |
static java.util.Set<ShardId> |
selectShrinkShards(int shardId,
IndexMetaData sourceIndexMetadata,
int numTargetShards)
Returns the source shard ids to shrink into the given shard id.
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
isFragment
public static java.util.Map<java.lang.String,IndexMetaData.Custom> customPrototypes
public static final ClusterBlock INDEX_READ_ONLY_BLOCK
public static final ClusterBlock INDEX_READ_BLOCK
public static final ClusterBlock INDEX_WRITE_BLOCK
public static final ClusterBlock INDEX_METADATA_BLOCK
public static final ClusterBlock INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
public static final java.lang.String INDEX_SETTING_PREFIX
public static final java.lang.String SETTING_NUMBER_OF_SHARDS
public static final Setting<java.lang.Integer> INDEX_NUMBER_OF_SHARDS_SETTING
public static final java.lang.String SETTING_NUMBER_OF_REPLICAS
public static final Setting<java.lang.Integer> INDEX_NUMBER_OF_REPLICAS_SETTING
public static final java.lang.String SETTING_SHADOW_REPLICAS
public static final Setting<java.lang.Boolean> INDEX_SHADOW_REPLICAS_SETTING
public static final java.lang.String SETTING_ROUTING_PARTITION_SIZE
public static final Setting<java.lang.Integer> INDEX_ROUTING_PARTITION_SIZE_SETTING
public static final java.lang.String SETTING_SHARED_FILESYSTEM
public static final Setting<java.lang.Boolean> INDEX_SHARED_FILESYSTEM_SETTING
public static final java.lang.String SETTING_AUTO_EXPAND_REPLICAS
public static final Setting<org.elasticsearch.cluster.metadata.AutoExpandReplicas> INDEX_AUTO_EXPAND_REPLICAS_SETTING
public static final java.lang.String SETTING_READ_ONLY
public static final Setting<java.lang.Boolean> INDEX_READ_ONLY_SETTING
public static final java.lang.String SETTING_BLOCKS_READ
public static final Setting<java.lang.Boolean> INDEX_BLOCKS_READ_SETTING
public static final java.lang.String SETTING_BLOCKS_WRITE
public static final Setting<java.lang.Boolean> INDEX_BLOCKS_WRITE_SETTING
public static final java.lang.String SETTING_BLOCKS_METADATA
public static final Setting<java.lang.Boolean> INDEX_BLOCKS_METADATA_SETTING
public static final java.lang.String SETTING_READ_ONLY_ALLOW_DELETE
public static final Setting<java.lang.Boolean> INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING
public static final java.lang.String SETTING_VERSION_CREATED
public static final java.lang.String SETTING_VERSION_CREATED_STRING
public static final java.lang.String SETTING_VERSION_UPGRADED
public static final java.lang.String SETTING_VERSION_UPGRADED_STRING
public static final java.lang.String SETTING_CREATION_DATE
public static final java.lang.String SETTING_INDEX_PROVIDED_NAME
public static final java.lang.String SETTING_PRIORITY
public static final Setting<java.lang.Integer> INDEX_PRIORITY_SETTING
public static final java.lang.String SETTING_CREATION_DATE_STRING
public static final java.lang.String SETTING_INDEX_UUID
public static final java.lang.String SETTING_DATA_PATH
public static final Setting<java.lang.String> INDEX_DATA_PATH_SETTING
public static final java.lang.String SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE
public static final Setting<java.lang.Boolean> INDEX_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE_SETTING
public static final java.lang.String INDEX_UUID_NA_VALUE
public static final java.lang.String INDEX_ROUTING_REQUIRE_GROUP_PREFIX
public static final java.lang.String INDEX_ROUTING_INCLUDE_GROUP_PREFIX
public static final java.lang.String INDEX_ROUTING_EXCLUDE_GROUP_PREFIX
public static final Setting<Settings> INDEX_ROUTING_REQUIRE_GROUP_SETTING
public static final Setting<Settings> INDEX_ROUTING_INCLUDE_GROUP_SETTING
public static final Setting<Settings> INDEX_ROUTING_EXCLUDE_GROUP_SETTING
public static final Setting<Settings> INDEX_ROUTING_INITIAL_RECOVERY_GROUP_SETTING
public static final Setting<ActiveShardCount> SETTING_WAIT_FOR_ACTIVE_SHARDS
public static final Setting<java.lang.Integer> INDEX_FORMAT_SETTING
public static final java.lang.String KEY_IN_SYNC_ALLOCATIONS
public static final java.lang.String KEY_PRIMARY_TERMS
public static final java.lang.String INDEX_STATE_FILE_PREFIX
public static final java.lang.String INDEX_SHRINK_SOURCE_UUID_KEY
public static final java.lang.String INDEX_SHRINK_SOURCE_NAME_KEY
public static final Setting<java.lang.String> INDEX_SHRINK_SOURCE_UUID
public static final Setting<java.lang.String> INDEX_SHRINK_SOURCE_NAME
public static final MetaDataStateFormat<IndexMetaData> FORMAT
IndexMetaData
to write to and load from diskpublic static void registerPrototype(java.lang.String type, IndexMetaData.Custom proto)
@Nullable public static <T extends IndexMetaData.Custom> T lookupPrototype(java.lang.String type)
public static <T extends IndexMetaData.Custom> T lookupPrototypeSafe(java.lang.String type)
public Index getIndex()
public java.lang.String getIndexUUID()
public boolean isSameUUID(java.lang.String otherUUID)
public long getVersion()
public long primaryTerm(int shardId)
IndexMetaDataUpdater.applyChanges(org.elasticsearch.cluster.metadata.MetaData, org.elasticsearch.cluster.routing.RoutingTable)
.public Version getCreationVersion()
Version
on which this index has been created. This
information is typically useful for backward compatibility.public Version getUpgradedVersion()
Version
on which this index has been upgraded. This
information is typically useful for backward compatibility.public long getCreationDate()
public IndexMetaData.State getState()
public int getNumberOfShards()
public int getNumberOfReplicas()
public int getRoutingPartitionSize()
public boolean isRoutingPartitionedIndex()
public int getTotalNumberOfShards()
public ActiveShardCount getWaitForActiveShards()
SETTING_WAIT_FOR_ACTIVE_SHARDS
, which defaults
to an active shard count of 1 if not specified.public Settings getSettings()
public ImmutableOpenMap<java.lang.String,AliasMetaData> getAliases()
public ImmutableOpenMap<java.lang.String,MappingMetaData> getMappings()
@Nullable public MappingMetaData mapping(java.lang.String mappingType)
public Index getMergeSourceIndex()
@Nullable public MappingMetaData mappingOrDefault(java.lang.String mappingType)
Note, once the mapping type is introduced, the default mapping is applied on the actual typed MappingMetaData, setting its routing, timestamp, and so on if needed.
public ImmutableOpenMap<java.lang.String,IndexMetaData.Custom> getCustoms()
public <T extends IndexMetaData.Custom> T custom(java.lang.String type)
public ImmutableOpenIntMap<java.util.Set<java.lang.String>> getInSyncAllocationIds()
public java.util.Set<java.lang.String> inSyncAllocationIds(int shardId)
@Nullable public DiscoveryNodeFilters requireFilters()
@Nullable public DiscoveryNodeFilters getInitialRecoveryFilters()
@Nullable public DiscoveryNodeFilters includeFilters()
@Nullable public DiscoveryNodeFilters excludeFilters()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public Diff<IndexMetaData> diff(IndexMetaData previousState)
Diffable
diff
in interface Diffable<IndexMetaData>
public static Diff<IndexMetaData> readDiffFrom(StreamInput in) throws java.io.IOException
java.io.IOException
public static IndexMetaData fromXContent(XContentParser parser) throws java.io.IOException
java.io.IOException
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
public static IndexMetaData readFrom(StreamInput in) throws java.io.IOException
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Writeable
public static IndexMetaData.Builder builder(java.lang.String index)
public static IndexMetaData.Builder builder(IndexMetaData indexMetaData)
public static boolean isOnSharedFilesystem(Settings settings)
true
iff the given settings indicate that the index
associated with these settings allocates it's shards on a shared
filesystem. Otherwise false
. The default setting for this
is the returned value from
isIndexUsingShadowReplicas(org.elasticsearch.common.settings.Settings)
.public static boolean isIndexUsingShadowReplicas(Settings settings)
true
iff the given settings indicate that the index associated
with these settings uses shadow replicas. Otherwise false
. The default
setting for this is false
.public static Settings addHumanReadableSettings(Settings settings)
public int getRoutingNumShards()
OperationRouting.generateShardId(IndexMetaData, String, String)
to route documents
to shards based on their ID or their specific routing value. The default value is getNumberOfShards()
. This value only
changes if and index is shrunk.public int getRoutingFactor()
for details
public static java.util.Set<ShardId> selectShrinkShards(int shardId, IndexMetaData sourceIndexMetadata, int numTargetShards)
shardId
- the id of the target shard to shrink tosourceIndexMetadata
- the source index metadatanumTargetShards
- the total number of shards in the target indexpublic static int getRoutingFactor(IndexMetaData sourceIndexMetadata, int targetNumberOfShards)
OperationRouting.generateShardId(IndexMetaData, String, String)
to guarantee consistent
hashing / routing of documents even if the number of shards changed (ie. a shrunk index).sourceIndexMetadata
- the metadata of the source indextargetNumberOfShards
- the total number of shards in the target indexjava.lang.IllegalArgumentException
- if the number of source shards is greater than the number of target shards or if the source shards
are not divisible by the number of target shards.