當前位置: 首頁>>代碼示例>>Java>>正文


Java DiscoveryNode類代碼示例

本文整理匯總了Java中org.elasticsearch.cluster.node.DiscoveryNode的典型用法代碼示例。如果您正苦於以下問題:Java DiscoveryNode類的具體用法?Java DiscoveryNode怎麽用?Java DiscoveryNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DiscoveryNode類屬於org.elasticsearch.cluster.node包,在下文中一共展示了DiscoveryNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkRemoveAddress

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
private void checkRemoveAddress(boolean sniff) {
    Object[] extraSettings = {TransportClient.CLIENT_TRANSPORT_SNIFF.getKey(), sniff};
    try(TestIteration iteration = new TestIteration(extraSettings)) {
        final TransportClientNodesService service = iteration.transportClientNodesService;
        assertEquals(iteration.listNodesCount + iteration.sniffNodesCount, service.connectedNodes().size());
        final TransportAddress addressToRemove = randomFrom(iteration.listNodeAddresses);
        service.removeTransportAddress(addressToRemove);
        assertThat(service.connectedNodes(), everyItem(not(new CustomMatcher<DiscoveryNode>("removed address") {
            @Override
            public boolean matches(Object item) {
                return item instanceof DiscoveryNode && ((DiscoveryNode)item).getAddress().equals(addressToRemove);
            }
        })));
        assertEquals(iteration.listNodesCount + iteration.sniffNodesCount - 1, service.connectedNodes().size());
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:TransportClientNodesServiceTests.java

示例2: testTcpHandshakeTimeout

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
public void testTcpHandshakeTimeout() throws IOException {
    try (ServerSocket socket = new MockServerSocket()) {
        socket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0), 1);
        socket.setReuseAddress(true);
        DiscoveryNode dummy = new DiscoveryNode("TEST", new TransportAddress(socket.getInetAddress(),
            socket.getLocalPort()), emptyMap(),
            emptySet(), version0);
        ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
        builder.addConnections(1,
            TransportRequestOptions.Type.BULK,
            TransportRequestOptions.Type.PING,
            TransportRequestOptions.Type.RECOVERY,
            TransportRequestOptions.Type.REG,
            TransportRequestOptions.Type.STATE);
        builder.setHandshakeTimeout(TimeValue.timeValueMillis(1));
        ConnectTransportException ex = expectThrows(ConnectTransportException.class,
            () -> serviceA.connectToNode(dummy, builder.build()));
        assertEquals("[][" + dummy.getAddress() + "] handshake_timeout[1ms]", ex.getMessage());
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,代碼來源:AbstractSimpleTransportTestCase.java

示例3: doStart

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
@Override
protected void doStart() {
    add(localNodeMasterListeners);
    add(taskManager);
    this.clusterState = ClusterState.builder(clusterState).blocks(initialBlocks).build();
    this.updateTasksExecutor = EsExecutors.newSinglePrioritizing(UPDATE_THREAD_NAME, daemonThreadFactory(settings, UPDATE_THREAD_NAME));
    this.reconnectToNodes = threadPool.schedule(reconnectInterval, ThreadPool.Names.GENERIC, new ReconnectToNodes());
    Map<String, String> nodeAttributes = discoveryNodeService.buildAttributes();
    // note, we rely on the fact that its a new id each time we start, see FD and "kill -9" handling
    final String nodeId = DiscoveryService.generateNodeId(settings);
    final TransportAddress publishAddress = transportService.boundAddress().publishAddress();
    DiscoveryNode localNode = new DiscoveryNode(settings.get("name"), nodeId, publishAddress, nodeAttributes, version);
    DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder().put(localNode).localNodeId(localNode.id());
    this.clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).blocks(initialBlocks).build();
    this.transportService.setLocalNode(localNode);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:InternalClusterService.java

示例4: buildDefaultConnectionProfile

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
static ConnectionProfile buildDefaultConnectionProfile(Settings settings) {
    int connectionsPerNodeRecovery = CONNECTIONS_PER_NODE_RECOVERY.get(settings);
    int connectionsPerNodeBulk = CONNECTIONS_PER_NODE_BULK.get(settings);
    int connectionsPerNodeReg = CONNECTIONS_PER_NODE_REG.get(settings);
    int connectionsPerNodeState = CONNECTIONS_PER_NODE_STATE.get(settings);
    int connectionsPerNodePing = CONNECTIONS_PER_NODE_PING.get(settings);
    ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
    builder.setConnectTimeout(TCP_CONNECT_TIMEOUT.get(settings));
    builder.setHandshakeTimeout(TCP_CONNECT_TIMEOUT.get(settings));
    builder.addConnections(connectionsPerNodeBulk, TransportRequestOptions.Type.BULK);
    builder.addConnections(connectionsPerNodePing, TransportRequestOptions.Type.PING);
    // if we are not master eligible we don't need a dedicated channel to publish the state
    builder.addConnections(DiscoveryNode.isMasterNode(settings) ? connectionsPerNodeState : 0, TransportRequestOptions.Type.STATE);
    // if we are not a data-node we don't need any dedicated channels for recovery
    builder.addConnections(DiscoveryNode.isDataNode(settings) ? connectionsPerNodeRecovery : 0, TransportRequestOptions.Type.RECOVERY);
    builder.addConnections(connectionsPerNodeReg, TransportRequestOptions.Type.REG);
    return builder.build();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:TcpTransport.java

示例5: handleJoinRequest

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
/**
 * processes or queues an incoming join request.
 * <p>
 * Note: doesn't do any validation. This should have been done before.
 */
public void handleJoinRequest(final DiscoveryNode node, final MembershipAction.JoinCallback callback) {
    synchronized (pendingJoinRequests) {
        List<MembershipAction.JoinCallback> nodeCallbacks = pendingJoinRequests.get(node);
        if (nodeCallbacks == null) {
            nodeCallbacks = new ArrayList<>();
            pendingJoinRequests.put(node, nodeCallbacks);
        }
        nodeCallbacks.add(callback);
    }
    if (accumulateJoins.get() == false) {
        processJoins("join from node[" + node + "]");
    } else {
        checkPendingJoinsAndElectIfNeeded();
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:21,代碼來源:NodeJoinController.java

示例6: executePhase

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
void executePhase(final int shardIndex, DiscoveryNode node, final long searchId) {
    InternalScrollSearchRequest internalRequest = internalScrollSearchRequest(searchId, request);
    searchService.sendExecuteFetch(node, internalRequest, new ActionListener<ScrollQueryFetchSearchResult>() {
        @Override
        public void onResponse(ScrollQueryFetchSearchResult result) {
            queryFetchResults.set(shardIndex, result.result());
            if (counter.decrementAndGet() == 0) {
                finishHim();
            }
        }

        @Override
        public void onFailure(Throwable t) {
            onPhaseFailure(t, searchId, shardIndex);
        }
    });
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:18,代碼來源:SearchScrollQueryAndFetchAsyncAction.java

示例7: createClusterService

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
public static ClusterService createClusterService(Settings settings, ThreadPool threadPool, DiscoveryNode localNode) {
    ClusterService clusterService = new ClusterService(
        Settings.builder().put("cluster.name", "ClusterServiceTests").put(settings).build(),
            new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
            threadPool, () -> localNode);
    clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
        @Override
        public void connectToNodes(DiscoveryNodes discoveryNodes) {
            // skip
        }

        @Override
        public void disconnectFromNodesExcept(DiscoveryNodes nodesToKeep) {
            // skip
        }
    });
    clusterService.setClusterStatePublisher((event, ackListener) -> {
    });
    clusterService.setDiscoverySettings(new DiscoverySettings(Settings.EMPTY,
        new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
    clusterService.start();
    final DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(clusterService.state().nodes());
    nodes.masterNodeId(clusterService.localNode().getId());
    setState(clusterService, ClusterState.builder(clusterService.state()).nodes(nodes));
    return clusterService;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:ClusterServiceUtils.java

示例8: NodeInfo

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
public NodeInfo(Version version, Build build, DiscoveryNode node, @Nullable ImmutableMap<String, String> serviceAttributes, @Nullable Settings settings,
                @Nullable OsInfo os, @Nullable ProcessInfo process, @Nullable JvmInfo jvm, @Nullable ThreadPoolInfo threadPool,
                @Nullable TransportInfo transport, @Nullable HttpInfo http, @Nullable PluginsAndModules plugins) {
    super(node);
    this.version = version;
    this.build = build;
    this.serviceAttributes = serviceAttributes;
    this.settings = settings;
    this.os = os;
    this.process = process;
    this.jvm = jvm;
    this.threadPool = threadPool;
    this.transport = transport;
    this.http = http;
    this.plugins = plugins;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:NodeInfo.java

示例9: testMismatchedClusterName

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
public void testMismatchedClusterName() {

        NetworkHandle handleA = startServices("TS_A", Settings.builder().put("cluster.name", "a").build(), Version.CURRENT);
        NetworkHandle handleB = startServices("TS_B", Settings.builder().put("cluster.name", "b").build(), Version.CURRENT);
        DiscoveryNode discoveryNode = new DiscoveryNode(
            "",
            handleB.discoveryNode.getAddress(),
            emptyMap(),
            emptySet(),
            Version.CURRENT.minimumCompatibilityVersion());
        IllegalStateException ex = expectThrows(IllegalStateException.class, () -> {
            try (Transport.Connection connection = handleA.transportService.openConnection(discoveryNode,
                MockTcpTransport.LIGHT_PROFILE)) {
                handleA.transportService.handshake(connection, timeout);
            }
        });
        assertThat(ex.getMessage(), containsString("handshake failed, mismatched cluster name [Cluster [b]]"));
        assertFalse(handleA.transportService.nodeConnected(discoveryNode));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:20,代碼來源:TransportServiceHandshakeTests.java

示例10: SnapshotShardsService

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
@Inject
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService, ThreadPool threadPool,
                             TransportService transportService, IndicesService indicesService) {
    super(settings);
    this.indicesService = indicesService;
    this.snapshotsService = snapshotsService;
    this.transportService = transportService;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    if (DiscoveryNode.dataNode(settings)) {
        // this is only useful on the nodes that can hold data
        // addLast to make sure that Repository will be created before snapshot
        clusterService.addLast(this);
    }

    if (DiscoveryNode.masterNode(settings)) {
        // This needs to run only on nodes that can become masters
        transportService.registerRequestHandler(UPDATE_SNAPSHOT_ACTION_NAME, UpdateIndexShardSnapshotStatusRequest.class, ThreadPool.Names.SAME, new UpdateSnapshotStateRequestHandler());
    }

}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:22,代碼來源:SnapshotShardsService.java

示例11: testSuccessAfterRetryWithExceptionFromTransport

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
public void testSuccessAfterRetryWithExceptionFromTransport() throws Exception {
    Request request = new Request().index("test");
    request.shardId = new ShardId("test", "_na_", 0);
    PlainActionFuture<Response> listener = new PlainActionFuture<>();
    boolean local = randomBoolean();
    setState(clusterService, ClusterStateCreationUtils.state("test", local, ShardRoutingState.STARTED));
    action.new AsyncSingleAction(request, listener).start();
    assertThat(transport.capturedRequests().length, equalTo(1));
    long requestId = transport.capturedRequests()[0].requestId;
    transport.clear();
    DiscoveryNode node = clusterService.state().getNodes().getLocalNode();
    transport.handleLocalError(requestId, new ConnectTransportException(node, "test exception"));
    // trigger cluster state observer
    setState(clusterService, ClusterStateCreationUtils.state("test", local, ShardRoutingState.STARTED));
    assertThat(transport.capturedRequests().length, equalTo(1));
    transport.handleResponse(transport.capturedRequests()[0].requestId, new Response());
    listener.get();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:TransportInstanceSingleOperationActionTests.java

示例12: getRouting

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
@Override
public Routing getRouting(WhereClause whereClause, @Nullable String preference) {
    DiscoveryNodes nodes = service.state().nodes();
    TreeMapBuilder<String, Map<String, List<Integer>>> builder = TreeMapBuilder.newMapBuilder();
    Map<String, List<Integer>> emptyTableMap = Collections.emptyMap();
    for (DiscoveryNode node : nodes) {
        builder.put(node.id(), emptyTableMap);
    }
    return new Routing(builder.map());
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,代碼來源:SysNodesTableInfo.java

示例13: fdNodesForState

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
private Set<DiscoveryNode> fdNodesForState(ClusterState clusterState, DiscoveryNode localNode) {
    final Set<DiscoveryNode> discoveryNodes = new HashSet<>();
    clusterState.getNodes().getNodes().valuesIt().forEachRemaining(discoveryNode -> {
        // the local node isn't part of the nodes that are pinged (don't ping ourselves)
        if (discoveryNode.getId().equals(localNode.getId()) == false) {
            discoveryNodes.add(discoveryNode);
        }
    });
    return discoveryNodes;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:ZenDiscoveryUnitTests.java

示例14: PingingRound

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
PingingRound(int id, List<DiscoveryNode> seedNodes, Consumer<PingCollection> resultsConsumer, DiscoveryNode localNode,
             ConnectionProfile connectionProfile) {
    this.id = id;
    this.seedNodes = Collections.unmodifiableList(new ArrayList<>(seedNodes));
    this.pingListener = resultsConsumer;
    this.localNode = localNode;
    this.connectionProfile = connectionProfile;
    this.pingCollection = new PingCollection();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:UnicastZenPing.java

示例15: requestSent

import org.elasticsearch.cluster.node.DiscoveryNode; //導入依賴的package包/類
@Override
public void requestSent(DiscoveryNode node, long requestId, String action, TransportRequestOptions options) {
    super.requestSent(node, requestId, action, options);
    if (actions.contains(action)) {
        sawRequestSent = true;
        expectedEvents.get().countDown();
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:AbstractSimpleTransportTestCase.java


注:本文中的org.elasticsearch.cluster.node.DiscoveryNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。