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

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

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

IndicesService.removeIndex介绍

[英]Removes the given index from this service and releases all associated resources. Persistent parts of the index like the shards files, state and transaction logs are kept around in the case of a disaster recovery.
[中]从此服务中删除给定索引并释放所有关联资源。索引的持久部分(如碎片文件、状态和事务日志)将保留在灾难恢复中。

代码示例

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

@Override
protected void doStop() {
  ExecutorService indicesStopExecutor =
    Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown"));
  // Copy indices because we modify it asynchronously in the body of the loop
  final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet());
  final CountDownLatch latch = new CountDownLatch(indices.size());
  for (final Index index : indices) {
    indicesStopExecutor.execute(() -> {
      try {
        removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown");
      } finally {
        latch.countDown();
      }
    });
  }
  try {
    if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) {
     logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds());
    }
  } catch (InterruptedException e) {
    // ignore
  } finally {
    indicesStopExecutor.shutdown();
  }
}

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

indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");

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

indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");

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

/**
 * Deletes the given index. Persistent parts of the index
 * like the shards files, state and transaction logs are removed once all resources are released.
 *
 * Equivalent to {@link #removeIndex(String, String)} but fires
 * different lifecycle events to ensure pending resources of this index are immediately removed.
 * @param index the index to delete
 * @param reason the high level reason causing this delete
 */
public void deleteIndex(String index, String reason) throws IOException {
  removeIndex(index, reason, true);
}

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

} finally {
  for (Index index : indicesToClose) {
    indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for alias processing");

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

if (createdIndex != null) {
  indicesService.removeIndex(createdIndex, removalReason, removalExtraInfo);

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

private void removeIndex(String index, String reason) {
  try {
    indicesService.removeIndex(index, reason);
  } catch (Throwable e) {
    logger.warn("failed to clean index ({})", e, reason);
  }
}

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

@Override
protected void doStop() {
  ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown"));
  // Copy indices because we modify it asynchronously in the body of the loop
  final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet());
  final CountDownLatch latch = new CountDownLatch(indices.size());
  for (final Index index : indices) {
    indicesStopExecutor.execute(() -> {
      try {
        removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown");
      } finally {
        latch.countDown();
      }
    });
  }
  try {
    if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) {
     logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds());
    }
  } catch (InterruptedException e) {
    // ignore
  } finally {
    indicesStopExecutor.shutdown();
  }
}

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

@Override
protected void doStop() {
  ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown"));
  // Copy indices because we modify it asynchronously in the body of the loop
  final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet());
  final CountDownLatch latch = new CountDownLatch(indices.size());
  for (final Index index : indices) {
    indicesStopExecutor.execute(() -> {
      try {
        removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown");
      } finally {
        latch.countDown();
      }
    });
  }
  try {
    if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) {
     logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds());
    }
  } catch (InterruptedException e) {
    // ignore
  } finally {
    indicesStopExecutor.shutdown();
  }
}

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

@Override
protected void doStop() {
  ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown"));
  // Copy indices because we modify it asynchronously in the body of the loop
  final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet());
  final CountDownLatch latch = new CountDownLatch(indices.size());
  for (final Index index : indices) {
    indicesStopExecutor.execute(() -> {
      try {
        removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown");
      } finally {
        latch.countDown();
      }
    });
  }
  try {
    if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) {
     logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds());
    }
  } catch (InterruptedException e) {
    // ignore
  } finally {
    indicesStopExecutor.shutdown();
  }
}

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

indicesService.removeIndex(temporaryIndexName, " created for parsing template mapping");

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

indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");

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

indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");

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

indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");

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

indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");

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

indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");

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

indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");

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

} finally {
  for (Index index : indicesToClose) {
    indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for alias processing");

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

} finally {
  for (String index : indicesToClose) {
    indicesService.removeIndex(index, "created for mapping processing");

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

private void removeIndex(String index, String reason, boolean delete) {
  try {
    final IndexService indexService;
    final Injector indexInjector;
    synchronized (this) {
      if (indices.containsKey(index) == false) {
        return;
      }
      logger.debug("[{}] closing ... (reason [{}])", index, reason);
      Map<String, IndexServiceInjectorPair> tmpMap = newHashMap(indices);
      IndexServiceInjectorPair remove = tmpMap.remove(index);
      indexService = remove.getIndexService();
      indexInjector = remove.getInjector();
      indices = ImmutableMap.copyOf(tmpMap);
    }
    indicesLifecycle.beforeIndexClosed(indexService);
    if (delete) {
      indicesLifecycle.beforeIndexDeleted(indexService);
    }
    IOUtils.close(Iterables.transform(pluginsService.indexServices(), new Function<Class<? extends Closeable>, Closeable>() {
      @Override
      public Closeable apply(Class<? extends Closeable> input) {
        return indexInjector.getInstance(input);
      }
    }));
    logger.debug("[{}] closing index service (reason [{}])", index, reason);
    indexService.close(reason, delete);

相关文章

微信公众号

最新文章

更多