本文整理汇总了Java中org.elasticsearch.common.component.Lifecycle类的典型用法代码示例。如果您正苦于以下问题:Java Lifecycle类的具体用法?Java Lifecycle怎么用?Java Lifecycle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lifecycle类属于org.elasticsearch.common.component包,在下文中一共展示了Lifecycle类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTransport
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
private TcpTransport<?> startTransport(Settings settings, ThreadPool threadPool) {
BigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
TcpTransport<?> transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()),
bigArrays, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService());
transport.start();
assertThat(transport.lifecycleState(), is(Lifecycle.State.STARTED));
return transport;
}
示例2: handleLeaveRequest
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
private void handleLeaveRequest(final DiscoveryNode node) {
if (lifecycleState() != Lifecycle.State.STARTED) {
// not started, ignore a node failure
return;
}
if (localNodeMaster()) {
removeNode(node, "zen-disco-node-left", "left");
} else if (node.equals(nodes().getMasterNode())) {
handleMasterGone(node, null, "shut_down");
}
}
示例3: handleNodeFailure
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
private void handleNodeFailure(final DiscoveryNode node, final String reason) {
if (lifecycleState() != Lifecycle.State.STARTED) {
// not started, ignore a node failure
return;
}
if (!localNodeMaster()) {
// nothing to do here...
return;
}
removeNode(node, "zen-disco-node-failed", reason);
}
示例4: handleMasterGone
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
private void handleMasterGone(final DiscoveryNode masterNode, final Throwable cause, final String reason) {
if (lifecycleState() != Lifecycle.State.STARTED) {
// not started, ignore a master failure
return;
}
if (localNodeMaster()) {
// we might get this on both a master telling us shutting down, and then the disconnect failure
return;
}
logger.info((Supplier<?>) () -> new ParameterizedMessage("master_left [{}], reason [{}]", masterNode, reason), cause);
clusterService.submitStateUpdateTask("master_failed (" + masterNode + ")", new LocalClusterUpdateTask(Priority.IMMEDIATE) {
@Override
public ClusterTasksResult<LocalClusterUpdateTask> execute(ClusterState currentState) {
if (!masterNode.equals(currentState.nodes().getMasterNode())) {
// master got switched on us, no need to send anything
return unchanged();
}
// flush any pending cluster states from old master, so it will not be set as master again
publishClusterState.pendingStatesQueue().failAllStatesAndClear(new ElasticsearchException("master left [{}]", reason));
return rejoin(currentState, "master left (reason = " + reason + ")");
}
@Override
public void onFailure(String source, Exception e) {
logger.error((Supplier<?>) () -> new ParameterizedMessage("unexpected failure during [{}]", source), e);
}
});
}
示例5: onFailure
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
@Override
public void onFailure(Exception e) {
if (lifecycleState() == Lifecycle.State.STARTED) {
// we can only send a response transport is started....
try {
transportChannel.sendResponse(e);
} catch (Exception inner) {
inner.addSuppressed(e);
logger.warn(
(Supplier<?>) () -> new ParameterizedMessage(
"Failed to send error message back to client for action [{}]", reg.getAction()), inner);
}
}
}
示例6: onFailure
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
@Override
public void onFailure(Throwable e) {
if (transport.lifecycleState() == Lifecycle.State.STARTED) {
// we can only send a response transport is started....
try {
transportChannel.sendResponse(e);
} catch (Throwable e1) {
logger.warn("Failed to send error message back to client for action [" + reg.getAction() + "]", e1);
logger.warn("Actual Exception", e);
}
}
}
示例7: run
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
public void run()
{
while (!closed) {
DiscoveryNode node = clusterService.localNode();
boolean isClusterStarted = clusterService.lifecycleState().equals(Lifecycle.State.STARTED);
if (isClusterStarted && node != null && node.isMasterNode()) {
NodeIndicesStats nodeIndicesStats = indicesService.stats(false);
CommonStatsFlags commonStatsFlags = new CommonStatsFlags().clear();
NodeStats nodeStats = nodeService.stats(commonStatsFlags, true, true, true, true, true, true, true, true);
List<IndexShard> indexShards = getIndexShards(indicesService);
StatsdReporter statsdReporter = new StatsdReporter(nodeIndicesStats, indexShards, nodeStats, statsdClient);
statsdReporter.run();
}
else {
if (node != null) {
logger.debug("[{}]/[{}] is not master node, not triggering update", node.getId(), node.getName());
}
}
try {
Thread.sleep(statsdRefreshInternal.millis());
}
catch (InterruptedException e1) {
continue;
}
}
}
示例8: run
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
public void run() {
while (!closed) {
DiscoveryNode node = clusterService.localNode();
boolean isClusterStarted = clusterService.lifecycleState().equals(Lifecycle.State.STARTED);
if (isClusterStarted && node != null && node.isMasterNode()) {
NodeIndicesStats nodeIndicesStats = indicesService.stats(false);
CommonStatsFlags commonStatsFlags = new CommonStatsFlags().clear();
NodeStats nodeStats = nodeService.stats(commonStatsFlags, true, true, true, true, true, true, true, true, true);
List<IndexShard> indexShards = getIndexShards(indicesService);
GraphiteReporter graphiteReporter = new GraphiteReporter(graphiteHost, graphitePort, graphitePrefix,
nodeIndicesStats, indexShards, nodeStats, graphiteInclusionRegex, graphiteExclusionRegex);
graphiteReporter.run();
} else {
if (node != null) {
logger.debug("[{}]/[{}] is not master node, not triggering update", node.getId(), node.getName());
}
}
try {
Thread.sleep(graphiteRefreshInternal.millis());
} catch (InterruptedException e1) {
continue;
}
}
}
示例9: lifecycleState
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
@Override
public Lifecycle.State lifecycleState() {
return transport.lifecycleState();
}
示例10: lifecycleState
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
@Override
public Lifecycle.State lifecycleState() {
return null;
}
示例11: AbstractLifecycleRunnable
import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
/**
* {@link AbstractLifecycleRunnable} must be aware of the actual {@code lifecycle} to react properly.
*
* @param lifecycle The lifecycle to react too
* @param logger The logger to use when logging
* @throws NullPointerException if any parameter is {@code null}
*/
public AbstractLifecycleRunnable(Lifecycle lifecycle, Logger logger) {
this.lifecycle = Objects.requireNonNull(lifecycle, "lifecycle must not be null");
this.logger = Objects.requireNonNull(logger, "logger must not be null");
}