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


Java DiscoveryNode.Role方法代码示例

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


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

示例1: generateRandomNodes

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
List<DiscoveryNode> generateRandomNodes() {
    int count = scaledRandomIntBetween(1, 100);
    ArrayList<DiscoveryNode> nodes = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        Set<DiscoveryNode.Role> roles = new HashSet<>();
        if (randomBoolean()) {
            roles.add(DiscoveryNode.Role.MASTER);
        }
        DiscoveryNode node = new DiscoveryNode("n_" + i, "n_" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
                roles, Version.CURRENT);
        nodes.add(node);
    }

    Collections.shuffle(nodes, random());
    return nodes;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:ElectMasterServiceTests.java

示例2: createNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
protected DiscoveryNode createNode(DiscoveryNode.Role... mustHaveRoles) {
    Set<DiscoveryNode.Role> roles = new HashSet<>(randomSubsetOf(Sets.newHashSet(DiscoveryNode.Role.values())));
    for (DiscoveryNode.Role mustHaveRole : mustHaveRoles) {
        roles.add(mustHaveRole);
    }
    final String id = String.format(Locale.ROOT, "node_%03d", nodeIdGenerator.incrementAndGet());
    return new DiscoveryNode(id, id, buildNewFakeTransportAddress(), Collections.emptyMap(), roles,
        Version.CURRENT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndicesClusterStateServiceRandomUpdatesTests.java

示例3: newNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:NodeJoinControllerTests.java

示例4: generateRandomCandidates

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
List<MasterCandidate> generateRandomCandidates() {
    int count = scaledRandomIntBetween(1, 100);
    ArrayList<MasterCandidate> candidates = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        Set<DiscoveryNode.Role> roles = new HashSet<>();
        roles.add(DiscoveryNode.Role.MASTER);
        DiscoveryNode node = new DiscoveryNode("n_" + i, "n_" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
            roles, Version.CURRENT);
        candidates.add(
            new MasterCandidate(node, randomBoolean() ? MasterCandidate.UNRECOVERED_CLUSTER_VERSION : randomNonNegativeLong()));
    }

    Collections.shuffle(candidates, random());
    return candidates;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ElectMasterServiceTests.java

示例5: generateNodes

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
private List<DiscoveryNode> generateNodes() {
    List<DiscoveryNode> nodes = new ArrayList<>();
    for (int i = randomIntBetween(20, 50); i > 0; i--) {
        Set<DiscoveryNode.Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values())));
        nodes.add(new DiscoveryNode("node_" + i, "" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
                roles, Version.CURRENT));
    }
    return nodes;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:NodeConnectionsServiceTests.java

示例6: setUp

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();
    transport = new CapturingTransport();
    clusterService = createClusterService(THREAD_POOL);
    transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL,
        TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    int numNodes = randomIntBetween(3, 10);
    DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder();
    List<DiscoveryNode> discoveryNodes = new ArrayList<>();
    for (int i = 0; i < numNodes; i++) {
        Map<String, String> attributes = new HashMap<>();
        Set<DiscoveryNode.Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values())));
        if (frequently()) {
            attributes.put("custom", randomBoolean() ? "match" : randomAsciiOfLengthBetween(3, 5));
        }
        final DiscoveryNode node = newNode(i, attributes, roles);
        discoBuilder = discoBuilder.add(node);
        discoveryNodes.add(node);
    }
    discoBuilder.localNodeId(randomFrom(discoveryNodes).getId());
    discoBuilder.masterNodeId(randomFrom(discoveryNodes).getId());
    ClusterState.Builder stateBuilder = ClusterState.builder(clusterService.getClusterName());
    stateBuilder.nodes(discoBuilder);
    ClusterState clusterState = stateBuilder.build();
    setState(clusterService, clusterState);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:TransportNodesActionTests.java

示例7: newNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
protected static DiscoveryNode newNode(String nodeId, Set<DiscoveryNode.Role> roles) {
    return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:ESAllocationTestCase.java

示例8: toXContent

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject("nodes");
    for (NodeInfo nodeInfo : getNodes()) {
        builder.startObject(nodeInfo.getNode().getId());

        builder.field("name", nodeInfo.getNode().getName());
        builder.field("transport_address", nodeInfo.getNode().getAddress().toString());
        builder.field("host", nodeInfo.getNode().getHostName());
        builder.field("ip", nodeInfo.getNode().getHostAddress());

        builder.field("version", nodeInfo.getVersion());
        builder.field("build_hash", nodeInfo.getBuild().shortHash());
        if (nodeInfo.getTotalIndexingBuffer() != null) {
            builder.byteSizeField("total_indexing_buffer", "total_indexing_buffer_in_bytes", nodeInfo.getTotalIndexingBuffer());
        }

        builder.startArray("roles");
        for (DiscoveryNode.Role role : nodeInfo.getNode().getRoles()) {
            builder.value(role.getRoleName());
        }
        builder.endArray();

        if (!nodeInfo.getNode().getAttributes().isEmpty()) {
            builder.startObject("attributes");
            for (Map.Entry<String, String> entry : nodeInfo.getNode().getAttributes().entrySet()) {
                builder.field(entry.getKey(), entry.getValue());
            }
            builder.endObject();
        }

        if (nodeInfo.getSettings() != null) {
            builder.startObject("settings");
            Settings settings = nodeInfo.getSettings();
            settings.toXContent(builder, params);
            builder.endObject();
        }

        if (nodeInfo.getOs() != null) {
            nodeInfo.getOs().toXContent(builder, params);
        }
        if (nodeInfo.getProcess() != null) {
            nodeInfo.getProcess().toXContent(builder, params);
        }
        if (nodeInfo.getJvm() != null) {
            nodeInfo.getJvm().toXContent(builder, params);
        }
        if (nodeInfo.getThreadPool() != null) {
            nodeInfo.getThreadPool().toXContent(builder, params);
        }
        if (nodeInfo.getTransport() != null) {
            nodeInfo.getTransport().toXContent(builder, params);
        }
        if (nodeInfo.getHttp() != null) {
            nodeInfo.getHttp().toXContent(builder, params);
        }
        if (nodeInfo.getPlugins() != null) {
            nodeInfo.getPlugins().toXContent(builder, params);
        }
        if (nodeInfo.getIngest() != null) {
            nodeInfo.getIngest().toXContent(builder, params);
        }

        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:69,代码来源:NodesInfoResponse.java

示例9: toXContentGroupedByNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
/**
 * Convert this task response to XContent grouping by executing nodes.
 */
public XContentBuilder toXContentGroupedByNode(XContentBuilder builder, Params params, DiscoveryNodes discoveryNodes)
        throws IOException {
    toXContentCommon(builder, params);
    builder.startObject("nodes");
    for (Map.Entry<String, List<TaskInfo>> entry : getPerNodeTasks().entrySet()) {
        DiscoveryNode node = discoveryNodes.get(entry.getKey());
        builder.startObject(entry.getKey());
        if (node != null) {
            // If the node is no longer part of the cluster, oh well, we'll just skip it's useful information.
            builder.field("name", node.getName());
            builder.field("transport_address", node.getAddress().toString());
            builder.field("host", node.getHostName());
            builder.field("ip", node.getAddress());

            builder.startArray("roles");
            for (DiscoveryNode.Role role : node.getRoles()) {
                builder.value(role.getRoleName());
            }
            builder.endArray();

            if (!node.getAttributes().isEmpty()) {
                builder.startObject("attributes");
                for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
                    builder.field(attrEntry.getKey(), attrEntry.getValue());
                }
                builder.endObject();
            }
        }
        builder.startObject("tasks");
        for(TaskInfo task : entry.getValue()) {
            builder.startObject(task.getTaskId().toString());
            task.toXContent(builder, params);
            builder.endObject();
        }
        builder.endObject();
        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:44,代码来源:ListTasksResponse.java

示例10: toXContent

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {

    builder.field("name", getNode().getName());
    builder.field("transport_address", getNode().getAddress().toString());
    builder.field("host", getNode().getHostName());
    builder.field("ip", getNode().getAddress());

    builder.startArray("roles");
    for (DiscoveryNode.Role role : getNode().getRoles()) {
        builder.value(role.getRoleName());
    }
    builder.endArray();

    if (!getNode().getAttributes().isEmpty()) {
        builder.startObject("attributes");
        for (Map.Entry<String, String> attrEntry : getNode().getAttributes().entrySet()) {
            builder.field(attrEntry.getKey(), attrEntry.getValue());
        }
        builder.endObject();
    }

    if (getIndices() != null) {
        getIndices().toXContent(builder, params);
    }
    if (getOs() != null) {
        getOs().toXContent(builder, params);
    }
    if (getProcess() != null) {
        getProcess().toXContent(builder, params);
    }
    if (getJvm() != null) {
        getJvm().toXContent(builder, params);
    }
    if (getThreadPool() != null) {
        getThreadPool().toXContent(builder, params);
    }
    if (getFs() != null) {
        getFs().toXContent(builder, params);
    }
    if (getTransport() != null) {
        getTransport().toXContent(builder, params);
    }
    if (getHttp() != null) {
        getHttp().toXContent(builder, params);
    }
    if (getBreaker() != null) {
        getBreaker().toXContent(builder, params);
    }
    if (getScriptStats() != null) {
        getScriptStats().toXContent(builder, params);
    }
    if (getDiscoveryStats() != null) {
        getDiscoveryStats().toXContent(builder, params);
    }
    if (getIngestStats() != null) {
        getIngestStats().toXContent(builder, params);
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:61,代码来源:NodeStats.java

示例11: generateDiscoveryNodes

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
private DiscoveryNodes.Builder generateDiscoveryNodes(boolean masterEligible) {
    Set<DiscoveryNode.Role> dataOnlyRoles = Collections.singleton(DiscoveryNode.Role.DATA);
    return DiscoveryNodes.builder().add(newNode("node1", masterEligible ? MASTER_DATA_ROLES : dataOnlyRoles))
            .add(newNode("master_node", MASTER_DATA_ROLES)).localNodeId("node1").masterNodeId(masterEligible ? "node1" : "master_node");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:GatewayMetaStateTests.java

示例12: newNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
private static DiscoveryNode newNode(final String nodeId, Set<DiscoveryNode.Role> roles) {
    return new DiscoveryNode(nodeId, nodeId, nodeId, "host", "host_address", buildNewFakeTransportAddress(),
        Collections.emptyMap(), roles, Version.CURRENT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterChangedEventTests.java

示例13: newNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
private static DiscoveryNode newNode(int nodeId, Map<String, String> attributes, Set<DiscoveryNode.Role> roles) {
    String node = "node_" + nodeId;
    return new DiscoveryNode(node, node, buildNewFakeTransportAddress(), attributes, roles, Version.CURRENT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TransportNodesActionTests.java


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