org.elasticsearch.cluster.ClusterState.routingTable()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(131)

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

ClusterState.routingTable介绍

暂无

代码示例

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

/**
 * Returns <code>true</code> iff the routing tables (for all indices) have
 * changed between the previous cluster state and the current cluster state.
 * Note that this is an object reference equality test, not an equals test.
 */
public boolean routingTableChanged() {
  return state.routingTable() != previousState.routingTable();
}

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

public RoutingTable getRoutingTable() {
  return routingTable();
}

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

/**
 * The refresh request works against *all* shards.
 */
@Override
protected ShardsIterator shards(ClusterState clusterState, ForceMergeRequest request, String[] concreteIndices) {
  return clusterState.routingTable().allShards(concreteIndices);
}

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

/**
 * Getting upgrade stats from *all* active shards.
 */
@Override
protected ShardsIterator shards(ClusterState clusterState, UpgradeStatusRequest request, String[] concreteIndices) {
  return clusterState.routingTable().allShards(concreteIndices);
}

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

/**
 * Segments goes across *all* active shards.
 */
@Override
protected ShardsIterator shards(ClusterState clusterState, IndicesSegmentsRequest request, String[] concreteIndices) {
  return clusterState.routingTable().allShards(concreteIndices);
}

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

/**
 * Status goes across *all* shards.
 */
@Override
protected ShardsIterator shards(ClusterState clusterState, IndicesStatsRequest request, String[] concreteIndices) {
  return clusterState.routingTable().allShards(concreteIndices);
}

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

/**
 * The refresh request works against *all* shards.
 */
@Override
protected ShardsIterator shards(ClusterState clusterState, ClearIndicesCacheRequest request, String[] concreteIndices) {
  return clusterState.routingTable().allShards(concreteIndices);
}

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

@Override
protected ShardsIterator shards(ClusterState state, RecoveryRequest request, String[] concreteIndices) {
  return state.routingTable().allShardsIncludingRelocationTargets(concreteIndices);
}

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

/**
 * Returns <code>true</code> iff the routing table has changed for the given index.
 * Note that this is an object reference equality test, not an equals test.
 */
public boolean indexRoutingTableChanged(String index) {
  Objects.requireNonNull(index, "index must not be null");
  if (!state.routingTable().hasIndex(index) && !previousState.routingTable().hasIndex(index)) {
    return false;
  }
  if (state.routingTable().hasIndex(index) && previousState.routingTable().hasIndex(index)) {
    return state.routingTable().index(index) != previousState.routingTable().index(index);
  }
  return true;
}

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

/**
 * Finds all indices that have not all primaries available
 */
private Set<String> indicesWithMissingPrimaries(ClusterState clusterState, String[] concreteIndices) {
  Set<String> indices = new HashSet<>();
  RoutingTable routingTable = clusterState.routingTable();
  for (String index : concreteIndices) {
    IndexRoutingTable indexRoutingTable = routingTable.index(index);
    if (indexRoutingTable.allPrimaryShardsActive() == false) {
      indices.add(index);
    }
  }
  return indices;
}

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

protected IndexRoutingTable indexRoutingTable(ClusterState clusterState, String index) {
  IndexRoutingTable indexRouting = clusterState.routingTable().index(index);
  if (indexRouting == null) {
    throw new IndexNotFoundException(index);
  }
  return indexRouting;
}

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

/**
 * The upgrade request works against *all* shards.
 */
@Override
protected ShardsIterator shards(ClusterState clusterState, UpgradeRequest request, String[] concreteIndices) {
  ShardsIterator iterator = clusterState.routingTable().allShards(concreteIndices);
  Set<String> indicesWithMissingPrimaries = indicesWithMissingPrimaries(clusterState, concreteIndices);
  if (indicesWithMissingPrimaries.isEmpty()) {
    return iterator;
  }
  // If some primary shards are not available the request should fail.
  throw new PrimaryMissingActionException("Cannot upgrade indices because the following indices are missing primary shards " +
    indicesWithMissingPrimaries);
}

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

@Override
protected ShardsIterator shards(ClusterState state, InternalRequest request) {
  // Will balance requests between shards
  // Resolve patterns and deduplicate
  return state.routingTable().index(request.concreteIndex()).randomAllActiveShardsIt();
}

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

/**
 * Returns the number of shards that are unassigned and currently being delayed.
 */
public static int getNumberOfDelayedUnassigned(ClusterState state) {
  int count = 0;
  for (ShardRouting shard : state.routingTable().shardsWithState(ShardRoutingState.UNASSIGNED)) {
    if (shard.unassignedInfo().isDelayed()) {
      count++;
    }
  }
  return count;
}

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

@Override
protected ShardsIterator shards(ClusterState state, InternalRequest request) {
  // Will balance requests between shards
  return state.routingTable().index(request.concreteIndex()).randomAllActiveShardsIt();
}

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

@Override
protected ShardsIterator shards(ClusterState state, InternalRequest request) {
  if (request.concreteIndex() == null) {
    // just execute locally....
    return null;
  }
  return state.routingTable().index(request.concreteIndex()).randomAllActiveShardsIt();
}

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

public ClusterState(long version, String stateUUID, ClusterState state) {
  this(state.clusterName, version, stateUUID, state.metaData(), state.routingTable(), state.nodes(), state.blocks(), state.customs(),
    false);
}

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

public Builder(ClusterState state) {
  this.clusterName = state.clusterName;
  this.version = state.version();
  this.uuid = state.stateUUID();
  this.nodes = state.nodes();
  this.routingTable = state.routingTable();
  this.metaData = state.metaData();
  this.blocks = state.blocks();
  this.customs = ImmutableOpenMap.builder(state.customs());
  this.fromDiff = false;
}

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

@Override
protected ShardIterator shards(ClusterState clusterState, UpdateRequest request) {
  if (request.getShardId() != null) {
    return clusterState.routingTable().index(request.concreteIndex()).shard(request.getShardId().getId()).primaryShardIt();
  }
  ShardIterator shardIterator = clusterService.operationRouting()
      .indexShards(clusterState, request.concreteIndex(), request.id(), request.routing());
  ShardRouting shard;
  while ((shard = shardIterator.nextOrNull()) != null) {
    if (shard.primary()) {
      return new PlainShardIterator(shardIterator.shardId(), Collections.singletonList(shard));
    }
  }
  return new PlainShardIterator(shardIterator.shardId(), Collections.emptyList());
}

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

final IndexShardRoutingTable getShardRoutingTable(ShardId shardId, ClusterState state) {
  final IndexRoutingTable indexRoutingTable = state.routingTable().index(shardId.getIndexName());
  if (indexRoutingTable == null) {
    IndexMetaData index = state.getMetaData().index(shardId.getIndex());
    if (index != null && index.getState() == IndexMetaData.State.CLOSE) {
      throw new IndexClosedException(shardId.getIndex());
    }
    throw new IndexNotFoundException(shardId.getIndexName());
  }
  final IndexShardRoutingTable shardRoutingTable = indexRoutingTable.shard(shardId.id());
  if (shardRoutingTable == null) {
    throw new ShardNotFoundException(shardId);
  }
  return shardRoutingTable;
}

相关文章