• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Lifecycle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KDFFeedbackParameters类代码示例发布时间:2022-05-22
下一篇:
Java MySqlUnionQuery类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap