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


Java NetworkService类代码示例

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


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

示例1: nettyFromThreadPool

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
public static MockTransportService nettyFromThreadPool(Settings settings, ThreadPool threadPool, final Version version,
        ClusterSettings clusterSettings, boolean doHandshake) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    Transport transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()),
        BigArrays.NON_RECYCLING_INSTANCE, namedWriteableRegistry, new NoneCircuitBreakerService()) {

        @Override
        protected Version executeHandshake(DiscoveryNode node, Channel channel, TimeValue timeout) throws IOException,
            InterruptedException {
            if (doHandshake) {
                return super.executeHandshake(node, channel, timeout);
            } else {
                return version.minimumCompatibilityVersion();
            }
        }

        @Override
        protected Version getCurrentVersion() {
            return version;
        }
    };
    MockTransportService mockTransportService =
        MockTransportService.createNewService(Settings.EMPTY, transport, version, threadPool, clusterSettings);
    mockTransportService.start();
    return mockTransportService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:SimpleNetty4TransportTests.java

示例2: testHandshakeWithIncompatVersion

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
public void testHandshakeWithIncompatVersion() {
    assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    try (MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
        new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList()),
        Version.fromString("2.0.0"))) {
        transport.transportServiceAdapter(serviceA.new Adapter());
        transport.start();
        DiscoveryNode node =
            new DiscoveryNode("TS_TPC", "TS_TPC", transport.boundAddress().publishAddress(), emptyMap(), emptySet(), version0);
        ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
        builder.addConnections(1,
            TransportRequestOptions.Type.BULK,
            TransportRequestOptions.Type.PING,
            TransportRequestOptions.Type.RECOVERY,
            TransportRequestOptions.Type.REG,
            TransportRequestOptions.Type.STATE);
        expectThrows(ConnectTransportException.class, () -> serviceA.openConnection(node, builder.build()));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:AbstractSimpleTransportTestCase.java

示例3: testHandshakeUpdatesVersion

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
public void testHandshakeUpdatesVersion() throws IOException {
    assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    Version version = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
    try (MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
        new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList()),version)) {
        transport.transportServiceAdapter(serviceA.new Adapter());
        transport.start();
        DiscoveryNode node =
            new DiscoveryNode("TS_TPC", "TS_TPC", transport.boundAddress().publishAddress(), emptyMap(), emptySet(),
                Version.fromString("2.0.0"));
        ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
        builder.addConnections(1,
            TransportRequestOptions.Type.BULK,
            TransportRequestOptions.Type.PING,
            TransportRequestOptions.Type.RECOVERY,
            TransportRequestOptions.Type.REG,
            TransportRequestOptions.Type.STATE);
        try (Transport.Connection connection = serviceA.openConnection(node, builder.build())) {
            assertEquals(connection.getVersion(), version);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:AbstractSimpleTransportTestCase.java

示例4: build

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
@Override
protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
        new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version) {
        @Override
        protected Version executeHandshake(DiscoveryNode node, MockChannel mockChannel, TimeValue timeout) throws IOException,
            InterruptedException {
            if (doHandshake) {
                return super.executeHandshake(node, mockChannel, timeout);
            } else {
                return version.minimumCompatibilityVersion();
            }
        }
    };
    MockTransportService mockTransportService =
        MockTransportService.createNewService(Settings.EMPTY, transport, version, threadPool, clusterSettings);
    mockTransportService.start();
    return mockTransportService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:MockTcpTransportTests.java

示例5: build

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
protected MockTransportService build(Settings settings, Version version) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    MockTransportService transportService =
        new MockTransportService(
            Settings.builder()
                .put(settings)
                // trace zenfd actions but keep the default otherwise
                .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), singleton(TransportLivenessAction.NAME))
                .build(),
            new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService,
                namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version),
            threadPool,
            TransportService.NOOP_TRANSPORT_INTERCEPTOR,
            (boundAddress) ->
                new DiscoveryNode(Node.NODE_NAME_SETTING.get(settings), boundAddress.publishAddress(),
                    Node.NODE_ATTRIBUTES.get(settings).getAsMap(), DiscoveryNode.getRolesFromSettings(settings), version),
            null);
    transportService.start();
    transportService.acceptIncomingRequests();
    return transportService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ZenFaultDetectionTests.java

示例6: setUp

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder()
            .put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false)
            .build();
    clusterService = createClusterService(threadPool);
    Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
            new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()),
            new NetworkService(settings, Collections.emptyList()));
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool,
        TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ShardStateAction shardStateAction = new ShardStateAction(settings, clusterService, transportService, null, null, threadPool);
    ActionFilters actionFilters = new ActionFilters(Collections.emptySet());
    IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
    AutoCreateIndex autoCreateIndex = new AutoCreateIndex(settings, new ClusterSettings(settings,
            ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), indexNameExpressionResolver);
    UpdateHelper updateHelper = new UpdateHelper(settings, null);
    TransportShardBulkAction shardBulkAction = new TransportShardBulkAction(settings, transportService, clusterService,
            indicesService, threadPool, shardStateAction, null, updateHelper, actionFilters, indexNameExpressionResolver);
    transportBulkAction = new TransportBulkAction(settings, threadPool, transportService, clusterService,
            null, shardBulkAction, null, actionFilters, indexNameExpressionResolver, autoCreateIndex, System::currentTimeMillis);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:DynamicMappingDisabledTests.java

示例7: startServices

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
private NetworkHandle startServices(String nodeNameAndId, Settings settings, Version version) {
    MockTcpTransport transport =
            new MockTcpTransport(
                settings,
                    threadPool,
                    BigArrays.NON_RECYCLING_INSTANCE,
                    new NoneCircuitBreakerService(),
                    new NamedWriteableRegistry(Collections.emptyList()),
                    new NetworkService(settings, Collections.emptyList()));
    TransportService transportService = new MockTransportService(settings, transport, threadPool,
        TransportService.NOOP_TRANSPORT_INTERCEPTOR, (boundAddress) -> new DiscoveryNode(
        nodeNameAndId,
        nodeNameAndId,
        boundAddress.publishAddress(),
        emptyMap(),
        emptySet(),
        version), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    transportServices.add(transportService);
    return new NetworkHandle(transportService, transportService.getLocalNode());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:TransportServiceHandshakeTests.java

示例8: createTransportSvc

import org.elasticsearch.common.network.NetworkService; //导入依赖的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

示例9: AzureUnicastHostsProvider

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
public AzureUnicastHostsProvider(Settings settings, AzureComputeService azureComputeService,
                                 TransportService transportService, NetworkService networkService) {
    super(settings);
    this.azureComputeService = azureComputeService;
    this.transportService = transportService;
    this.networkService = networkService;

    this.refreshInterval = Discovery.REFRESH_SETTING.get(settings);

    this.hostType = Discovery.HOST_TYPE_SETTING.get(settings);
    this.publicEndpointName = Discovery.ENDPOINT_NAME_SETTING.get(settings);

    // Deployment name could be set with discovery.azure.deployment.name
    // Default to cloud.azure.management.cloud.service.name
    this.deploymentName = Discovery.DEPLOYMENT_NAME_SETTING.get(settings);

    // Reading deployment_slot
    this.deploymentSlot = Discovery.DEPLOYMENT_SLOT_SETTING.get(settings).slot;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:AzureUnicastHostsProvider.java

示例10: GceUnicastHostsProvider

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
public GceUnicastHostsProvider(Settings settings, GceInstancesService gceInstancesService,
        TransportService transportService,
        NetworkService networkService) {
    super(settings);
    this.gceInstancesService = gceInstancesService;
    this.transportService = transportService;
    this.networkService = networkService;

    this.refreshInterval = GceInstancesService.REFRESH_SETTING.get(settings);
    this.project = GceInstancesService.PROJECT_SETTING.get(settings);
    this.zones = GceInstancesService.ZONE_SETTING.get(settings);

    this.tags = TAGS_SETTING.get(settings);
    if (logger.isDebugEnabled()) {
        logger.debug("using tags {}", this.tags);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:GceUnicastHostsProvider.java

示例11: resolveGce

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
/**
 * Utility test method to test different settings
 * @param gceNetworkSetting tested network.host property
 * @param expected expected InetAddress, null if we expect an exception
 * @throws IOException Well... If something goes wrong :)
 */
private void resolveGce(String gceNetworkSetting, InetAddress[] expected) throws IOException {
    Settings nodeSettings = Settings.builder()
            .put("network.host", gceNetworkSetting)
            .build();

    GceMetadataServiceMock mock = new GceMetadataServiceMock(nodeSettings);
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new GceNameResolver(nodeSettings, mock)));
    try {
        InetAddress[] addresses = networkService.resolveBindHostAddresses(null);
        if (expected == null) {
            fail("We should get a IllegalArgumentException when setting network.host: _gce:doesnotexist_");
        }
        assertThat(addresses, arrayContaining(expected));
    } catch (IllegalArgumentException e) {
        if (expected != null) {
            // We were expecting something and not an exception
            throw e;
        }
        // We check that we get the expected exception
        assertThat(e.getMessage(), containsString("is not one of the supported GCE network.host setting"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:GceNetworkTests.java

示例12: getHttpTransports

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
        CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry,
        NamedXContentRegistry xContentRegistry, NetworkService networkService, Dispatcher dispatcher) {
    
    Map<String, Supplier<HttpServerTransport>> httpTransports = new HashMap<String, Supplier<HttpServerTransport>>(1);

    if(!disabled) {
        if (!client && httpSSLEnabled && !tribeNodeClient) {
            
            final ValidatingDispatcher validatingDispatcher = new ValidatingDispatcher(threadPool.getThreadContext(), dispatcher, 
                    settings, configPath, evaluateSslExceptionHandler());
            final SearchGuardHttpServerTransport sghst = new SearchGuardHttpServerTransport(settings, networkService, bigArrays, 
                    threadPool, sgks, evaluateSslExceptionHandler(), xContentRegistry, validatingDispatcher);
            
            httpTransports.put("com.floragunn.searchguard.http.SearchGuardHttpServerTransport", 
                    () -> sghst);
        } else if (!client && !tribeNodeClient) {
            httpTransports.put("com.floragunn.searchguard.http.SearchGuardHttpServerTransport", 
                    () -> new SearchGuardNonSslHttpServerTransport(settings, networkService, bigArrays, threadPool, xContentRegistry, dispatcher));
        }
    }
    return httpTransports;
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:25,代码来源:SearchGuardPlugin.java

示例13: getHttpTransports

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
        CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry,
        NamedXContentRegistry xContentRegistry, NetworkService networkService, Dispatcher dispatcher) {
    
    final Map<String, Supplier<HttpServerTransport>> httpTransports = new HashMap<String, Supplier<HttpServerTransport>>(1);
    if (!client && httpSSLEnabled) {
        
        final ValidatingDispatcher validatingDispatcher = new ValidatingDispatcher(threadPool.getThreadContext(), dispatcher, settings, configPath, NOOP_SSL_EXCEPTION_HANDLER);
        final SearchGuardSSLNettyHttpServerTransport sgsnht = new SearchGuardSSLNettyHttpServerTransport(settings, networkService, bigArrays, threadPool, sgks, xContentRegistry, validatingDispatcher, NOOP_SSL_EXCEPTION_HANDLER);
        
        httpTransports.put("com.floragunn.searchguard.ssl.http.netty.SearchGuardSSLNettyHttpServerTransport", () -> sgsnht);
        
    }
    return httpTransports;
}
 
开发者ID:floragunncom,项目名称:search-guard-ssl,代码行数:17,代码来源:SearchGuardSSLPlugin.java

示例14: createClient

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
protected Client createClient() {
    if (addresses.isEmpty()) throw new Error("addresses must not be empty");
    StopWatch watch = new StopWatch();
    try {
        Settings.Builder settings = Settings.builder();
        settings.put(NetworkService.TCP_CONNECT_TIMEOUT.getKey(), new TimeValue(timeout.toMillis()))
                .put(TransportClient.CLIENT_TRANSPORT_PING_TIMEOUT.getKey(), new TimeValue(timeout.toMillis()))
                .put(TransportClient.CLIENT_TRANSPORT_PING_TIMEOUT.getKey(), new TimeValue(timeout.toMillis()))
                .put(TransportClient.CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME.getKey(), "true");     // refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html
        if (sniff) {
            settings.put(TransportClient.CLIENT_TRANSPORT_SNIFF.getKey(), true);
        }
        TransportClient client = new PreBuiltTransportClient(settings.build());
        addresses.forEach(client::addTransportAddress);
        return client;
    } finally {
        logger.info("create elasticsearch client, addresses={}, elapsedTime={}", addresses, watch.elapsedTime());
    }
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:20,代码来源:ElasticSearchImpl.java

示例15: createClient

import org.elasticsearch.common.network.NetworkService; //导入依赖的package包/类
@Override
protected Client createClient() {
    StopWatch watch = new StopWatch();
    try {
        Settings.Builder settings = Settings.builder();
        settings.put(Environment.PATH_HOME_SETTING.getKey(), dataPath)
                .put(NetworkModule.HTTP_ENABLED.getKey(), false)
                .put(NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.getKey(), "_local_")
                .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "single-node");
        MockNode node = new MockNode(settings.build());
        node.start();
        return node.client();
    } catch (NodeValidationException e) {
        throw new Error(e);
    } finally {
        logger.info("create local elasticsearch node, dataPath={}, elapsedTime={}", dataPath, watch.elapsedTime());
    }
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:19,代码来源:MockElasticSearch.java


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