当前位置: 首页>>代码示例>>Java>>正文


Java Lifecycle类代码示例

本文整理汇总了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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:NettyTransportMultiPortTests.java

示例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");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ZenDiscovery.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ZenDiscovery.java

示例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);
        }

    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:ZenDiscovery.java

示例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);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:TcpTransport.java

示例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);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:MessageChannelHandler.java

示例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;
		}
	}
}
 
开发者ID:swoop-inc,项目名称:elasticsearch-statsd-plugin,代码行数:30,代码来源:StatsdService.java

示例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;
        }
    }
}
 
开发者ID:spinscale,项目名称:elasticsearch-graphite-plugin,代码行数:28,代码来源:GraphiteService.java

示例9: lifecycleState

import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
@Override
public Lifecycle.State lifecycleState() {
    return transport.lifecycleState();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:MockTransportService.java

示例10: lifecycleState

import org.elasticsearch.common.component.Lifecycle; //导入依赖的package包/类
@Override
public Lifecycle.State lifecycleState() {
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:CapturingTransport.java

示例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");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:AbstractLifecycleRunnable.java


注:本文中的org.elasticsearch.common.component.Lifecycle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。