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


Java DiscoveryNodes.masterNode方法代码示例

本文整理汇总了Java中org.elasticsearch.cluster.node.DiscoveryNodes.masterNode方法的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryNodes.masterNode方法的具体用法?Java DiscoveryNodes.masterNode怎么用?Java DiscoveryNodes.masterNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.cluster.node.DiscoveryNodes的用法示例。


在下文中一共展示了DiscoveryNodes.masterNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nodeMappingRefresh

import org.elasticsearch.cluster.node.DiscoveryNodes; //导入方法依赖的package包/类
public void nodeMappingRefresh(final ClusterState state, final NodeMappingRefreshRequest request) {
    final DiscoveryNodes nodes = state.nodes();
    if (nodes.masterNode() == null) {
        logger.warn("can't send mapping refresh for [{}][{}], no master known.", request.index(), Strings.arrayToCommaDelimitedString(request.types()));
        return;
    }
    transportService.sendRequest(nodes.masterNode(), ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:NodeMappingRefreshAction.java

示例2: createPingResponse

import org.elasticsearch.cluster.node.DiscoveryNodes; //导入方法依赖的package包/类
private PingResponse createPingResponse(DiscoveryNodes discoNodes) {
    return new PingResponse(discoNodes.localNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:UnicastZenPing.java

示例3: doStart

import org.elasticsearch.cluster.node.DiscoveryNodes; //导入方法依赖的package包/类
protected void doStart() {
    final ClusterState clusterState = observer.observedState();
    final DiscoveryNodes nodes = clusterState.nodes();
    if (nodes.localNodeMaster() || localExecute(request)) {
        // check for block, if blocked, retry, else, execute locally
        final ClusterBlockException blockException = checkBlock(request, clusterState);
        if (blockException != null) {
            if (!blockException.retryable()) {
                listener.onFailure(blockException);
            } else {
                logger.trace("can't execute due to a cluster block, retrying", blockException);
                retry(blockException, retryableOrNoBlockPredicate);
            }
        } else {
            final ActionListener<Response> delegate = new ActionListener<Response>() {
                @Override
                public void onResponse(Response response) {
                    listener.onResponse(response);
                }

                @Override
                public void onFailure(Throwable t) {
                    if (t instanceof NotMasterException) {
                        logger.debug("master could not publish cluster state or stepped down before publishing action [{}], scheduling a retry", t, actionName);
                        retry(t, masterNodeChangedPredicate);
                    } else {
                        listener.onFailure(t);
                    }
                }
            };
            taskManager.registerChildTask(task, nodes.getLocalNodeId());
            threadPool.executor(executor).execute(new ActionRunnable(delegate) {
                @Override
                protected void doRun() throws Exception {
                    masterOperation(task, request, clusterService.state(), delegate);
                }
            });
        }
    } else {
        if (nodes.masterNode() == null) {
            logger.debug("no known master node, scheduling a retry");
            retry(null, masterNodeChangedPredicate);
        } else {
            taskManager.registerChildTask(task, nodes.masterNode().getId());
            transportService.sendRequest(nodes.masterNode(), actionName, request, new ActionListenerResponseHandler<Response>(listener) {
                @Override
                public Response newInstance() {
                    return newResponse();
                }

                @Override
                public void handleException(final TransportException exp) {
                    Throwable cause = exp.unwrapCause();
                    if (cause instanceof ConnectTransportException) {
                        // we want to retry here a bit to see if a new master is elected
                        logger.debug("connection exception while trying to forward request with action name [{}] to master node [{}], scheduling a retry. Error: [{}]",
                                actionName, nodes.masterNode(), exp.getDetailedMessage());
                        retry(cause, masterNodeChangedPredicate);
                    } else {
                        listener.onFailure(exp);
                    }
                }
            });
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:67,代码来源:TransportMasterNodeAction.java


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