Java Code Examples for org.elasticsearch.cluster.node.DiscoveryNode#Role
The following examples show how to use
org.elasticsearch.cluster.node.DiscoveryNode#Role .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoutingTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testRoutingForRandomMasterOrDataNode() throws IOException { Map<String, String> attr = ImmutableMap.of(); Set<DiscoveryNode.Role> master_and_data = ImmutableSet.of(DiscoveryNode.Role.MASTER, DiscoveryNode.Role.DATA); DiscoveryNode local = new DiscoveryNode("client_node_1", buildNewFakeTransportAddress(), attr, ImmutableSet.of(), null); DiscoveryNodes nodes = new DiscoveryNodes.Builder() .add(new DiscoveryNode("data_master_node_1", buildNewFakeTransportAddress(), attr, master_and_data, null)) .add(new DiscoveryNode("data_master_node_2", buildNewFakeTransportAddress(), attr, master_and_data, null)) .add(local) .add(new DiscoveryNode("client_node_2", buildNewFakeTransportAddress(), attr, ImmutableSet.of(), null)) .add(new DiscoveryNode("client_node_3", buildNewFakeTransportAddress(), attr, ImmutableSet.of(), null)) .localNodeId(local.getId()) .build(); RoutingProvider routingProvider = new RoutingProvider(Randomness.get().nextInt(), Collections.emptyList()); Routing routing = routingProvider.forRandomMasterOrDataNode(new RelationName("doc", "table"), nodes); assertThat(routing.locations().keySet(), anyOf(contains("data_master_node_1"), contains("data_master_node_2"))); Routing routing2 = routingProvider.forRandomMasterOrDataNode(new RelationName("doc", "table"), nodes); assertThat("routingProvider is seeded and must return deterministic routing", routing.locations(), equalTo(routing2.locations())); }
Example 2
Source File: RoutingTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testRoutingForRandomMasterOrDataNodePrefersLocal() throws Exception { Set<DiscoveryNode.Role> data = ImmutableSet.of(DiscoveryNode.Role.DATA); Map<String, String> attr = ImmutableMap.of(); DiscoveryNode local = new DiscoveryNode("local_data", buildNewFakeTransportAddress(), attr, data, null); DiscoveryNodes nodes = new DiscoveryNodes.Builder() .add(local) .localNodeId(local.getId()) .add(new DiscoveryNode("data_1", buildNewFakeTransportAddress(), attr, data, null)) .add(new DiscoveryNode("data_2", buildNewFakeTransportAddress(), attr, data, null)) .add(new DiscoveryNode("data_3", buildNewFakeTransportAddress(), attr, data, null)) .add(new DiscoveryNode("data_4", buildNewFakeTransportAddress(), attr, data, null)) .build(); RoutingProvider routingProvider = new RoutingProvider(Randomness.get().nextInt(), Collections.emptyList()); Routing routing = routingProvider.forRandomMasterOrDataNode(new RelationName("doc", "table"), nodes); assertThat(routing.locations().keySet(), contains("local_data")); }
Example 3
Source File: Node.java From crate with Apache License 2.0 | 5 votes |
@Override public DiscoveryNode apply(BoundTransportAddress boundTransportAddress) { // CRATE_PATCH: use existing node attributes to pass and stream http_address between the nodes Map<String, String> attributes = new HashMap<>(NODE_ATTRIBUTES.getAsMap(settings)); Set<DiscoveryNode.Role> roles = getRolesFromSettings(settings); if (httpPublishAddress != null) { attributes.put("http_address", httpPublishAddress); } localNode.set(new DiscoveryNode(Node.NODE_NAME_SETTING.get(settings), persistentNodeId, boundTransportAddress.publishAddress(), attributes, roles, Version.CURRENT)); return localNode.get(); }
Example 4
Source File: NodeJoinTests.java From crate with Apache License 2.0 | 5 votes |
protected DiscoveryNode newNode(int i, boolean master) { Set<DiscoveryNode.Role> roles = new HashSet<>(); if (master) { roles.add(DiscoveryNode.Role.MASTER); } final String prefix = master ? "master_" : "data_"; return new DiscoveryNode(prefix + i, i + "", buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); }
Example 5
Source File: ESAllocationTestCase.java From crate with Apache License 2.0 | 4 votes |
protected static DiscoveryNode newNode(String nodeId, Set<DiscoveryNode.Role> roles) { return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); }
Example 6
Source File: PublicationTests.java From crate with Apache License 2.0 | 4 votes |
private static DiscoveryNode newNode(int nodeId, Map<String, String> attributes, Set<DiscoveryNode.Role> roles) { return new DiscoveryNode("name_" + nodeId, "node_" + nodeId, buildNewFakeTransportAddress(), attributes, roles, Version.CURRENT); }
Example 7
Source File: FollowersCheckerTests.java From crate with Apache License 2.0 | 4 votes |
private static DiscoveryNode newNode(int nodeId, Map<String, String> attributes, Set<DiscoveryNode.Role> roles) { return new DiscoveryNode("name_" + nodeId, "node_" + nodeId, buildNewFakeTransportAddress(), attributes, roles, Version.CURRENT); }