private static boolean clusterHas5xIndices(ClusterState state) { final Iterator<IndexMetaData> indices = state.metaData().indices().valuesIt(); for(;indices.hasNext();) { final IndexMetaData indexMetaData = indices.next(); if(indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) { return true; } } return false; } }
public ImmutableOpenMap<String, IndexMetaData> getIndices() { return indices(); }
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { logger.info("recovered [{}] indices into cluster_state", newState.metaData().indices().size()); } });
/** * Returns the indices created in this event */ public List<String> indicesCreated() { if (!metaDataChanged()) { return Collections.emptyList(); } List<String> created = null; for (ObjectCursor<String> cursor : state.metaData().indices().keys()) { String index = cursor.value; if (!previousState.metaData().hasIndex(index)) { if (created == null) { created = new ArrayList<>(); } created.add(index); } } return created == null ? Collections.<String>emptyList() : created; }
private List<Index> indicesDeletedFromClusterState() { // If the new cluster state has a new cluster UUID, the likely scenario is that a node was elected // master that has had its data directory wiped out, in which case we don't want to delete the indices and lose data; // rather we want to import them as dangling indices instead. So we check here if the cluster UUID differs from the previous // cluster UUID, in which case, we don't want to delete indices that the master erroneously believes shouldn't exist. // See test DiscoveryWithServiceDisruptionsIT.testIndicesDeleted() // See discussion on https://github.com/elastic/elasticsearch/pull/9952 and // https://github.com/elastic/elasticsearch/issues/11665 if (metaDataChanged() == false || isNewCluster()) { return Collections.emptyList(); } List<Index> deleted = null; for (ObjectCursor<IndexMetaData> cursor : previousState.metaData().indices().values()) { IndexMetaData index = cursor.value; IndexMetaData current = state.metaData().index(index.getIndex()); if (current == null) { if (deleted == null) { deleted = new ArrayList<>(); } deleted.add(index.getIndex()); } } return deleted == null ? Collections.<Index>emptyList() : deleted; }
if (context == XContentContext.API && !metaData.indices().isEmpty()) { builder.startObject("indices"); for (IndexMetaData indexMetaData : metaData) {
public boolean equalsAliases(MetaData other) { for (ObjectCursor<IndexMetaData> cursor : other.indices().values()) { IndexMetaData otherIndex = cursor.value; IndexMetaData thisIndex = index(otherIndex.getIndex()); if (thisIndex == null) { return false; } if (otherIndex.getAliases().equals(thisIndex.getAliases()) == false) { return false; } } return true; }
final IndexMetaData metaData = clusterState.getMetaData().indices().get(shardId.getIndexName());
public ImmutableOpenMap<String, IndexMetaData> getIndices() { return indices(); }
boolean hasIndexRequestsWithPipelines = false; final MetaData metaData = clusterService.state().getMetaData(); ImmutableOpenMap<String, IndexMetaData> indicesMetaData = metaData.indices(); for (DocWriteRequest<?> actionRequest : bulkRequest.requests) { IndexRequest indexRequest = getIndexWriteRequest(actionRequest);
electedGlobalState = nodeState.metaData(); for (ObjectCursor<IndexMetaData> cursor : nodeState.metaData().indices().values()) { indices.addTo(cursor.value.getIndex(), 1);
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { logger.info("recovered [{}] indices into cluster_state", newState.metaData().indices().size()); } });
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { logger.info("recovered [{}] indices into cluster_state", newState.metaData().indices().size()); } });
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { logger.info("Recovered [{}] indices into cluster_state", newState.metaData().indices().size()); } });
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { logger.info("recovered [{}] indices into cluster_state", newState.metaData().indices().size()); } });
private static boolean clusterHas5xIndices(ClusterState state) { final Iterator<IndexMetaData> indices = state.metaData().indices().valuesIt(); for(;indices.hasNext();) { final IndexMetaData indexMetaData = indices.next(); if(indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) { return true; } } return false; } }
@Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { logger.info("recovered [{}] indices into cluster_state", newState.metaData().indices().size()); } });
private ImmutableMap<String, IndexMetaData> getIndexMetaData(Set<String> indexes) { ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() .filterRoutingTable(true) .filterNodes(true) .filteredIndices(indexes.toArray(new String[indexes.size()])); clusterStateRequest.listenerThreaded(false); ClusterStateResponse response = client.admin().cluster().state(clusterStateRequest).actionGet(); return ImmutableMap.copyOf(response.getState().metaData().indices()); }