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


Java DiscoveryNode.getRoles方法代码示例

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


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

示例1: testRejectingJoinWithSameIdButDifferentNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void testRejectingJoinWithSameIdButDifferentNode() throws InterruptedException, ExecutionException {
    addNodes(randomInt(5));
    ClusterState state = clusterService.state();
    final DiscoveryNode existing = randomFrom(StreamSupport.stream(state.nodes().spliterator(), false).collect(Collectors.toList()));
    final DiscoveryNode other_node = new DiscoveryNode(
        randomBoolean() ? existing.getName() : "other_name",
        existing.getId(),
        randomBoolean() ? existing.getAddress() : buildNewFakeTransportAddress(),
        randomBoolean() ? existing.getAttributes() : Collections.singletonMap("attr", "other"),
        randomBoolean() ? existing.getRoles() : new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values()))),
        randomBoolean() ? existing.getVersion() : VersionUtils.randomVersion(random()));

    ExecutionException e = expectThrows(ExecutionException.class, () -> joinNode(other_node));
    assertThat(e.getMessage(), containsString("found existing node"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:NodeJoinControllerTests.java

示例2: testRejectingRestartedNodeJoinsBeforeProcessingNodeLeft

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
public void testRejectingRestartedNodeJoinsBeforeProcessingNodeLeft() throws InterruptedException, ExecutionException {
    addNodes(randomInt(5));
    ClusterState state = clusterService.state();
    final DiscoveryNode existing = randomFrom(StreamSupport.stream(state.nodes().spliterator(), false).collect(Collectors.toList()));
    joinNode(existing); // OK

    final DiscoveryNode other_node = new DiscoveryNode(existing.getId(), existing.getAddress(), existing.getAttributes(),
        existing.getRoles(), Version.CURRENT);

    ExecutionException e = expectThrows(ExecutionException.class, () -> joinNode(other_node));
    assertThat(e.getMessage(), containsString("found existing node"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:NodeJoinControllerTests.java

示例3: wrapLivenessResponseHandler

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
private <T extends TransportResponse> TransportResponseHandler wrapLivenessResponseHandler(TransportResponseHandler<T> handler,
                                                                                           DiscoveryNode node,
                                                                                           ClusterName clusterName) {
    return new TransportResponseHandler<T>() {
        @Override
        public T newInstance() {
            return handler.newInstance();
        }

        @Override
        @SuppressWarnings("unchecked")
        public void handleResponse(T response) {
            LivenessResponse livenessResponse = new LivenessResponse(clusterName,
                    new DiscoveryNode(node.getName(), node.getId(), node.getEphemeralId(), "liveness-hostname" + node.getId(),
                            "liveness-hostaddress" + node.getId(),
                            livenessAddress, node.getAttributes(), node.getRoles(),
                            node.getVersion()));
            handler.handleResponse((T)livenessResponse);
        }

        @Override
        public void handleException(TransportException exp) {
            handler.handleException(exp);
        }

        @Override
        public String executor() {
            return handler.executor();
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:TransportClientNodesServiceTests.java

示例4: 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

示例5: cloneNode

import org.elasticsearch.cluster.node.DiscoveryNode; //导入方法依赖的package包/类
/**
 * creates an object clone of node, so it will be a different object instance
 */
private DiscoveryNode cloneNode(DiscoveryNode node) {
    return new DiscoveryNode(node.getName(), node.getId(), node.getEphemeralId(), node.getHostName(), node.getHostAddress(),
        node.getAddress(), node.getAttributes(), node.getRoles(), node.getVersion());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:NodeJoinControllerTests.java


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