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


Java TransportAddress.META_ADDRESS属性代码示例

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


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

示例1: newNode

public static DiscoveryNode newNode(String nodeId, Map<String, String> attributes) {
    return new DiscoveryNode("", nodeId, new TransportAddress(TransportAddress.META_ADDRESS,
        portGenerator.incrementAndGet()), attributes, Sets.newHashSet(DiscoveryNode.Role.MASTER,
        DiscoveryNode.Role.DATA), Version.CURRENT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:Allocators.java

示例2: testResolveTimeout

public void testResolveTimeout() throws InterruptedException {
    final Logger logger = mock(Logger.class);
    final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
    final CountDownLatch latch = new CountDownLatch(1);
    final Transport transport = new MockTcpTransport(
        Settings.EMPTY,
        threadPool,
        BigArrays.NON_RECYCLING_INSTANCE,
        new NoneCircuitBreakerService(),
        new NamedWriteableRegistry(Collections.emptyList()),
        networkService,
        Version.CURRENT) {

        @Override
        public BoundTransportAddress boundAddress() {
            return new BoundTransportAddress(
                new TransportAddress[]{new TransportAddress(InetAddress.getLoopbackAddress(), 9500)},
                new TransportAddress(InetAddress.getLoopbackAddress(), 9500)
            );
        }

        @Override
        public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws UnknownHostException {
            if ("hostname1".equals(address)) {
                return new TransportAddress[]{new TransportAddress(TransportAddress.META_ADDRESS, 9300)};
            } else if ("hostname2".equals(address)) {
                try {
                    latch.await();
                    return new TransportAddress[]{new TransportAddress(TransportAddress.META_ADDRESS, 9300)};
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            } else {
                throw new UnknownHostException(address);
            }
        }

    };
    closeables.push(transport);

    final TransportService transportService =
        new TransportService(Settings.EMPTY, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null);
    closeables.push(transportService);
    final TimeValue resolveTimeout = TimeValue.timeValueSeconds(randomIntBetween(1, 3));
    try {
        final List<DiscoveryNode> discoveryNodes = TestUnicastZenPing.resolveHostsLists(
            executorService,
            logger,
            Arrays.asList("hostname1", "hostname2"),
            1,
            transportService,
            "test+",
            resolveTimeout);

        assertThat(discoveryNodes, hasSize(1));
        verify(logger).trace(
            "resolved host [{}] to {}", "hostname1",
            new TransportAddress[]{new TransportAddress(TransportAddress.META_ADDRESS, 9300)});
        verify(logger).warn("timed out after [{}] resolving host [{}]", resolveTimeout, "hostname2");
        verifyNoMoreInteractions(logger);
    } finally {
        latch.countDown();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:64,代码来源:UnicastZenPingTests.java

示例3: testSerialization

public void testSerialization() throws Exception {
    Map<String, AliasFilter> indicesAndFilters = new HashMap<>();
    Set<DiscoveryNode> nodes = new HashSet<>();
    int numShards = randomIntBetween(1, 10);
    ClusterSearchShardsGroup[] clusterSearchShardsGroups = new ClusterSearchShardsGroup[numShards];
    for (int i = 0; i < numShards; i++) {
        String index = randomAsciiOfLengthBetween(3, 10);
        ShardId shardId = new ShardId(index, randomAsciiOfLength(12), i);
        String nodeId = randomAsciiOfLength(10);
        ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, nodeId, randomBoolean(), ShardRoutingState.STARTED);
        clusterSearchShardsGroups[i] = new ClusterSearchShardsGroup(shardId, new ShardRouting[]{shardRouting});
        DiscoveryNode node = new DiscoveryNode(shardRouting.currentNodeId(),
                new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF)), VersionUtils.randomVersion(random()));
        nodes.add(node);
        AliasFilter aliasFilter;
        if (randomBoolean()) {
            aliasFilter = new AliasFilter(RandomQueryBuilder.createQuery(random()), "alias-" + index);
        } else {
            aliasFilter = new AliasFilter(null, Strings.EMPTY_ARRAY);
        }
        indicesAndFilters.put(index, aliasFilter);
    }
    ClusterSearchShardsResponse clusterSearchShardsResponse = new ClusterSearchShardsResponse(clusterSearchShardsGroups,
            nodes.toArray(new DiscoveryNode[nodes.size()]), indicesAndFilters);

    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
    entries.addAll(searchModule.getNamedWriteables());
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(entries);
    Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.CURRENT);
    try(BytesStreamOutput out = new BytesStreamOutput()) {
        out.setVersion(version);
        clusterSearchShardsResponse.writeTo(out);
        try(StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), namedWriteableRegistry)) {
            in.setVersion(version);
            ClusterSearchShardsResponse deserialized = new ClusterSearchShardsResponse();
            deserialized.readFrom(in);
            assertArrayEquals(clusterSearchShardsResponse.getNodes(), deserialized.getNodes());
            assertEquals(clusterSearchShardsResponse.getGroups().length, deserialized.getGroups().length);
            for (int i = 0; i < clusterSearchShardsResponse.getGroups().length; i++) {
                ClusterSearchShardsGroup clusterSearchShardsGroup = clusterSearchShardsResponse.getGroups()[i];
                ClusterSearchShardsGroup deserializedGroup = deserialized.getGroups()[i];
                assertEquals(clusterSearchShardsGroup.getShardId(), deserializedGroup.getShardId());
                assertArrayEquals(clusterSearchShardsGroup.getShards(), deserializedGroup.getShards());
            }
            if (version.onOrAfter(Version.V_5_1_1_UNRELEASED)) {
                assertEquals(clusterSearchShardsResponse.getIndicesAndFilters(), deserialized.getIndicesAndFilters());
            } else {
                assertNull(deserialized.getIndicesAndFilters());
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:53,代码来源:ClusterSearchShardsResponseTests.java

示例4: buildNewFakeTransportAddress

/**
 * Generates a new transport address using {@link TransportAddress#META_ADDRESS} with an incrementing port number.
 * The port number starts at 0 and is reset after each test suite run.
 */
public static TransportAddress buildNewFakeTransportAddress() {
    return new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:ESTestCase.java


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