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


Java NetworkModule类代码示例

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


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

示例1: assertTribeNodeSuccessfullyCreated

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
private static void assertTribeNodeSuccessfullyCreated(Settings extraSettings) throws Exception {
    //The tribe clients do need it to make sure they can find their corresponding tribes using the proper transport
    Settings settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put("node.name", "tribe_node")
            .put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put("discovery.type", "local")
            .put("tribe.t1.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
            .put("tribe.t2.transport.type",MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
            .put(extraSettings).build();

    try (Node node = new MockNode(settings, Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class)).start()) {
        try (Client client = node.client()) {
            assertBusy(() -> {
                ClusterState state = client.admin().cluster().prepareState().clear().setNodes(true).get().getState();
                assertThat(state.getClusterName().value(), equalTo("tribe_node_cluster"));
                assertThat(state.getNodes().getSize(), equalTo(5));
                for (DiscoveryNode discoveryNode : state.getNodes()) {
                    assertThat(discoveryNode.getName(), either(equalTo("tribe1_node")).or(equalTo("tribe2_node"))
                            .or(equalTo("tribe_node")).or(equalTo("tribe_node/t1")).or(equalTo("tribe_node/t2")));
                }
            });
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TribeUnitTests.java

示例2: createClient

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@Override
public Client createClient(Map<String, String> clientConfig) {
	Settings settings = Settings.builder().put(clientConfig)
		.put(NetworkModule.HTTP_TYPE_KEY, Netty3Plugin.NETTY_HTTP_TRANSPORT_NAME)
		.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty3Plugin.NETTY_TRANSPORT_NAME)
		.build();

	TransportClient transportClient = new PreBuiltTransportClient(settings);
	for (TransportAddress transport : ElasticsearchUtils.convertInetSocketAddresses(transportAddresses)) {
		transportClient.addTransportAddress(transport);
	}

	// verify that we actually are connected to a cluster
	if (transportClient.connectedNodes().isEmpty()) {
		throw new RuntimeException("Elasticsearch client is not connected to any Elasticsearch nodes!");
	}

	if (LOG.isInfoEnabled()) {
		LOG.info("Created Elasticsearch TransportClient with connected nodes {}", transportClient.connectedNodes());
	}

	return transportClient;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:Elasticsearch5ApiCallBridge.java

示例3: testThatTransportClientCanConnect

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
public void testThatTransportClientCanConnect() throws Exception {
    Settings settings = Settings.builder()
        .put("cluster.name", internalCluster().getClusterName())
        .put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME)
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
        .build();
    try (TransportClient transportClient = new MockTransportClient(settings, Netty4Plugin.class)) {
        transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), randomPort));
        ClusterHealthResponse response = transportClient.admin().cluster().prepareHealth().get();
        assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:Netty4TransportMultiPortIntegrationIT.java

示例4: nodeSettings

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
/**
 * Lower the queue sizes to be small enough that both bulk and searches will time out and have to be retried.
 */
@Override
protected Settings nodeSettings() {
    Settings.Builder settings = Settings.builder().put(super.nodeSettings());
    // Use pools of size 1 so we can block them
    settings.put("thread_pool.bulk.size", 1);
    settings.put("thread_pool.search.size", 1);
    // Use queues of size 1 because size 0 is broken and because search requests need the queue to function
    settings.put("thread_pool.bulk.queue_size", 1);
    settings.put("thread_pool.search.queue_size", 1);
    // Enable http so we can test retries on reindex from remote. In this case the "remote" cluster is just this cluster.
    settings.put(NetworkModule.HTTP_ENABLED.getKey(), true);
    // Whitelist reindexing from the http host we're going to use
    settings.put(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getKey(), "127.0.0.1:*");
    return settings.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RetryTests.java

示例5: testPluginInstalled

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@Test
public void testPluginInstalled() {
    try (TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)) {
        Settings settings = client.settings();
        assertEquals(Netty4Plugin.NETTY_TRANSPORT_NAME, NetworkModule.HTTP_DEFAULT_TYPE_SETTING.get(settings));
        assertEquals(Netty4Plugin.NETTY_TRANSPORT_NAME, NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.get(settings));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:PreBuiltTransportClientTests.java

示例6: startClient

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
private static Client startClient(Path tempDir, TransportAddress... transportAddresses) {
    Settings.Builder builder = Settings.builder()
        .put("node.name", "qa_smoke_client_" + counter.getAndIncrement())
        .put("client.transport.ignore_cluster_name", true)
        .put(Environment.PATH_HOME_SETTING.getKey(), tempDir);
    final Collection<Class<? extends Plugin>> plugins;
    if (random().nextBoolean()) {
        builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
        plugins = Collections.singleton(MockTcpTransportPlugin.class);
    } else {
        plugins = Collections.emptyList();
    }
    TransportClient client = new PreBuiltTransportClient(builder.build(), plugins).addTransportAddresses(transportAddresses);

    logger.info("--> Elasticsearch Java TransportClient started");

    Exception clientException = null;
    try {
        ClusterHealthResponse health = client.admin().cluster().prepareHealth().get();
        logger.info("--> connected to [{}] cluster which is running [{}] node(s).",
                health.getClusterName(), health.getNumberOfNodes());
    } catch (Exception e) {
        clientException = e;
    }

    assumeNoException("Sounds like your cluster is not running at " + clusterAddresses, clientException);

    return client;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:ESSmokeClientTestCase.java

示例7: createTribes

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@BeforeClass
public static void createTribes() throws NodeValidationException {
    Settings baseSettings = Settings.builder()
        .put(NetworkModule.HTTP_ENABLED.getKey(), false)
        .put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
        .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
        .put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2)
        .build();

    final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class);
    tribe1 = new MockNode(
        Settings.builder()
            .put(baseSettings)
            .put("cluster.name", "tribe1")
            .put("node.name", "tribe1_node")
                .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
            .build(), mockPlugins).start();
    tribe2 = new MockNode(
        Settings.builder()
            .put(baseSettings)
            .put("cluster.name", "tribe2")
            .put("node.name", "tribe2_node")
                .put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong())
            .build(), mockPlugins).start();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TribeUnitTests.java

示例8: nodeSettings

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@Override
public Settings nodeSettings(int nodeOrdinal) {
    Settings.Builder builder = Settings.builder().put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), numOfNodes);

    String[] unicastHosts = new String[unicastHostOrdinals.length];
    if (nodeOrdinal >= unicastHostPorts.length) {
        throw new ElasticsearchException("nodeOrdinal [" + nodeOrdinal + "] is greater than the number unicast ports [" + unicastHostPorts.length + "]");
    } else {
        // we need to pin the node port & host so we'd know where to point things
        builder.put(TransportSettings.PORT.getKey(), unicastHostPorts[nodeOrdinal]);
        builder.put(TransportSettings.HOST.getKey(), IP_ADDR); // only bind on one IF we use v4 here by default
        builder.put(NetworkModule.HTTP_ENABLED.getKey(), false);
        for (int i = 0; i < unicastHostOrdinals.length; i++) {
            unicastHosts[i] = IP_ADDR + ":" + (unicastHostPorts[unicastHostOrdinals[i]]);
        }
    }
    builder.putArray("discovery.zen.ping.unicast.hosts", unicastHosts);
    return builder.put(super.nodeSettings(nodeOrdinal)).build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ClusterDiscoveryConfiguration.java

示例9: testNodeName

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
public void testNodeName() throws IOException {
    final Path tempDir = createTempDir();
    final String name = randomBoolean() ? randomAsciiOfLength(10) : null;
    Settings.Builder settings = Settings.builder()
        .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", randomLong()))
        .put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
        .put(NetworkModule.HTTP_ENABLED.getKey(), false)
        .put("transport.type", "mock-socket-network")
        .put(Node.NODE_DATA_SETTING.getKey(), true);
    if (name != null) {
        settings.put(Node.NODE_NAME_SETTING.getKey(), name);
    }
    try (Node node = new MockNode(settings.build(), Collections.singleton(MockTcpTransportPlugin.class))) {
        final Settings nodeSettings = randomBoolean() ? node.settings() : node.getEnvironment().settings();
        if (name == null) {
            assertThat(Node.NODE_NAME_SETTING.get(nodeSettings), equalTo(node.getNodeEnvironment().nodeId().substring(0, 7)));
        } else {
            assertThat(Node.NODE_NAME_SETTING.get(nodeSettings), equalTo(name));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:NodeTests.java

示例10: testMinimalSettings

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
public void testMinimalSettings() {
    Settings globalSettings = Settings.builder()
        .put("node.name", "nodename")
        .put("path.home", "some/path").build();
    Settings clientSettings = TribeService.buildClientSettings("tribe1", "parent_id", globalSettings, Settings.EMPTY);
    assertEquals("some/path", clientSettings.get("path.home"));
    assertEquals("nodename/tribe1", clientSettings.get("node.name"));
    assertEquals("tribe1", clientSettings.get("tribe.name"));
    assertFalse(NetworkModule.HTTP_ENABLED.get(clientSettings));
    assertEquals("false", clientSettings.get("node.master"));
    assertEquals("false", clientSettings.get("node.data"));
    assertEquals("false", clientSettings.get("node.ingest"));
    assertEquals("false", clientSettings.get("node.local_storage"));
    assertEquals("3707202549613653169", clientSettings.get("node.id.seed")); // should be fixed by the parent id and tribe name
    assertEquals(9, clientSettings.size());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:TribeServiceTests.java

示例11: createTribeSettings

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
private Settings.Builder createTribeSettings(Predicate<InternalTestCluster> filter) {
    assertNotNull(filter);

    final Settings.Builder settings = Settings.builder();
    settings.put(Node.NODE_NAME_SETTING.getKey(), TRIBE_NODE);
    settings.put(Node.NODE_DATA_SETTING.getKey(), false);
    settings.put(Node.NODE_MASTER_SETTING.getKey(), true);
    settings.put(NetworkModule.HTTP_ENABLED.getKey(), false);
    settings.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);

    doWithAllClusters(filter, c -> {
        String tribeSetting = "tribe." + c.getClusterName() + ".";
        settings.put(tribeSetting + ClusterName.CLUSTER_NAME_SETTING.getKey(), c.getClusterName());
        settings.put(tribeSetting + DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), "100ms");
        settings.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
    });

    return settings;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:TribeIT.java

示例12: testSerializeRequest

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
public void testSerializeRequest() throws IOException {
    ClusterRerouteRequest req = new ClusterRerouteRequest();
    req.setRetryFailed(randomBoolean());
    req.dryRun(randomBoolean());
    req.explain(randomBoolean());
    req.add(new AllocateEmptyPrimaryAllocationCommand("foo", 1, "bar", randomBoolean()));
    req.timeout(TimeValue.timeValueMillis(randomIntBetween(0, 100)));
    BytesStreamOutput out = new BytesStreamOutput();
    req.writeTo(out);
    BytesReference bytes = out.bytes();
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(NetworkModule.getNamedWriteables());
    StreamInput wrap = new NamedWriteableAwareStreamInput(bytes.streamInput(),
        namedWriteableRegistry);
    ClusterRerouteRequest deserializedReq = new ClusterRerouteRequest();
    deserializedReq.readFrom(wrap);

    assertEquals(req.isRetryFailed(), deserializedReq.isRetryFailed());
    assertEquals(req.dryRun(), deserializedReq.dryRun());
    assertEquals(req.explain(), deserializedReq.explain());
    assertEquals(req.timeout(), deserializedReq.timeout());
    assertEquals(1, deserializedReq.getCommands().commands().size()); // allocation commands have their own tests
    assertEquals(req.getCommands().commands().size(), deserializedReq.getCommands().commands().size());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ClusterRerouteTests.java

示例13: newNode

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@Bean(destroyMethod="close")
Node newNode() throws NodeValidationException {
  final Path tempDir = createTempDir().toPath();
  final Settings settings = Settings.builder()
    .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), new ClusterName("single-node-cluster" + System.nanoTime()))
    .put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
    .put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo"))
    .put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir().getParent())
    .put("node.name", "single-node")
    .put("script.inline", "true")
    .put("script.stored", "true")
    .put(ScriptService.SCRIPT_MAX_COMPILATIONS_PER_MINUTE.getKey(), 1000)
    .put(EsExecutors.PROCESSORS_SETTING.getKey(), 1)
    .put(NetworkModule.HTTP_ENABLED.getKey(), false)
    .put("discovery.type", "zen")
    .put("transport.type", "local")
    .put(Node.NODE_DATA_SETTING.getKey(), true)
    .put(NODE_ID_SEED_SETTING.getKey(), System.nanoTime())
    .build();
  return new Node(settings).start(); // NOSONAR
}
 
开发者ID:jloisel,项目名称:elastic-crud,代码行数:22,代码来源:NodeTestConfig.java

示例14: start

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@Override
public void start(File tmpDataFolder, String clusterName) throws Exception {
	if (node == null) {
		Settings settings = Settings.builder()
			.put("cluster.name", clusterName)
			.put("http.enabled", false)
			.put("path.home", tmpDataFolder.getParent())
			.put("path.data", tmpDataFolder.getAbsolutePath())
			.put(NetworkModule.HTTP_TYPE_KEY, Netty3Plugin.NETTY_HTTP_TRANSPORT_NAME)
			.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty3Plugin.NETTY_TRANSPORT_NAME)
			.build();

		node = new PluginNode(settings);
		node.start();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:EmbeddedElasticsearchNodeEnvironmentImpl.java

示例15: additionalSettings

import org.elasticsearch.common.network.NetworkModule; //导入依赖的package包/类
@Override
public Settings additionalSettings() {
   final Settings.Builder builder = Settings.builder();
    
   if(!client && httpSSLEnabled) {
       
       if(settings.get("http.compression") == null) {
           builder.put("http.compression", false);
           log.info("Disabled https compression by default to mitigate BREACH attacks. You can enable it by setting 'http.compression: true' in elasticsearch.yml");
       }
       
       builder.put(NetworkModule.HTTP_TYPE_KEY, "com.floragunn.searchguard.ssl.http.netty.SearchGuardSSLNettyHttpServerTransport");
   }
    
   if (transportSSLEnabled) {
       builder.put(NetworkModule.TRANSPORT_TYPE_KEY, "com.floragunn.searchguard.ssl.http.netty.SearchGuardSSLNettyTransport");
   }
    
    return builder.build();
}
 
开发者ID:floragunncom,项目名称:search-guard-ssl,代码行数:21,代码来源:SearchGuardSSLPlugin.java


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