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


Java BoundTransportAddress类代码示例

本文整理汇总了Java中org.elasticsearch.common.transport.BoundTransportAddress的典型用法代码示例。如果您正苦于以下问题:Java BoundTransportAddress类的具体用法?Java BoundTransportAddress怎么用?Java BoundTransportAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TransportService

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
/**
 * Build the service.
 *
 * @param clusterSettings if non null the the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings
 *        updates for {@link #TRACE_LOG_EXCLUDE_SETTING} and {@link #TRACE_LOG_INCLUDE_SETTING}.
 */
public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor,
                        Function<BoundTransportAddress, DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings) {
    super(settings);
    this.transport = transport;
    this.threadPool = threadPool;
    this.localNodeFactory = localNodeFactory;
    this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
    setTracerLogInclude(TRACE_LOG_INCLUDE_SETTING.get(settings));
    setTracerLogExclude(TRACE_LOG_EXCLUDE_SETTING.get(settings));
    tracerLog = Loggers.getLogger(logger, ".tracer");
    adapter = createAdapter();
    taskManager = createTaskManager();
    this.interceptor = transportInterceptor;
    this.asyncSender = interceptor.interceptSender(this::sendRequestInternal);
    if (clusterSettings != null) {
        clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude);
        clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_EXCLUDE_SETTING, this::setTracerLogExclude);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportService.java

示例2: doStart

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
@Override
protected void doStart() {
    adapter.rxMetric.clear();
    adapter.txMetric.clear();
    transport.transportServiceAdapter(adapter);
    transport.start();

    if (transport.boundAddress() != null && logger.isInfoEnabled()) {
        logger.info("{}", transport.boundAddress());
        for (Map.Entry<String, BoundTransportAddress> entry : transport.profileBoundAddresses().entrySet()) {
            logger.info("profile [{}]: {}", entry.getKey(), entry.getValue());
        }
    }
    localNode = localNodeFactory.apply(transport.boundAddress());
    registerRequestHandler(
        HANDSHAKE_ACTION_NAME,
        () -> HandshakeRequest.INSTANCE,
        ThreadPool.Names.SAME,
        false, false,
        (request, channel) -> channel.sendResponse(
                new HandshakeResponse(localNode, clusterName, localNode.getVersion())));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:TransportService.java

示例3: toXContent

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.TRANSPORT);
    builder.array(Fields.BOUND_ADDRESS, (Object[]) address.boundAddresses());
    builder.field(Fields.PUBLISH_ADDRESS, address.publishAddress().toString());
    builder.startObject(Fields.PROFILES);
    if (profileAddresses != null && profileAddresses.size() > 0) {
        for (Map.Entry<String, BoundTransportAddress> entry : profileAddresses.entrySet()) {
            builder.startObject(entry.getKey());
            builder.array(Fields.BOUND_ADDRESS, (Object[]) entry.getValue().boundAddresses());
            builder.field(Fields.PUBLISH_ADDRESS, entry.getValue().publishAddress().toString());
            builder.endObject();
        }
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:TransportInfo.java

示例4: testEnforceLimitsWhenBoundToNonLocalAddress

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
public void testEnforceLimitsWhenBoundToNonLocalAddress() {
    final List<TransportAddress> transportAddresses = new ArrayList<>();
    final TransportAddress nonLocalTransportAddress = buildNewFakeTransportAddress();
    transportAddresses.add(nonLocalTransportAddress);

    for (int i = 0; i < randomIntBetween(0, 7); i++) {
        final TransportAddress randomTransportAddress = randomBoolean() ? buildNewFakeTransportAddress() :
            new TransportAddress(InetAddress.getLoopbackAddress(), i);
        transportAddresses.add(randomTransportAddress);
    }

    final TransportAddress publishAddress = randomBoolean() ? buildNewFakeTransportAddress() :
        new TransportAddress(InetAddress.getLoopbackAddress(), 0);

    final BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class);
    Collections.shuffle(transportAddresses, random());
    when(boundTransportAddress.boundAddresses()).thenReturn(transportAddresses.toArray(new TransportAddress[0]));
    when(boundTransportAddress.publishAddress()).thenReturn(publishAddress);

    assertTrue(BootstrapChecks.enforceLimits(boundTransportAddress));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:BootstrapCheckTests.java

示例5: createTransportSvc

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
@Before
public void createTransportSvc() {
    MockTcpTransport transport =
        new MockTcpTransport(Settings.EMPTY,
                                threadPool,
                                BigArrays.NON_RECYCLING_INSTANCE,
                                new NoneCircuitBreakerService(),
                                new NamedWriteableRegistry(Collections.emptyList()),
                                new NetworkService(Settings.EMPTY, Collections.emptyList())) {
            @Override
            public BoundTransportAddress boundAddress() {
                return new BoundTransportAddress(
                    new TransportAddress[]{new TransportAddress(InetAddress.getLoopbackAddress(), 9300)},
                    new TransportAddress(InetAddress.getLoopbackAddress(), 9300)
                );
            }
        };
    transportService = new MockTransportService(Settings.EMPTY, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR,
            null);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:FileBasedUnicastHostsProviderTests.java

示例6: info

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
@Override
public HttpInfo info() {
    BoundTransportAddress boundTransportAddress = boundAddress();
    if (boundTransportAddress == null) {
        return null;
    }
    return new HttpInfo(boundTransportAddress, maxContentLength.getBytes());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:Netty4HttpServerTransport.java

示例7: testDifferentPorts

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
public void testDifferentPorts() throws Exception {
    if (!NetworkUtils.SUPPORTS_V6) {
        return;
    }
    logger.info("--> starting a node on ipv4 only");
    Settings ipv4Settings = Settings.builder().put("network.host", "127.0.0.1").build();
    String ipv4OnlyNode = internalCluster().startNode(ipv4Settings); // should bind 127.0.0.1:XYZ

    logger.info("--> starting a node on ipv4 and ipv6");
    Settings bothSettings = Settings.builder().put("network.host", "_local_").build();
    internalCluster().startNode(bothSettings); // should bind [::1]:XYZ and 127.0.0.1:XYZ+1

    logger.info("--> waiting for the cluster to declare itself stable");
    ensureStableCluster(2); // fails if port of publish address does not match corresponding bound address

    logger.info("--> checking if boundAddress matching publishAddress has same port");
    NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get();
    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        BoundTransportAddress boundTransportAddress = nodeInfo.getTransport().getAddress();
        if (nodeInfo.getNode().getName().equals(ipv4OnlyNode)) {
            assertThat(boundTransportAddress.boundAddresses().length, equalTo(1));
            assertThat(boundTransportAddress.boundAddresses()[0].getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
        } else {
            assertThat(boundTransportAddress.boundAddresses().length, greaterThan(1));
            for (TransportAddress boundAddress : boundTransportAddress.boundAddresses()) {
                assertThat(boundAddress, instanceOf(TransportAddress.class));
                TransportAddress inetBoundAddress = (TransportAddress) boundAddress;
                if (inetBoundAddress.address().getAddress() instanceof Inet4Address) {
                    // IPv4 address is preferred publish address for _local_
                    assertThat(inetBoundAddress.getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:Netty4TransportPublishAddressIT.java

示例8: MockTransportService

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
/**
 * Build the service.
 *
 * @param clusterSettings if non null the the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings
 *        updates for {@link #TRACE_LOG_EXCLUDE_SETTING} and {@link #TRACE_LOG_INCLUDE_SETTING}.
 */
public MockTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor,
                            Function<BoundTransportAddress, DiscoveryNode> localNodeFactory,
                            @Nullable ClusterSettings clusterSettings) {
    super(settings, new LookupTestTransport(transport), threadPool, interceptor, localNodeFactory, clusterSettings);
    this.original = transport;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MockTransportService.java

示例9: extractTransportAddresses

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
public static TransportAddress[] extractTransportAddresses(TransportService transportService) {
    HashSet<TransportAddress> transportAddresses = new HashSet<>();
    BoundTransportAddress boundTransportAddress = transportService.boundAddress();
    transportAddresses.addAll(Arrays.asList(boundTransportAddress.boundAddresses()));
    transportAddresses.add(boundTransportAddress.publishAddress());
    return transportAddresses.toArray(new TransportAddress[transportAddresses.size()]);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:MockTransportService.java

示例10: newTransportService

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
@Override
protected TransportService newTransportService(Settings settings, Transport transport, ThreadPool threadPool,
                                               TransportInterceptor interceptor,
                                               Function<BoundTransportAddress, DiscoveryNode> localNodeFactory,
                                               ClusterSettings clusterSettings) {
    // we use the MockTransportService.TestPlugin class as a marker to create a network
    // module with this MockNetworkService. NetworkService is such an integral part of the systme
    // we don't allow to plug it in from plugins or anything. this is a test-only override and
    // can't be done in a production env.
    if (getPluginsService().filterPlugins(MockTransportService.TestPlugin.class).isEmpty()) {
        return super.newTransportService(settings, transport, threadPool, interceptor, localNodeFactory, clusterSettings);
    } else {
        return new MockTransportService(settings, transport, threadPool, interceptor, localNodeFactory, clusterSettings);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:MockNode.java

示例11: info

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
public TransportInfo info() {
    BoundTransportAddress boundTransportAddress = boundAddress();
    if (boundTransportAddress == null) {
        return null;
    }
    return new TransportInfo(boundTransportAddress, transport.profileBoundAddresses());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportService.java

示例12: createBoundTransportAddress

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
private BoundTransportAddress createBoundTransportAddress(String name, Settings profileSettings,
                                                          List<InetSocketAddress> boundAddresses) {
    String[] boundAddressesHostStrings = new String[boundAddresses.size()];
    TransportAddress[] transportBoundAddresses = new TransportAddress[boundAddresses.size()];
    for (int i = 0; i < boundAddresses.size(); i++) {
        InetSocketAddress boundAddress = boundAddresses.get(i);
        boundAddressesHostStrings[i] = boundAddress.getHostString();
        transportBoundAddresses[i] = new TransportAddress(boundAddress);
    }

    final String[] publishHosts;
    if (TransportSettings.DEFAULT_PROFILE.equals(name)) {
        publishHosts = TransportSettings.PUBLISH_HOST.get(settings).toArray(Strings.EMPTY_ARRAY);
    } else {
        publishHosts = profileSettings.getAsArray("publish_host", boundAddressesHostStrings);
    }

    final InetAddress publishInetAddress;
    try {
        publishInetAddress = networkService.resolvePublishHostAddresses(publishHosts);
    } catch (Exception e) {
        throw new BindTransportException("Failed to resolve publish address", e);
    }

    final int publishPort = resolvePublishPort(name, settings, profileSettings, boundAddresses, publishInetAddress);
    final TransportAddress publishAddress = new TransportAddress(new InetSocketAddress(publishInetAddress, publishPort));
    return new BoundTransportAddress(transportBoundAddresses, publishAddress);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:TcpTransport.java

示例13: TransportInfo

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
public TransportInfo(StreamInput in) throws IOException {
    address = BoundTransportAddress.readBoundTransportAddress(in);
    int size = in.readVInt();
    if (size > 0) {
        profileAddresses = new HashMap<>(size);
        for (int i = 0; i < size; i++) {
            String key = in.readString();
            BoundTransportAddress value = BoundTransportAddress.readBoundTransportAddress(in);
            profileAddresses.put(key, value);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:TransportInfo.java

示例14: writeTo

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    address.writeTo(out);
    if (profileAddresses != null) {
        out.writeVInt(profileAddresses.size());
    } else {
        out.writeVInt(0);
    }
    if (profileAddresses != null && profileAddresses.size() > 0) {
        for (Map.Entry<String, BoundTransportAddress> entry : profileAddresses.entrySet()) {
            out.writeString(entry.getKey());
            entry.getValue().writeTo(out);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:TransportInfo.java

示例15: check

import org.elasticsearch.common.transport.BoundTransportAddress; //导入依赖的package包/类
/**
 * Executes the bootstrap checks if the node has the transport protocol bound to a non-loopback interface.
 *
 * @param settings              the current node settings
 * @param boundTransportAddress the node network bindings
 */
static void check(final Settings settings, final BoundTransportAddress boundTransportAddress, List<BootstrapCheck> additionalChecks)
    throws NodeValidationException {
    final List<BootstrapCheck> builtInChecks = checks(settings);
    final List<BootstrapCheck> combinedChecks = new ArrayList<>(builtInChecks);
    combinedChecks.addAll(additionalChecks);
    check(
            enforceLimits(boundTransportAddress),
            Collections.unmodifiableList(combinedChecks),
            Node.NODE_NAME_SETTING.get(settings));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BootstrapChecks.java


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