org.elasticsearch.cluster.metadata.MetaData.getIndices()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.elasticsearch.cluster.metadata.MetaData.getIndices()方法的一些代码示例,展示了MetaData.getIndices()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaData.getIndices()方法的具体详情如下:
包路径:org.elasticsearch.cluster.metadata.MetaData
类名称:MetaData
方法名:getIndices

MetaData.getIndices介绍

暂无

代码示例

代码示例来源:origin: alibaba/canal

.getState()
.getMetaData()
.getIndices()
.get(mapping.get_index())
.getMappings();

代码示例来源:origin: floragunncom/search-guard

final IndexMetaData indexMetaData = clusterService.state().metaData().getIndices().get(requestAliasOrIndex);

代码示例来源:origin: Netflix/conductor

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);
    }
  });
}

代码示例来源:origin: org.elasticsearch/elasticsearch

return null;
final IndexMetaData indexMetaData = state.metaData().getIndices().get(index);
if (indexMetaData == null) {

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * @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;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

for (AliasAction action : actions) {
  if (action.removeIndex()) {
    IndexMetaData index = currentState.metaData().getIndices().get(action.getIndex());
    if (index == null) {
      throw new IndexNotFoundException(action.getIndex());

代码示例来源:origin: org.elasticsearch/elasticsearch

ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings();
if (mappings.isEmpty()) {
  listener.onResponse(new TypesExistsResponse(false));

代码示例来源:origin: harbby/presto-connectors

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());
}

代码示例来源:origin: harbby/presto-connectors

/**
 * @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;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * @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;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * @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;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * @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;
}

代码示例来源:origin: com.scireum/sirius-search

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;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * 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());
  }
}

代码示例来源:origin: Anchormen/sql4es

@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;
}

代码示例来源:origin: allegro/hermes

public ImmutableOpenMap<String, IndexMetaData> getIndices() {
  return client.admin().cluster().prepareState().execute().actionGet().getState().getMetaData().getIndices();
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

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());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

ClusterIndexHealth indexHealth = response.getIndices().get(indexName);
IndexStats indexStats = stats.getIndices().get(indexName);
IndexMetaData indexMetaData = indexMetaDatas.getIndices().get(indexName);
IndexMetaData.State state = indexMetaData.getState();

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings();
if (mappings.isEmpty()) {
  listener.onResponse(new TypesExistsResponse(false));

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings();
if (mappings.isEmpty()) {
  listener.onResponse(new TypesExistsResponse(false));

相关文章