org.elasticsearch.indices.IndicesService.canDeleteShardContent()方法的使用及代码示例

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

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

IndicesService.canDeleteShardContent介绍

[英]Returns true iff the shards content for the given shard can be deleted. This method will return false if:

  • if the shard is still allocated / active on this node
  • if for instance if the shard is located on shared and should not be deleted
  • if the shards data locations do not exists
    [中]如果可以删除给定碎片的碎片内容,则返回true。如果出现以下情况,此方法将返回false
    *如果此节点上的碎片仍被分配/激活
    *例如,如果碎片位于共享磁盘上,则不应删除
    *如果碎片数据位置不存在

代码示例

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

ShardDeletionCheckResult shardDeletionCheckResult = canDeleteShardContent(shardId, indexSettings);
if (shardDeletionCheckResult != ShardDeletionCheckResult.FOLDER_FOUND_CAN_DELETE) {
  throw new IllegalStateException("Can't delete shard " + shardId + " (cause: " + shardDeletionCheckResult + ")");

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

indicesService.canDeleteShardContent(shardId, indexSettings);
switch (shardDeletionCheckResult) {
  case FOLDER_FOUND_CAN_DELETE:

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

/**
 * Returns <code>true</code> iff the shards content for the given shard can be deleted.
 * This method will return <code>false</code> if:
 * <ul>
 *     <li>if the shard is still allocated / active on this node</li>
 *     <li>if for instance if the shard is located on shared and should not be deleted</li>
 *     <li>if the shards data locations do not exists</li>
 * </ul>
 *
 * @param shardId the shard to delete.
 * @param metaData the shards index metadata. This is required to access the indexes settings etc.
 */
public boolean canDeleteShardContent(ShardId shardId, IndexMetaData metaData) {
  // we need the metadata here since we have to build the complete settings
  // to decide where the shard content lives. In the future we might even need more info here ie. for shadow replicas
  // The plan was to make it harder to miss-use and ask for metadata instead of simple settings
  assert shardId.getIndex().equals(metaData.getIndex());
  final Settings indexSettings = buildIndexSettings(metaData);
  return canDeleteShardContent(shardId, indexSettings);
}

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

ShardDeletionCheckResult shardDeletionCheckResult = canDeleteShardContent(shardId, indexSettings);
if (shardDeletionCheckResult != ShardDeletionCheckResult.FOLDER_FOUND_CAN_DELETE) {
  throw new IllegalStateException("Can't delete shard " + shardId + " (cause: " + shardDeletionCheckResult + ")");

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

ShardDeletionCheckResult shardDeletionCheckResult = canDeleteShardContent(shardId, indexSettings);
if (shardDeletionCheckResult != ShardDeletionCheckResult.FOLDER_FOUND_CAN_DELETE) {
  throw new IllegalStateException("Can't delete shard " + shardId + " (cause: " + shardDeletionCheckResult + ")");

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

indexSettings = indexService.getIndexSettings();
IndicesService.ShardDeletionCheckResult shardDeletionCheckResult = indicesService.canDeleteShardContent(shardId, indexSettings);
switch (shardDeletionCheckResult) {
  case FOLDER_FOUND_CAN_DELETE:

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

indexSettings = indexService.getIndexSettings();
IndicesService.ShardDeletionCheckResult shardDeletionCheckResult = indicesService.canDeleteShardContent(shardId, indexSettings);
switch (shardDeletionCheckResult) {
  case FOLDER_FOUND_CAN_DELETE:

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

indexSettings = indexService.getIndexSettings();
IndicesService.ShardDeletionCheckResult shardDeletionCheckResult = indicesService.canDeleteShardContent(shardId, indexSettings);
switch (shardDeletionCheckResult) {
  case FOLDER_FOUND_CAN_DELETE:

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

if (canDeleteShardContent(shardId, indexSettings) == false) {
  throw new IllegalStateException("Can't delete shard " + shardId);

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

static class OldShardsStats implements IndexEventListener {
  final SearchStats searchStats = new SearchStats();
  final GetStats getStats = new GetStats();
  final IndexingStats indexingStats = new IndexingStats();
  final MergeStats mergeStats = new MergeStats();
  final RefreshStats refreshStats = new RefreshStats();
  final FlushStats flushStats = new FlushStats();
  final RecoveryStats recoveryStats = new RecoveryStats();
  @Override
  public synchronized void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, Settings indexSettings) {
    if (indexShard != null) {
      getStats.addTotals(indexShard.getStats());
      indexingStats.addTotals(indexShard.indexingStats());
      searchStats.addTotals(indexShard.searchStats());
      mergeStats.addTotals(indexShard.mergeStats());
      refreshStats.addTotals(indexShard.refreshStats());
      flushStats.addTotals(indexShard.flushStats());
      recoveryStats.addTotals(indexShard.recoveryStats());
    }
  }
}

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

@Override
public void clusterChanged(ClusterChangedEvent event) {
  if (!event.routingTableChanged()) {
    return;
  }
  if (event.state().blocks().disableStatePersistence()) {
    return;
  }
  for (IndexRoutingTable indexRoutingTable : event.state().routingTable()) {
    // Note, closed indices will not have any routing information, so won't be deleted
    for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
      if (shardCanBeDeleted(event.state(), indexShardRoutingTable)) {
        ShardId shardId = indexShardRoutingTable.shardId();
        if (indicesService.canDeleteShardContent(shardId, event.state().getMetaData().index(shardId.getIndex()))) {
          deleteShardIfExistElseWhere(event.state(), indexShardRoutingTable);
        }
      }
    }
  }
}

相关文章

微信公众号

最新文章

更多