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

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

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

IndexMetaData.getInitialRecoveryFilters介绍

暂无

代码示例

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

@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
  if (shardRouting.unassigned()) {
    // only for unassigned - we filter allocation right after the index creation ie. for shard shrinking etc. to ensure
    // that once it has been allocated post API the replicas can be allocated elsewhere without user interaction
    // this is a setting that can only be set within the system!
    IndexMetaData indexMd = allocation.metaData().getIndexSafe(shardRouting.index());
    DiscoveryNodeFilters initialRecoveryFilters = indexMd.getInitialRecoveryFilters();
    if (initialRecoveryFilters != null  &&
      INITIAL_RECOVERY_TYPES.contains(shardRouting.recoverySource().getType()) &&
      initialRecoveryFilters.match(node.node()) == false) {
      String explanation = (shardRouting.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) ?
        "initial allocation of the shrunken index is only allowed on nodes [%s] that hold a copy of every shard in the index" :
        "initial allocation of the index is only allowed on nodes [%s]";
      return allocation.decision(Decision.NO, NAME, explanation, initialRecoveryFilters);
    }
  }
  return shouldFilter(shardRouting, node, allocation);
}

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

@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
  if (shardRouting.unassigned()) {
    // only for unassigned - we filter allocation right after the index creation ie. for shard shrinking etc. to ensure
    // that once it has been allocated post API the replicas can be allocated elsewhere without user interaction
    // this is a setting that can only be set within the system!
    IndexMetaData indexMd = allocation.metaData().getIndexSafe(shardRouting.index());
    DiscoveryNodeFilters initialRecoveryFilters = indexMd.getInitialRecoveryFilters();
    if (initialRecoveryFilters != null  &&
      INITIAL_RECOVERY_TYPES.contains(shardRouting.recoverySource().getType()) &&
      initialRecoveryFilters.match(node.node()) == false) {
      String explanation = (shardRouting.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) ?
        "initial allocation of the shrunken index is only allowed on nodes [%s] that hold a copy of every shard in the index" :
        "initial allocation of the index is only allowed on nodes [%s]";
      return allocation.decision(Decision.NO, NAME, explanation, initialRecoveryFilters);
    }
  }
  return shouldFilter(shardRouting, node, allocation);
}

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

@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
  if (shardRouting.unassigned()) {
    // only for unassigned - we filter allocation right after the index creation ie. for shard shrinking etc. to ensure
    // that once it has been allocated post API the replicas can be allocated elsewhere without user interaction
    // this is a setting that can only be set within the system!
    IndexMetaData indexMd = allocation.metaData().getIndexSafe(shardRouting.index());
    DiscoveryNodeFilters initialRecoveryFilters = indexMd.getInitialRecoveryFilters();
    if (initialRecoveryFilters != null  &&
      INITIAL_RECOVERY_TYPES.contains(shardRouting.recoverySource().getType()) &&
      initialRecoveryFilters.match(node.node()) == false) {
      String explanation = (shardRouting.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) ?
        "initial allocation of the shrunken index is only allowed on nodes [%s] that hold a copy of every shard in the index" :
        "initial allocation of the index is only allowed on nodes [%s]";
      return allocation.decision(Decision.NO, NAME, explanation, initialRecoveryFilters);
    }
  }
  return shouldFilter(shardRouting, node, allocation);
}

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

@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
  if (shardRouting.unassigned()) {
    // only for unassigned - we filter allocation right after the index creation ie. for shard shrinking etc. to ensure
    // that once it has been allocated post API the replicas can be allocated elsewhere without user interaction
    // this is a setting that can only be set within the system!
    IndexMetaData indexMd = allocation.metaData().getIndexSafe(shardRouting.index());
    DiscoveryNodeFilters initialRecoveryFilters = indexMd.getInitialRecoveryFilters();
    if (initialRecoveryFilters != null  &&
      INITIAL_RECOVERY_TYPES.contains(shardRouting.recoverySource().getType()) &&
      initialRecoveryFilters.match(node.node()) == false) {
      String explanation = (shardRouting.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) ?
        "initial allocation of the shrunken index is only allowed on nodes [%s] that hold a copy of every shard in the index" :
        "initial allocation of the index is only allowed on nodes [%s]";
      return allocation.decision(Decision.NO, NAME, explanation, initialRecoveryFilters);
    }
  }
  return shouldFilter(shardRouting, node, allocation);
}

相关文章

微信公众号

最新文章

更多

IndexMetaData类方法