.getState() .getMetaData() .getIndices() .get(mapping.get_index()) .getMappings();
final IndexMetaData indexMetaData = clusterService.state().metaData().getIndices().get(requestAliasOrIndex);
private void deleteAllIndices() { ImmutableOpenMap<String, IndexMetaData> indices = elasticSearchClient.admin().cluster() .prepareState().get().getState() .getMetaData().getIndices(); indices.forEach(cursor -> { try { elasticSearchClient.admin() .indices() .delete(new DeleteIndexRequest(cursor.value.getIndex().getName())) .get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }); }
return null; final IndexMetaData indexMetaData = state.metaData().getIndices().get(index); if (indexMetaData == null) {
/** * @return all shard ids the request should run on */ protected List<ShardId> shards(Request request, ClusterState clusterState) { List<ShardId> shardIds = new ArrayList<>(); String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); for (String index : concreteIndices) { IndexMetaData indexMetaData = clusterState.metaData().getIndices().get(index); if (indexMetaData != null) { for (IntObjectCursor<IndexShardRoutingTable> shardRouting : clusterState.getRoutingTable().indicesRouting().get(index).getShards()) { shardIds.add(shardRouting.value.shardId()); } } } return shardIds; }
for (AliasAction action : actions) { if (action.removeIndex()) { IndexMetaData index = currentState.metaData().getIndices().get(action.getIndex()); if (index == null) { throw new IndexNotFoundException(action.getIndex());
ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings(); if (mappings.isEmpty()) { listener.onResponse(new TypesExistsResponse(false));
private Version getVersion(MetaData metaData, String concreteIndex) { // this can go away in 3.0 but is here now for easy backporting - since in 2.x we need the version on the timestamp stuff final IndexMetaData indexMetaData = metaData.getIndices().get(concreteIndex); if (indexMetaData == null) { throw new IndexNotFoundException(concreteIndex); } return Version.indexCreated(indexMetaData.getSettings()); }
/** * @return all shard ids the request should run on */ protected List<ShardId> shards(Request request, ClusterState clusterState) { List<ShardId> shardIds = new ArrayList<>(); String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request); for (String index : concreteIndices) { IndexMetaData indexMetaData = clusterState.metaData().getIndices().get(index); if (indexMetaData != null) { for (IntObjectCursor<IndexShardRoutingTable> shardRouting : clusterState.getRoutingTable().indicesRouting().get(index).getShards()) { shardIds.add(shardRouting.value.shardId()); } } } return shardIds; }
/** * @return all shard ids the request should run on */ protected List<ShardId> shards(Request request, ClusterState clusterState) { List<ShardId> shardIds = new ArrayList<>(); String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); for (String index : concreteIndices) { IndexMetaData indexMetaData = clusterState.metaData().getIndices().get(index); if (indexMetaData != null) { for (IntObjectCursor<IndexShardRoutingTable> shardRouting : clusterState.getRoutingTable().indicesRouting().get(index).getShards()) { shardIds.add(shardRouting.value.shardId()); } } } return shardIds; }
/** * @return all shard ids the request should run on */ protected List<ShardId> shards(Request request, ClusterState clusterState) { List<ShardId> shardIds = new ArrayList<>(); String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); for (String index : concreteIndices) { IndexMetaData indexMetaData = clusterState.metaData().getIndices().get(index); if (indexMetaData != null) { for (IntObjectCursor<IndexShardRoutingTable> shardRouting : clusterState.getRoutingTable().indicesRouting().get(index).getShards()) { shardIds.add(shardRouting.value.shardId()); } } } return shardIds; }
/** * @return all shard ids the request should run on */ protected List<ShardId> shards(Request request, ClusterState clusterState) { List<ShardId> shardIds = new ArrayList<>(); String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); for (String index : concreteIndices) { IndexMetaData indexMetaData = clusterState.metaData().getIndices().get(index); if (indexMetaData != null) { for (IntObjectCursor<IndexShardRoutingTable> shardRouting : clusterState.getRoutingTable().indicesRouting().get(index).getShards()) { shardIds.add(shardRouting.value.shardId()); } } } return shardIds; }
private Map<String, String> getIndicesMetadata(ClusterStateResponse clusterStateResponse) { Map<String, String> metaDataMap = new HashMap<>(); for (ObjectObjectCursor<String, IndexMetaData> metadata : clusterStateResponse.getState() .getMetaData() .getIndices()) { try (XContentBuilder metaDataBuilder = XContentFactory.jsonBuilder()) { metaDataBuilder.humanReadable(true).prettyPrint().startObject(); clusterStateResponse.getState() .getMetaData() .index(metadata.key) .toXContent(metaDataBuilder, ToXContent.EMPTY_PARAMS); metaDataBuilder.endObject(); metaDataMap.put(metadata.key, metaDataBuilder.string()); } catch (IOException e) { Exceptions.handle(e); } } return metaDataMap; }
/** * Build a RoutingTable according to clusterState ( * -Allocate unallocated indices with one primary shard on local node). * -Remove obsolete IndexRoutingTable */ public Builder(ClusterService clusterService, ClusterState clusterState) { version = clusterState.routingTable().version(); for (ObjectObjectCursor<String, IndexMetaData> entry : clusterState.metaData().getIndices()) { IndexRoutingTable.Builder indexRoutingTableBuilder = new IndexRoutingTable.Builder(entry.value.getIndex(), clusterService, clusterState); if (indexRoutingTableBuilder.shards.size() > 0) indicesRouting.put(entry.key, indexRoutingTableBuilder.build()); } }
@Override public ResultSet getSchemas() throws SQLException { ImmutableOpenMap<String, IndexMetaData> indices = client.admin().cluster() .prepareState().get().getState() .getMetaData().getIndices(); SortedMap<String, AliasOrIndex> aliasAndIndices = client.admin().cluster().prepareState().get().getState() .getMetaData().getAliasAndIndexLookup(); Heading heading = new Heading(); heading.add(new Column("TABLE_SCHEM")); heading.add(new Column("TABLE_CATALOG")); ESResultSet result = new ESResultSet(heading, indices.size(), heading.getColumnCount()); for(String key : aliasAndIndices.keySet()){ List<Object> row = result.getNewRow(); row.set(0, key); row.set(1, "elasticsearch" /* aliasAndIndices.get(key).isAlias() ? "alias" : "index"*/); result.add(row); } return result; }
public ImmutableOpenMap<String, IndexMetaData> getIndices() { return client.admin().cluster().prepareState().execute().actionGet().getState().getMetaData().getIndices(); }
public static RoutingTable build(ClusterService clusterService, ClusterState clusterState) { ImmutableOpenMap.Builder<String, IndexRoutingTable> indicesRoutingMap = new ImmutableOpenMap.Builder<>(); for(ObjectObjectCursor<String, IndexMetaData> entry : clusterState.metaData().getIndices()) { IndexRoutingTable.Builder indexRoutingTableBuilder = new IndexRoutingTable.Builder(entry.value.getIndex(), clusterService, clusterState); if (indexRoutingTableBuilder.shards.size() > 0) indicesRoutingMap.put(indexRoutingTableBuilder.index.getName(), indexRoutingTableBuilder.build()); } return new RoutingTable(clusterState.routingTable().version(), indicesRoutingMap.build()); }
ClusterIndexHealth indexHealth = response.getIndices().get(indexName); IndexStats indexStats = stats.getIndices().get(indexName); IndexMetaData indexMetaData = indexMetaDatas.getIndices().get(indexName); IndexMetaData.State state = indexMetaData.getState();
ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings(); if (mappings.isEmpty()) { listener.onResponse(new TypesExistsResponse(false));
ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings(); if (mappings.isEmpty()) { listener.onResponse(new TypesExistsResponse(false));