本文整理了Java中org.elasticsearch.common.component.Lifecycle.stoppedOrClosed()
方法的一些代码示例,展示了Lifecycle.stoppedOrClosed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lifecycle.stoppedOrClosed()
方法的具体详情如下:
包路径:org.elasticsearch.common.component.Lifecycle
类名称:Lifecycle
方法名:stoppedOrClosed
暂无
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* {@inheritDoc}
* <p>
* This invokes {@link #doRunInLifecycle()} <em>only</em> if the {@link #lifecycle} is not stopped or closed. Otherwise it exits
* immediately.
*/
@Override
protected final void doRun() throws Exception {
// prevent execution if the service is stopped
if (lifecycle.stoppedOrClosed()) {
logger.trace("lifecycle is stopping. exiting");
return;
}
doRunInLifecycle();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* {@inheritDoc}
* <p>
* This overrides the default behavior of {@code onAfter} to add the caveat that it only runs if the {@link #lifecycle} is <em>not</em>
* stopped or closed.
* <p>
* Note: this does not guarantee that it won't be stopped concurrently as it invokes {@link #onAfterInLifecycle()},
* but it's a solid attempt at preventing it. For those that use this for rescheduling purposes, the next invocation would be
* effectively cancelled immediately if that's the case.
*
* @see #onAfterInLifecycle()
*/
@Override
public final void onAfter() {
if (lifecycle.stoppedOrClosed() == false) {
onAfterInLifecycle();
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void run() {
if (future != null && future.isCancelled()) {
return;
}
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
} else {
listener.onTimeout(this.timeout);
}
// note, we rely on the listener to remove itself in case of timeout if needed
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
void validateAndConnectIfNeeded(DiscoveryNode node) {
assert nodeLocks.isHeldByCurrentThread(node) : "validateAndConnectIfNeeded must be called under lock";
if (lifecycle.stoppedOrClosed() ||
nodes.containsKey(node) == false) { // we double check existence of node since connectToNode might take time...
// nothing to do
} else {
try {
// connecting to an already connected node is a noop
transportService.connectToNode(node);
nodes.put(node, 0);
} catch (Exception e) {
Integer nodeFailureCount = nodes.get(node);
assert nodeFailureCount != null : node + " didn't have a counter in nodes map";
nodeFailureCount = nodeFailureCount + 1;
// log every 6th failure
if ((nodeFailureCount % 6) == 1) {
final int finalNodeFailureCount = nodeFailureCount;
logger.warn(() -> new ParameterizedMessage(
"failed to connect to node {} (tried [{}] times)", node, finalNodeFailureCount), e);
}
nodes.put(node, nodeFailureCount);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
return;
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
} else {
代码示例来源:origin: org.elasticsearch/elasticsearch
if (!lifecycle.stoppedOrClosed()) {
throw e;
代码示例来源: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: apache/servicemix-bundles
@Override
public void onFailure(Exception e) {
if (lifecycle.stoppedOrClosed()) {
logger.trace("failed to send ping transport message", e);
} else {
logger.warn("failed to send ping transport message", e);
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public void onFailure(Exception e) {
if (lifecycle.stoppedOrClosed()) {
logger.trace("failed to send ping transport message", e);
} else {
logger.warn("failed to send ping transport message", e);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if (lifecycle.stoppedOrClosed()) {
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void clusterChanged(final ClusterChangedEvent event) {
if (lifecycle.stoppedOrClosed()) {
return;
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* {@inheritDoc}
* <p>
* This invokes {@link #doRunInLifecycle()} <em>only</em> if the {@link #lifecycle} is not stopped or closed. Otherwise it exits
* immediately.
*/
@Override
protected final void doRun() throws Exception {
// prevent execution if the service is stopped
if (lifecycle.stoppedOrClosed()) {
logger.trace("lifecycle is stopping. exiting");
return;
}
doRunInLifecycle();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* {@inheritDoc}
* <p>
* This invokes {@link #doRunInLifecycle()} <em>only</em> if the {@link #lifecycle} is not stopped or closed. Otherwise it exits
* immediately.
*/
@Override
protected final void doRun() throws Exception {
// prevent execution if the service is stopped
if (lifecycle.stoppedOrClosed()) {
logger.trace("lifecycle is stopping. exiting");
return;
}
doRunInLifecycle();
}
代码示例来源:origin: apache/servicemix-bundles
/**
* {@inheritDoc}
* <p>
* This invokes {@link #doRunInLifecycle()} <em>only</em> if the {@link #lifecycle} is not stopped or closed. Otherwise it exits
* immediately.
*/
@Override
protected final void doRun() throws Exception {
// prevent execution if the service is stopped
if (lifecycle.stoppedOrClosed()) {
logger.trace("lifecycle is stopping. exiting");
return;
}
doRunInLifecycle();
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* {@inheritDoc}
* <p>
* This overrides the default behavior of {@code onAfter} to add the caveat that it only runs if the {@link #lifecycle} is <em>not</em>
* stopped or closed.
* <p>
* Note: this does not guarantee that it won't be stopped concurrently as it invokes {@link #onAfterInLifecycle()},
* but it's a solid attempt at preventing it. For those that use this for rescheduling purposes, the next invocation would be
* effectively cancelled immediately if that's the case.
*
* @see #onAfterInLifecycle()
*/
@Override
public final void onAfter() {
if (lifecycle.stoppedOrClosed() == false) {
onAfterInLifecycle();
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public void run() {
if (future != null && future.isCancelled()) {
return;
}
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
} else {
listener.onTimeout(this.timeout);
}
// note, we rely on the listener to remove itself in case of timeout if needed
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public void run() {
if (future != null && future.isCancelled()) {
return;
}
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
} else {
listener.onTimeout(this.timeout);
}
// note, we rely on the listener to remove itself in case of timeout if needed
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void run() {
if (future != null && future.isCancelled()) {
return;
}
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
} else {
listener.onTimeout(this.timeout);
}
// note, we rely on the listener to remove itself in case of timeout if needed
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public void run() {
if (future != null && future.isCancelled()) {
return;
}
if (lifecycle.stoppedOrClosed()) {
listener.onClose();
} else {
listener.onTimeout(this.timeout);
}
// note, we rely on the listener to remove itself in case of timeout if needed
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void onFailure(Throwable t) {
if (lifecycle.stoppedOrClosed()) {
logger.trace("failed to send ping transport message", t);
} else {
logger.warn("failed to send ping transport message", t);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!