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

x33g5p2x  于2022-01-21 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(67)

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

IndexMetaData.isIndexUsingShadowReplicas介绍

[英]Returns 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.
[中]如果给定设置指示与这些设置关联的索引使用卷影副本,则返回true。否则false。默认设置为false

代码示例

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

/**
 * Indicated whether this operation should be replicated to shadow replicas or not. If this method returns true the replication phase will be skipped.
 * For example writes such as index and delete don't need to be replicated on shadow replicas but refresh and flush do.
 */
protected boolean shouldExecuteReplication(Settings settings) {
  return IndexMetaData.isIndexUsingShadowReplicas(settings) == false;
}

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

/** Return true if a shadow engine should be used */
protected boolean useShadowEngine() {
  return primary == false && IndexMetaData.isIndexUsingShadowReplicas(settings);
}

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

/**
 * Returns <code>true</code> iff the given settings indicate that the index
 * associated with these settings allocates it's shards on a shared
 * filesystem. Otherwise <code>false</code>. The default setting for this
 * is the returned value from
 * {@link #isIndexUsingShadowReplicas(org.elasticsearch.common.settings.Settings)}.
 */
public static boolean isOnSharedFilesystem(Settings settings) {
  // don't use the setting directly, not to trigger verbose deprecation logging
  return settings.getAsBoolean(SETTING_SHARED_FILESYSTEM, isIndexUsingShadowReplicas(settings));
}

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

/**
 * Returns <code>true</code> iff the given settings indicate that the index
 * associated with these settings allocates it's shards on a shared
 * filesystem. Otherwise <code>false</code>. The default setting for this
 * is the returned value from
 * {@link #isIndexUsingShadowReplicas(org.elasticsearch.common.settings.Settings)}.
 */
public static boolean isOnSharedFilesystem(Settings settings) {
  return settings.getAsBoolean(SETTING_SHARED_FILESYSTEM, isIndexUsingShadowReplicas(settings));
}

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

private void promoteReplicaToPrimary(ShardRouting activeReplica, IndexMetaData indexMetaData,
                   RoutingChangesObserver routingChangesObserver) {
  // if the activeReplica was relocating before this call to failShard, its relocation was cancelled earlier when we
  // failed initializing replica shards (and moved replica relocation source back to started)
  assert activeReplica.started() : "replica relocation should have been cancelled: " + activeReplica;
  ShardRouting primarySwappedCandidate = promoteActiveReplicaShardToPrimary(activeReplica);
  routingChangesObserver.replicaPromoted(activeReplica);
  if (IndexMetaData.isIndexUsingShadowReplicas(indexMetaData.getSettings())) {
    ShardRouting initializedShard = reinitShadowPrimary(primarySwappedCandidate);
    routingChangesObserver.startedPrimaryReinitialized(primarySwappedCandidate, initializedShard);
  }
}

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

IndexMetaData.isIndexUsingShadowReplicas(indexMetaData.getSettings()) == false && // see #20650
shardRouting.primary() && shardRouting.initializing() &&
shardRouting.recoverySource().getType() == RecoverySource.Type.SNAPSHOT &&

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

static void buildShardLevelInfo(ESLogger logger, ShardStats[] stats, HashMap<String, Long> newShardSizes, HashMap<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
  MetaData meta = state.getMetaData();
  for (ShardStats s : stats) {
    IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
    Settings indexSettings = indexMeta == null ? null : indexMeta.getSettings();
    newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
    long size = s.getStats().getStore().sizeInBytes();
    String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
    if (logger.isTraceEnabled()) {
      logger.trace("shard: {} size: {}", sid, size);
    }
    if (indexSettings != null && IndexMetaData.isIndexUsingShadowReplicas(indexSettings)) {
      // Shards on a shared filesystem should be considered of size 0
      if (logger.isTraceEnabled()) {
        logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
      }
      size = 0;
    }
    newShardSizes.put(sid, size);
  }
}

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

static void buildShardLevelInfo(Logger logger, ShardStats[] stats, ImmutableOpenMap.Builder<String, Long> newShardSizes,
                ImmutableOpenMap.Builder<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
  MetaData meta = state.getMetaData();
  for (ShardStats s : stats) {
    IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
    Settings indexSettings = indexMeta == null ? null : indexMeta.getSettings();
    newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
    long size = s.getStats().getStore().sizeInBytes();
    String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
    if (logger.isTraceEnabled()) {
      logger.trace("shard: {} size: {}", sid, size);
    }
    if (indexSettings != null && IndexMetaData.isIndexUsingShadowReplicas(indexSettings)) {
      // Shards on a shared filesystem should be considered of size 0
      if (logger.isTraceEnabled()) {
        logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
      }
      size = 0;
    }
    newShardSizes.put(sid, size);
  }
}

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

.build();
String maybeShadowIndicator = IndexMetaData.isIndexUsingShadowReplicas(indexMetaData.getSettings()) ? "s" : "";
logger.info("[{}] creating index, cause [{}], templates {}, shards [{}]/[{}{}], mappings {}",
    request.index(), request.cause(), templateNames, indexMetaData.getNumberOfShards(),

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

.build();
String maybeShadowIndicator = IndexMetaData.isIndexUsingShadowReplicas(indexMetaData.getSettings()) ? "s" : "";
logger.info("[{}] creating index, cause [{}], templates {}, shards [{}]/[{}{}], mappings {}",
    request.index(), request.cause(), templateNames, indexMetaData.getNumberOfShards(),

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

if (IndexMetaData.isIndexUsingShadowReplicas(index.getSettings())) {
  routingNodes.reinitShadowPrimary(candidate);
  changed = true;

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

settings.get(SETTING_NUMBER_OF_SHARDS),
settings.get(SETTING_NUMBER_OF_REPLICAS),
IndexMetaData.isIndexUsingShadowReplicas(settings) ? "s" : "");

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

assert activeReplica == null || IndexMetaData.isIndexUsingShadowReplicas(indexMetaData.getSettings()) :
  "initializing primary [" + failedShard + "] with active replicas [" + activeReplica + "] only expected when " +
    "using shadow replicas";

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

@Override
protected void resolveRequest(ClusterState state, InternalRequest request) {
  IndexMetaData indexMeta = state.getMetaData().index(request.concreteIndex());
  if (request.request().realtime && // if the realtime flag is set
      request.request().preference() == null && // the preference flag is not already set
      indexMeta != null && // and we have the index
      IndexMetaData.isIndexUsingShadowReplicas(indexMeta.getSettings())) { // and the index uses shadow replicas
    // set the preference for the request to use "_primary" automatically
    request.request().preference(Preference.PRIMARY.type());
  }
  // update the routing (request#index here is possibly an alias)
  request.request().routing(state.metaData().resolveIndexRouting(request.request().parent(), request.request().routing(), request.request().index()));
  // Fail fast on the node that received the request.
  if (request.request().routing() == null && state.getMetaData().routingRequired(request.concreteIndex(), request.request().type())) {
    throw new RoutingMissingException(request.concreteIndex(), request.request().type(), request.request().id());
  }
}

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

this.indexMetaData = indexMetaData;
numberOfShards = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1);
isShadowReplicaIndex = IndexMetaData.isIndexUsingShadowReplicas(settings);

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

@Override
protected void resolveRequest(ClusterState state, InternalRequest request) {
  if (request.request().realtime == null) {
    request.request().realtime = this.realtime;
  }
  IndexMetaData indexMeta = state.getMetaData().index(request.concreteIndex());
  if (request.request().realtime && // if the realtime flag is set
      request.request().preference() == null && // the preference flag is not already set
      indexMeta != null && // and we have the index
      IndexMetaData.isIndexUsingShadowReplicas(indexMeta.getSettings())) { // and the index uses shadow replicas
    // set the preference for the request to use "_primary" automatically
    request.request().preference(Preference.PRIMARY.type());
  }
  // update the routing (request#index here is possibly an alias)
  request.request().routing(state.metaData().resolveIndexRouting(request.request().routing(), request.request().index()));
  // Fail fast on the node that received the request.
  if (request.request().routing() == null && state.getMetaData().routingRequired(request.concreteIndex(), request.request().type())) {
    throw new RoutingMissingException(request.concreteIndex(), request.request().type(), request.request().id());
  }
}

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

boolean usesShadowReplicas = false;
if (indexMeta != null) {
  usesShadowReplicas = IndexMetaData.isIndexUsingShadowReplicas(indexMeta.getSettings());

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

boolean usesShadowReplicas = false;
if (indexMeta != null) {
  usesShadowReplicas = IndexMetaData.isIndexUsingShadowReplicas(indexMeta.getSettings());

相关文章

微信公众号

最新文章

更多

IndexMetaData类方法