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


Java DiscoveryNode.equals方法代码示例

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


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

示例1: handleTransportDisconnect

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
protected void handleTransportDisconnect(DiscoveryNode node) {
    synchronized (masterNodeMutex) {
        if (!node.equals(this.masterNode)) {
            return;
        }
        if (connectOnNetworkDisconnect) {
            try {
                transportService.connectToNode(node);
                // if all is well, make sure we restart the pinger
                if (masterPinger != null) {
                    masterPinger.stop();
                }
                this.masterPinger = new MasterPinger();
                // we use schedule with a 0 time value to run the pinger on the pool as it will run on later
                threadPool.schedule(TimeValue.timeValueMillis(0), ThreadPool.Names.SAME, masterPinger);
            } catch (Exception e) {
                logger.trace("[master] [{}] transport disconnected (with verified connect)", masterNode);
                notifyMasterFailure(masterNode, null, "transport disconnected (with verified connect)");
            }
        } else {
            logger.trace("[master] [{}] transport disconnected", node);
            notifyMasterFailure(node, null, "transport disconnected");
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MasterFaultDetection.java

示例2: updateNodesAndPing

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
/**
 * make sure that nodes in clusterState are pinged. Any pinging to nodes which are not
 * part of the cluster will be stopped
 */
public void updateNodesAndPing(ClusterState clusterState) {
    // remove any nodes we don't need, this will cause their FD to stop
    for (DiscoveryNode monitoredNode : nodesFD.keySet()) {
        if (!clusterState.nodes().nodeExists(monitoredNode)) {
            nodesFD.remove(monitoredNode);
        }
    }
    // add any missing nodes

    for (DiscoveryNode node : clusterState.nodes()) {
        if (node.equals(localNode)) {
            // no need to monitor the local node
            continue;
        }
        if (!nodesFD.containsKey(node)) {
            NodeFD fd = new NodeFD(node);
            // it's OK to overwrite an existing nodeFD - it will just stop and the new one will pick things up.
            nodesFD.put(node, fd);
            // we use schedule with a 0 time value to run the pinger on the pool as it will run on later
            threadPool.schedule(TimeValue.timeValueMillis(0), ThreadPool.Names.SAME, fd);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:NodesFaultDetection.java

示例3: onNodeAck

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public void onNodeAck(DiscoveryNode node, @Nullable Exception e) {
    if (!ackedTaskListener.mustAck(node)) {
        //we always wait for the master ack anyway
        if (!node.equals(nodes.getMasterNode())) {
            return;
        }
    }
    if (e == null) {
        logger.trace("ack received from node [{}], cluster_state update (version: {})", node, clusterStateVersion);
    } else {
        this.lastFailure = e;
        logger.debug(
            (Supplier<?>) () -> new ParameterizedMessage(
                "ack received from node [{}], cluster_state update (version: {})", node, clusterStateVersion),
            e);
    }

    if (countDown.countDown()) {
        logger.trace("all expected nodes acknowledged cluster_state update (version: {})", clusterStateVersion);
        FutureUtils.cancel(ackTimeoutCallback);
        ackedTaskListener.onAllNodesAcked(lastFailure);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ClusterService.java

示例4: handleTransportDisconnect

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
protected void handleTransportDisconnect(DiscoveryNode node) {
    synchronized (masterNodeMutex) {
        if (!node.equals(this.masterNode)) {
            return;
        }
        if (connectOnNetworkDisconnect) {
            try {
                transportService.connectToNode(node);
                // if all is well, make sure we restart the pinger
                if (masterPinger != null) {
                    masterPinger.stop();
                }
                this.masterPinger = new MasterPinger();
                // we use schedule with a 0 time value to run the pinger on the pool as it will run on later
                threadPool.schedule(TimeValue.timeValueMillis(0), ThreadPool.Names.SAME, masterPinger);
            } catch (Exception e) {
                logger.trace("[master] [{}] transport disconnected (with verified connect)", masterNode);
                notifyMasterFailure(masterNode, "transport disconnected (with verified connect)");
            }
        } else {
            logger.trace("[master] [{}] transport disconnected", node);
            notifyMasterFailure(node, "transport disconnected");
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:MasterFaultDetection.java

示例5: updateNodesAndPing

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
/**
 * make sure that nodes in clusterState are pinged. Any pinging to nodes which are not
 * part of the cluster will be stopped
 */
public void updateNodesAndPing(ClusterState clusterState) {
    // remove any nodes we don't need, this will cause their FD to stop
    for (DiscoveryNode monitoredNode : nodesFD.keySet()) {
        if (!clusterState.nodes().nodeExists(monitoredNode.id())) {
            nodesFD.remove(monitoredNode);
        }
    }
    // add any missing nodes

    for (DiscoveryNode node : clusterState.nodes()) {
        if (node.equals(localNode)) {
            // no need to monitor the local node
            continue;
        }
        if (!nodesFD.containsKey(node)) {
            NodeFD fd = new NodeFD(node);
            // it's OK to overwrite an existing nodeFD - it will just stop and the new one will pick things up.
            nodesFD.put(node, fd);
            // we use schedule with a 0 time value to run the pinger on the pool as it will run on later
            threadPool.schedule(TimeValue.timeValueMillis(0), ThreadPool.Names.SAME, fd);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:NodesFaultDetection.java

示例6: onNodeAck

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public void onNodeAck(DiscoveryNode node, @Nullable Throwable t) {
    if (!ackedTaskListener.mustAck(node)) {
        //we always wait for the master ack anyway
        if (!node.equals(nodes.masterNode())) {
            return;
        }
    }
    if (t == null) {
        logger.trace("ack received from node [{}], cluster_state update (version: {})", node, clusterStateVersion);
    } else {
        this.lastFailure = t;
        logger.debug("ack received from node [{}], cluster_state update (version: {})", t, node, clusterStateVersion);
    }

    if (countDown.countDown()) {
        logger.trace("all expected nodes acknowledged cluster_state update (version: {})", clusterStateVersion);
        FutureUtils.cancel(ackTimeoutCallback);
        ackedTaskListener.onAllNodesAcked(lastFailure);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:InternalClusterService.java

示例7: handleLeaveRequest

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的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

示例8: testTieBreakActiveMasters

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void testTieBreakActiveMasters() {
    List<DiscoveryNode> nodes = generateRandomCandidates().stream().map(MasterCandidate::getNode).collect(Collectors.toList());
    DiscoveryNode bestMaster = electMasterService().tieBreakActiveMasters(nodes);
    for (DiscoveryNode node: nodes) {
        if (node.equals(bestMaster) == false) {
            assertTrue(bestMaster.getId().compareTo(node.getId()) < 0);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ElectMasterServiceTests.java

示例9: testFilterDiscoveredNodes

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void testFilterDiscoveredNodes() throws Exception {
    List<DiscoveryNode> knownNodes = new CopyOnWriteArrayList<>();
    try (MockTransportService seedTransport = startTransport("seed_node", knownNodes, Version.CURRENT);
         MockTransportService discoverableTransport = startTransport("discoverable_node", knownNodes, Version.CURRENT)) {
        DiscoveryNode seedNode = seedTransport.getLocalDiscoNode();
        DiscoveryNode discoverableNode = discoverableTransport.getLocalDiscoNode();
        knownNodes.add(seedTransport.getLocalDiscoNode());
        knownNodes.add(discoverableTransport.getLocalDiscoNode());
        DiscoveryNode rejectedNode = randomBoolean() ? seedNode : discoverableNode;
        Collections.shuffle(knownNodes, random());

        try (MockTransportService service = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool, null)) {
            service.start();
            service.acceptIncomingRequests();
            try (RemoteClusterConnection connection = new RemoteClusterConnection(Settings.EMPTY, "test-cluster",
                Arrays.asList(seedNode), service, Integer.MAX_VALUE, n -> n.equals(rejectedNode) == false)) {
                updateSeedNodes(connection, Arrays.asList(seedNode));
                if (rejectedNode.equals(seedNode)) {
                    assertFalse(service.nodeConnected(seedNode));
                    assertTrue(service.nodeConnected(discoverableNode));
                } else {
                    assertTrue(service.nodeConnected(seedNode));
                    assertFalse(service.nodeConnected(discoverableNode));
                }
                assertTrue(connection.assertNoRunningConnections());
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:RemoteClusterConnectionTests.java

示例10: publish

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void publish(ClusterChangedEvent clusterChangedEvent, final Discovery.AckListener ackListener) {
    Set<DiscoveryNode> nodesToPublishTo = new HashSet<>(clusterChangedEvent.state().nodes().size());
    DiscoveryNode localNode = nodesProvider.nodes().localNode();
    for (final DiscoveryNode node : clusterChangedEvent.state().nodes()) {
        if (node.equals(localNode)) {
            continue;
        }
        nodesToPublishTo.add(node);
    }
    publish(clusterChangedEvent, nodesToPublishTo, new AckClusterStatePublishResponseHandler(nodesToPublishTo, ackListener));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:PublishClusterStateAction.java

示例11: testPrimaryRelocationWhileIndexing

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@TestLogging("_root:DEBUG,org.elasticsearch.action.bulk:TRACE,org.elasticsearch.index.shard:TRACE,org.elasticsearch.cluster.service:TRACE")
public void testPrimaryRelocationWhileIndexing() throws Exception {
    internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3));
    client().admin().indices().prepareCreate("test")
        .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0))
        .addMapping("type", "field", "type=text")
        .get();
    ensureGreen("test");
    AtomicInteger numAutoGenDocs = new AtomicInteger();
    final AtomicBoolean finished = new AtomicBoolean(false);
    Thread indexingThread = new Thread() {
        @Override
        public void run() {
            while (finished.get() == false) {
                IndexResponse indexResponse = client().prepareIndex("test", "type", "id").setSource("field", "value").get();
                assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
                DeleteResponse deleteResponse = client().prepareDelete("test", "type", "id").get();
                assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
                client().prepareIndex("test", "type").setSource("auto", true).get();
                numAutoGenDocs.incrementAndGet();
            }
        }
    };
    indexingThread.start();

    ClusterState initialState = client().admin().cluster().prepareState().get().getState();
    DiscoveryNode[] dataNodes = initialState.getNodes().getDataNodes().values().toArray(DiscoveryNode.class);
    DiscoveryNode relocationSource = initialState.getNodes().getDataNodes().get(initialState.getRoutingTable().shardRoutingTable("test", 0).primaryShard().currentNodeId());
    for (int i = 0; i < RELOCATION_COUNT; i++) {
        DiscoveryNode relocationTarget = randomFrom(dataNodes);
        while (relocationTarget.equals(relocationSource)) {
            relocationTarget = randomFrom(dataNodes);
        }
        logger.info("--> [iteration {}] relocating from {} to {} ", i, relocationSource.getName(), relocationTarget.getName());
        client().admin().cluster().prepareReroute()
            .add(new MoveAllocationCommand("test", 0, relocationSource.getId(), relocationTarget.getId()))
            .execute().actionGet();
        ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNoRelocatingShards(true).execute().actionGet();
        assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
        logger.info("--> [iteration {}] relocation complete", i);
        relocationSource = relocationTarget;
        if (indexingThread.isAlive() == false) { // indexing process aborted early, no need for more relocations as test has already failed
            break;
        }
        if (i > 0  && i % 5 == 0) {
            logger.info("--> [iteration {}] flushing index", i);
            client().admin().indices().prepareFlush("test").get();
        }
    }
    finished.set(true);
    indexingThread.join();
    refresh("test");
    ElasticsearchAssertions.assertHitCount(client().prepareSearch("test").get(), numAutoGenDocs.get());
    ElasticsearchAssertions.assertHitCount(client().prepareSearch("test")// extra paranoia ;)
        .setQuery(QueryBuilders.termQuery("auto", true)).get(), numAutoGenDocs.get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:57,代码来源:IndexPrimaryRelocationIT.java

示例12: nodeConnected

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public boolean nodeConnected(DiscoveryNode node) {
    return node.equals(localNode) || transport.nodeConnected(node);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:TransportService.java

示例13: connectToNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void connectToNode(DiscoveryNode node) throws ConnectTransportException {
    if (node.equals(localNode)) {
        return;
    }
    transport.connectToNode(node);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:TransportService.java

示例14: connectToNodeLight

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void connectToNodeLight(DiscoveryNode node) throws ConnectTransportException {
    if (node.equals(localNode)) {
        return;
    }
    transport.connectToNodeLight(node);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:TransportService.java

示例15: disconnectFromNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void disconnectFromNode(DiscoveryNode node) {
    if (node.equals(localNode)) {
        return;
    }
    transport.disconnectFromNode(node);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:TransportService.java


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