org.elasticsearch.common.component.Lifecycle.started()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(93)

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

Lifecycle.started介绍

[英]Returns true if the state is started.
[中]如果状态已启动,则返回true。

代码示例

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

/**
 * Checks if changes (adding / removing) indices, shards and so on are allowed.
 *
 * @throws IllegalStateException if no changes allowed.
 */
private void ensureChangesAllowed() {
  if (lifecycle.started() == false) {
    throw new IllegalStateException("Can't make changes to indices service, node is closed");
  }
}

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

/**
 * Ensures this transport is still started / open
 *
 * @throws IllegalStateException if the transport is not started / open
 */
protected final void ensureOpen() {
  if (lifecycle.started() == false) {
    throw new IllegalStateException("transport has been stopped");
  }
}

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

@Override
public void setInitialState(ClusterState initialState) {
  if (lifecycle.started()) {
    throw new IllegalStateException("can't set initial state when started");
  }
  assert state.get() == null : "state is already set";
  state.set(initialState);
}

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

@Override
  public void onAfter() {
    if (lifecycle.started()) {
      backgroundFuture = threadPool.schedule(reconnectInterval, ThreadPool.Names.GENERIC, this);
    }
  }
}

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

@Override
public synchronized void startInitialJoin() {
  if (lifecycle.started() == false) {
    throw new IllegalStateException("can't start initial join when not started");
  }
  // apply a fresh cluster state just so that state recovery gets triggered by GatewayService
  // TODO: give discovery module control over GatewayService
  clusterState = ClusterState.builder(clusterState).build();
  clusterApplier.onNewClusterState("single-node-start-initial-join", () -> clusterState, (source, e) -> {});
}

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

@Override
public void close() {
  if (lifecycle.started()) {
    stop();
  }
  if (!lifecycle.canMoveToClosed()) {
    return;
  }
  for (LifecycleListener listener : listeners) {
    listener.beforeClose();
  }
  lifecycle.moveToClosed();
  try {
    doClose();
  } catch (IOException e) {
    // TODO: we need to separate out closing (ie shutting down) services, vs releasing runtime transient
    // structures. Shutting down services should use IOUtils.close
    logger.warn("failed to close " + getClass().getName(), e);
  }
  for (LifecycleListener listener : listeners) {
    listener.afterClose();
  }
}

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

final Map<T, ClusterStateTaskListener> tasks, final ClusterStateTaskConfig config,
                  final ClusterStateTaskExecutor<T> executor) {
if (!lifecycle.started()) {
  return;

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

@Override
public synchronized void close() throws IOException {
  if (lifecycle.started()) {
    stop();

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

public void onException(TcpChannel channel, Exception e) {
  if (!lifecycle.started()) {

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

protected void runTask(UpdateTask task) {
  if (!lifecycle.started()) {
    logger.debug("processing [{}]: ignoring, cluster applier service not started", task.source);
    return;

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

protected void runTasks(TaskInputs taskInputs) {
  final String summary = taskInputs.summary;
  if (!lifecycle.started()) {
    logger.debug("processing [{}]: ignoring, master service not started", summary);
    return;

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

private void submitStateUpdateTask(final String source, final ClusterStateTaskConfig config,
                  final Function<ClusterState, ClusterState> executor,
                  final ClusterApplyListener listener) {
  if (!lifecycle.started()) {
    return;
  }
  try {
    UpdateTask updateTask = new UpdateTask(config.priority(), source, new SafeClusterApplyListener(listener, logger), executor);
    if (config.timeout() != null) {
      threadPoolExecutor.execute(updateTask, config.timeout(),
        () -> threadPool.generic().execute(
          () -> listener.onFailure(source, new ProcessClusterEventTimeoutException(config.timeout(), source))));
    } else {
      threadPoolExecutor.execute(updateTask);
    }
  } catch (EsRejectedExecutionException e) {
    // ignore cases where we are shutting down..., there is really nothing interesting
    // to be done here...
    if (!lifecycle.stoppedOrClosed()) {
      throw e;
    }
  }
}

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

/**
 * maintains single lazy instance of {@link BlobStore}
 */
protected BlobStore blobStore() {
  assertSnapshotOrGenericThread();
  BlobStore store = blobStore.get();
  if (store == null) {
    synchronized (lock) {
      store = blobStore.get();
      if (store == null) {
        if (lifecycle.started() == false) {
          throw new RepositoryException(metadata.name(), "repository is not in started state");
        }
        try {
          store = createBlobStore();
        } catch (RepositoryException e) {
          throw e;
        } catch (Exception e) {
          throw new RepositoryException(metadata.name(), "cannot create blob store" , e);
        }
        blobStore.set(store);
      }
    }
  }
  return store;
}

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

/**
 * Checks if changes (adding / removing) indices, shards and so on are allowed.
 *
 * @throws IllegalStateException if no changes allowed.
 */
private void ensureChangesAllowed() {
  if (lifecycle.started() == false) {
    throw new IllegalStateException("Can't make changes to indices service, node is closed");
  }
}

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

private void ensureOpen() {
  if (lifecycle.started() == false) {
    throw new IllegalStateException("connection manager is closed");
  }
}

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

@Override
public void setInitialState(ClusterState initialState) {
  if (lifecycle.started()) {
    throw new IllegalStateException("can't set initial state when started");
  }
  assert state.get() == null : "state is already set";
  state.set(initialState);
}

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

@Override
public synchronized void applyClusterState(final ClusterChangedEvent event) {
  if (!lifecycle.started()) {
    return;
  }
  final ClusterState state = event.state();
  // we need to clean the shards and indices we have on this node, since we
  // are going to recover them again once state persistence is disabled (no master / not recovered)
  // TODO: feels hacky, a block disables state persistence, and then we clean the allocated shards, maybe another flag in blocks?
  if (state.blocks().disableStatePersistence()) {
    for (AllocatedIndex<? extends Shard> indexService : indicesService) {
      indicesService.removeIndex(indexService.index(), NO_LONGER_ASSIGNED,
        "cleaning index (disabled block persistence)"); // also cleans shards
    }
    return;
  }
  updateFailedShardsCache(state);
  deleteIndices(event); // also deletes shards of deleted indices
  removeUnallocatedIndices(event); // also removes shards of removed indices
  failMissingShards(state);
  removeShards(state);   // removes any local shards that doesn't match what the master expects
  updateIndices(event); // can also fail shards, but these are then guaranteed to be in failedShardsCache
  createIndices(state);
  createOrUpdateShards(state);
}

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

/**
 * Adds an initial block to be set on the first cluster state created.
 */
public synchronized void addInitialStateBlock(ClusterBlock block) throws IllegalStateException {
  if (lifecycle.started()) {
    throw new IllegalStateException("can't set initial block when started");
  }
  initialBlocks.addGlobalBlock(block);
}

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

@Override
  public void onAfter() {
    if (lifecycle.started()) {
      backgroundFuture = threadPool.schedule(reconnectInterval, ThreadPool.Names.GENERIC, this);
    }
  }
}

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

@Override
public synchronized void startInitialJoin() {
  if (lifecycle.started() == false) {
    throw new IllegalStateException("can't start initial join when not started");
  }
  // apply a fresh cluster state just so that state recovery gets triggered by GatewayService
  // TODO: give discovery module control over GatewayService
  clusterState = ClusterState.builder(clusterState).build();
  clusterApplier.onNewClusterState("single-node-start-initial-join", () -> clusterState, (source, e) -> {});
}

相关文章