org.elasticsearch.node.NodeBuilder Java Examples
The following examples show how to use
org.elasticsearch.node.NodeBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EsRetryTest.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() // .put("node.http.enabled", false) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #2
Source File: EsRetry2Test.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() .put("node.http.enabled", true) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #3
Source File: EsTestNode.java From io with Apache License 2.0 | 6 votes |
/** * テスト用のElasticsearchのNodeを初期化する. */ public void create() { Settings settings = Settings.settingsBuilder() .put("node.http.enabled", false) .put("cluster.name", "testingCluster") .put("node.name", "node1") // .put("gateway.type", "local") .put("action.auto_create_index", "false") .put("index.store.type", "mmapfs") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("path.home", ".") .put("transport.tcp.port", "9399") .build(); this.node = NodeBuilder.nodeBuilder().settings(settings).node(); }
Example #4
Source File: AbstractElasticSearchSinkTest.java From ingestion with Apache License 2.0 | 6 votes |
void createNodes() throws Exception { Settings settings = ImmutableSettings .settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 0) .put("routing.hash.type", "simple") .put("gateway.type", "none") .put("path.data", "target/es-test") .build(); node = NodeBuilder.nodeBuilder().settings(settings).local(true).node(); client = node.client(); client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute() .actionGet(); }
Example #5
Source File: EsRetryTest.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = Settings.settingsBuilder() .put("node.http.enabled", true) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") .put("path.home", ".") //.put("gateway.type", "local") .put("action.auto_create_index", "false") .put("index.store.type", "mmapfs") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #6
Source File: EsRetryTest.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = Settings.settingsBuilder() // .put("node.http.enabled", false) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") //.put("gateway.type", "none") .put("plugin.mandatory", "delete-by-query") //.put("plugin.types", DeleteByQueryPlugin.class.getName()) // https://github.com/elastic/elasticsearch/issues/13212 // https://github.com/elastic/elasticsearch/pull/15107 .put("path.plugins", "C:/soft/elasticsearch-2.3.3/plugins") .put("path.home", ".") .put("action.auto_create_index", "false") .put("index.store.type", "mmapfs") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #7
Source File: AbstractElasticSearchSinkTest.java From mt-flume with Apache License 2.0 | 6 votes |
void createNodes() throws Exception { Settings settings = ImmutableSettings .settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 0) .put("routing.hash.type", "simple") .put("gateway.type", "none") .put("path.data", "target/es-test") .build(); node = NodeBuilder.nodeBuilder().settings(settings).local(true).node(); client = node.client(); client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute() .actionGet(); }
Example #8
Source File: EsRetry2Test.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = Settings.settingsBuilder() .put("node.http.enabled", true) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") .put("path.home", ".") //.put("gateway.type", "local") .put("action.auto_create_index", "false") .put("index.store.type", "mmapfs") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #9
Source File: EsRetryTest.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = Settings.settingsBuilder() // .put("node.http.enabled", false) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #10
Source File: EsRetryTest.java From io with Apache License 2.0 | 6 votes |
/** * テストケース共通の初期化処理. テスト用のElasticsearchのNodeを初期化する * @throws Exception 異常が発生した場合の例外 */ @BeforeClass public static void setUpBeforeClass() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() // .put("node.http.enabled", false) .put("cluster.name", TESTING_CLUSTER) .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); node = NodeBuilder.nodeBuilder().settings(settings).node(); esClient = new EsClient(TESTING_CLUSTER, TESTING_HOSTS); }
Example #11
Source File: ClientFactory.java From storm-trident-elasticsearch with Apache License 2.0 | 5 votes |
@Override public Client makeClient(Map conf) { String clusterName = (String)conf.get(NAME); final Node node = NodeBuilder.nodeBuilder().settings(buildSettings(clusterName)).node(); registerShutdownHook(node); return node.client(); }
Example #12
Source File: EsTestNode.java From io with Apache License 2.0 | 5 votes |
/** * テスト用のElasticsearchのNodeを初期化する. */ public void create() { Settings settings = ImmutableSettings.settingsBuilder() .put("node.http.enabled", false) .put("cluster.name", "testingCluster") .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); this.node = NodeBuilder.nodeBuilder().settings(settings).node(); }
Example #13
Source File: EmbeddedElasticsearchNodeEnvironmentImpl.java From flink with Apache License 2.0 | 5 votes |
@Override public void start(File tmpDataFolder, String clusterName) throws Exception { if (node == null) { node = NodeBuilder.nodeBuilder().settings( Settings.settingsBuilder() .put("path.home", tmpDataFolder.getParent()) .put("http.enabled", false) .put("path.data", tmpDataFolder.getAbsolutePath())) .clusterName(clusterName) .node(); node.start(); } }
Example #14
Source File: ClientFactory.java From storm-trident-elasticsearch with Apache License 2.0 | 5 votes |
@Override public Client makeClient(Map conf) { final Node node = NodeBuilder.nodeBuilder().settings( buildSettings() ).node(); registerShutdownHook(node); return waitForYellowStatus(node.client()); }
Example #15
Source File: ESStorageEngine.java From BioSolr with Apache License 2.0 | 5 votes |
@SuppressWarnings("resource") @Override public void initialise() throws StorageEngineException { if (config.isUseNodeClient()) { Node node = new NodeBuilder().client(true).clusterName(config.getClusterName()).build(); client = node.client(); } else { TransportAddress[] serverAddresses = config.getServers().stream() .map(HostAndPort::fromString) .map(hp -> new InetSocketTransportAddress( new InetSocketAddress(hp.getHostText(), hp.getPortOrDefault(DEFAULT_PORT)))) .toArray(size -> new TransportAddress[size]); client = TransportClient.builder().build().addTransportAddresses(serverAddresses); } }
Example #16
Source File: ElasticSearchTransportClient.java From ingestion with Apache License 2.0 | 5 votes |
private void openLocalDiscoveryClient() { logger.info("Using ElasticSearch AutoDiscovery mode"); Node node = NodeBuilder.nodeBuilder().client(true).local(true).node(); if (client != null) { client.close(); } client = node.client(); }
Example #17
Source File: CassandraRiverIntegrationTest.java From cassandra-river with Apache License 2.0 | 5 votes |
@BeforeClass public void beforeClass() throws Exception { //fires elasticsearch node Settings settings = ImmutableSettings.settingsBuilder() .put("path.data", ES_DATA_DIR.getAbsolutePath()) .put("http.enabled", ES_HTTP_ENABLED) .build(); esNode = NodeBuilder.nodeBuilder().clusterName("cassandra-river-test").local(true).settings(settings).build(); esNode.start(); esClient = esNode.client(); }
Example #18
Source File: NodeTestHelper.java From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License | 5 votes |
public static Node createNode(String clusterName, int graphitePort, String refreshInterval, String includeRegex, String excludeRegex, String prefix) throws IOException { ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder(); settingsBuilder.put("path.conf", NodeTestHelper.class.getResource("/").getFile()); settingsBuilder.put("gateway.type", "none"); settingsBuilder.put("cluster.name", clusterName); settingsBuilder.put("index.number_of_shards", 1); settingsBuilder.put("index.number_of_replicas", 1); settingsBuilder.put("metrics.graphite.host", "localhost"); settingsBuilder.put("metrics.graphite.port", graphitePort); settingsBuilder.put("metrics.graphite.every", refreshInterval); if (!Strings.isEmpty(prefix)) { settingsBuilder.put("metrics.graphite.prefix", prefix); } if (Strings.hasLength(includeRegex)) { settingsBuilder.put("metrics.graphite.include", includeRegex); } if (Strings.hasLength(excludeRegex)) { settingsBuilder.put("metrics.graphite.exclude", excludeRegex); } LogConfigurator.configure(settingsBuilder.build()); return NodeBuilder.nodeBuilder().settings(settingsBuilder.build()).node(); }
Example #19
Source File: EmbeddedUtils.java From usergrid with Apache License 2.0 | 5 votes |
public static InternalNode newInstance(ElasticSearchFig config) { InternalNode inode = (InternalNode) NodeBuilder.nodeBuilder().settings(getSettings(config)) .data(true) .clusterName(config.getClusterName()) .node(); extractTransportInfo(inode, config); return inode; }
Example #20
Source File: InternalNodeImpl.java From io with Apache License 2.0 | 5 votes |
/** * テスト用のElasticsearchノードを起動する. */ public static void startInternalNode() { Settings settings = Settings.settingsBuilder() .put("node.http.enabled", false) .put("cluster.name", "testingCluster") .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); internalNode = NodeBuilder.nodeBuilder().settings(settings).node(); }
Example #21
Source File: EmbeddedElasticsearchNodeEnvironmentImpl.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void start(File tmpDataFolder, String clusterName) throws Exception { if (node == null) { node = NodeBuilder.nodeBuilder().settings( Settings.settingsBuilder() .put("path.home", tmpDataFolder.getParent()) .put("http.enabled", false) .put("path.data", tmpDataFolder.getAbsolutePath())) .clusterName(clusterName) .node(); node.start(); } }
Example #22
Source File: Bootstrap.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void setup(boolean addShutdownHook, Settings settings, Environment environment) throws Exception { initializeNatives(environment.tmpFile(), settings.getAsBoolean("bootstrap.mlockall", false), settings.getAsBoolean("bootstrap.seccomp", true), settings.getAsBoolean("bootstrap.ctrlhandler", true)); // initialize probes before the security manager is installed initializeProbes(); if (addShutdownHook) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (node != null) { node.close(); } } }); } // look for jar hell JarHell.checkJarHell(); // install SM after natives, shutdown hooks, etc. setupSecurity(settings, environment); // We do not need to reload system properties here as we have already applied them in building the settings and // reloading could cause multiple prompts to the user for values if a system property was specified with a prompt // placeholder Settings nodeSettings = Settings.settingsBuilder() .put(settings) .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) .build(); NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(nodeSettings); node = nodeBuilder.build(); }
Example #23
Source File: ElasticsearchServer.java From swagger-for-elasticsearch with Apache License 2.0 | 5 votes |
public ElasticsearchServer() { node = NodeBuilder.nodeBuilder().settings( Settings.settingsBuilder() .put("http.port", 9201) .put("node.name", "swagger-for-elasticsearch-test-node") .put("cluster.name", "swagger-for-elasticsearch-test-cluster") .put("path.data", HOME_DIRECTORY) .put("path.home", DATA_DIRECTORY) ).node(); }
Example #24
Source File: ElasticSearchConfigTest.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Test public void testIndexCreationOptions() throws InterruptedException, BackendException { final int shards = 77; ElasticsearchRunner esr = new ElasticsearchRunner(".", "indexCreationOptions.yml"); esr.start(); CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration()); cc.set("index." + INDEX_NAME + ".elasticsearch.create.ext.number_of_shards", String.valueOf(shards)); cc.set("index." + INDEX_NAME + ".elasticsearch.ext.cluster.name", "indexCreationOptions"); ModifiableConfiguration config = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, cc, BasicConfiguration.Restriction.NONE); config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME); Configuration indexConfig = config.restrictTo(INDEX_NAME); IndexProvider idx = new ElasticSearchIndex(indexConfig); simpleWriteAndQuery(idx); ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder(); settingsBuilder.put("discovery.zen.ping.multicast.enabled", "false"); settingsBuilder.put("discovery.zen.ping.unicast.hosts", "localhost,127.0.0.1:9300"); settingsBuilder.put("cluster.name", "indexCreationOptions"); NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settingsBuilder.build()); nodeBuilder.client(true).data(false).local(false); Node n = nodeBuilder.build().start(); GetSettingsResponse response = n.client().admin().indices().getSettings(new GetSettingsRequest().indices("titan")).actionGet(); assertEquals(String.valueOf(shards), response.getSetting("titan", "index.number_of_shards")); idx.close(); n.stop(); esr.stop(); }
Example #25
Source File: ElasticSearchTransportClient.java From ElasticsearchSink2 with Apache License 2.0 | 5 votes |
private void openLocalDiscoveryClient() { logger.info("Using ElasticSearch AutoDiscovery mode"); Node node = NodeBuilder.nodeBuilder().client(true).local(true).node(); if (client != null) { client.close(); } client = node.client(); }
Example #26
Source File: ElasticSearchAppConfig.java From logsniffer with GNU Lesser General Public License v3.0 | 5 votes |
private Node buildLocalEmbeddedNode() { final File esHomeDir = new File(logSnifferHome.getHomeDir(), "elasticsearch"); final File esDataDir = new File(esHomeDir, "data"); logger.info("Preparing local elasticsearch node on data path: {}", esDataDir.getPath()); esDataDir.mkdirs(); final Settings settings = Settings.settingsBuilder().put("node.name", "embedded") .put("path.home", esHomeDir.getPath()).put("http.enabled", false).build(); final Node node = NodeBuilder.nodeBuilder().settings(settings).clusterName("embedded").data(true).local(true) .node(); return node; }
Example #27
Source File: NodeClientFactory.java From samza with Apache License 2.0 | 5 votes |
@Override public Client getClient() { Settings settings = Settings.settingsBuilder() .put(clientSettings) .build(); Node node = NodeBuilder.nodeBuilder() .client(true) .settings(settings) .build(); return node.client(); }
Example #28
Source File: EmbeddedElasticsearchCluster.java From elasticsearch-reindex-tool with Apache License 2.0 | 5 votes |
private EmbeddedElasticsearchCluster(String clusterName, int apiPort) { NodeBuilder nodeBuilder = nodeBuilder() .clusterName(clusterName) .data(true); Settings.Builder settings = nodeBuilder.settings() .put("http.port", ELS_PORT) //.put("index.store.type", "memory") .put("path.home", ".") .put("transport.tcp.port", apiPort); dataNode = nodeBuilder.settings(settings).node(); dataNode.client().admin().cluster().prepareHealth().setWaitForGreenStatus().get(); }
Example #29
Source File: InternalNodeImpl.java From io with Apache License 2.0 | 5 votes |
/** * テスト用のElasticsearchノードを起動する. */ public static void startInternalNode() { Settings settings = ImmutableSettings.settingsBuilder() .put("node.http.enabled", false) .put("cluster.name", "testingCluster") .put("node.name", "node1") .put("gateway.type", "none") .put("action.auto_create_index", "false") .put("index.store.type", "memory") .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .put("transport.tcp.port", "9399") .build(); internalNode = NodeBuilder.nodeBuilder().settings(settings).node(); }
Example #30
Source File: ElasticsearchInterpreterTest.java From zeppelin with Apache License 2.0 | 4 votes |
@BeforeClass public static void populate() throws IOException { final Settings settings = Settings.settingsBuilder() .put("cluster.name", ELS_CLUSTER_NAME) .put("network.host", ELS_HOST) .put("http.port", ELS_HTTP_PORT) .put("transport.tcp.port", ELS_TRANSPORT_PORT) .put("path.home", ELS_PATH) .build(); elsNode = NodeBuilder.nodeBuilder().settings(settings).node(); elsClient = elsNode.client(); elsClient.admin().indices().prepareCreate("logs") .addMapping("http", jsonBuilder() .startObject().startObject("http").startObject("properties") .startObject("content_length") .field("type", "integer") .endObject() .endObject().endObject().endObject()).get(); for (int i = 0; i < 48; i++) { elsClient.prepareIndex("logs", "http", "" + i) .setRefresh(true) .setSource(jsonBuilder() .startObject() .field("date", new Date()) .startObject("request") .field("method", METHODS[RandomUtils.nextInt(0, METHODS.length)]) .field("url", "/zeppelin/" + UUID.randomUUID().toString()) .field("headers", Arrays.asList("Accept: *.*", "Host: apache.org")) .endObject() .field("status", STATUS[RandomUtils.nextInt(0, STATUS.length)]) .field("content_length", RandomUtils.nextInt(0, 2000)) ) .get(); } for (int i = 1; i < 3; i++) { elsClient.prepareIndex("logs", "http", "very/strange/id#" + i) .setRefresh(true) .setSource(jsonBuilder() .startObject() .field("date", new Date()) .startObject("request") .field("method", METHODS[RandomUtils.nextInt(0, METHODS.length)]) .field("url", "/zeppelin/" + UUID.randomUUID().toString()) .field("headers", Arrays.asList("Accept: *.*", "Host: apache.org")) .endObject() .field("status", STATUS[RandomUtils.nextInt(0, STATUS.length)]) .field("content_length", RandomUtils.nextInt(0, 2000)) ) .get(); } final Properties props = new Properties(); props.put(ElasticsearchInterpreter.ELASTICSEARCH_HOST, ELS_HOST); props.put(ElasticsearchInterpreter.ELASTICSEARCH_CLUSTER_NAME, ELS_CLUSTER_NAME); props.put(ElasticsearchInterpreter.ELASTICSEARCH_PORT, ELS_TRANSPORT_PORT); props.put(ElasticsearchInterpreter.ELASTICSEARCH_CLIENT_TYPE, "transport"); transportInterpreter = new ElasticsearchInterpreter(props); transportInterpreter.open(); props.put(ElasticsearchInterpreter.ELASTICSEARCH_PORT, ELS_HTTP_PORT); props.put(ElasticsearchInterpreter.ELASTICSEARCH_CLIENT_TYPE, "http"); httpInterpreter = new ElasticsearchInterpreter(props); httpInterpreter.open(); }