You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/06/12 10:08:22 UTC

git commit: CAMEL-7502 fix the issue that camel-elastichsearch - starts up an instance even though IP specified

Repository: camel
Updated Branches:
  refs/heads/master 4b0381f29 -> 0c3017b6b


CAMEL-7502 fix the issue that camel-elastichsearch - starts up an instance even though IP specified


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0c3017b6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0c3017b6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0c3017b6

Branch: refs/heads/master
Commit: 0c3017b6b7c830916f73d2178bfdbe252505d517
Parents: 4b0381f
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Jun 12 16:07:51 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Jun 12 16:07:51 2014 +0800

----------------------------------------------------------------------
 .../component/elasticsearch/ElasticsearchEndpoint.java | 11 ++++++++---
 .../elasticsearch/ElasticsearchConfigurationTest.java  | 13 +++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0c3017b6/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
index 4d002ea..d8af587 100644
--- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
+++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
@@ -68,14 +68,19 @@ public class ElasticsearchEndpoint extends DefaultEndpoint {
         } else {
             LOG.info("Joining ElasticSearch cluster " + config.getClusterName());
         }
-        node = config.buildNode();
-        if (config.getIp() != null && !config.isLocal()) {
+        if (config.getIp() != null) {
+            LOG.info("REMOTE ELASTICSEARCH: {}", config.getIp());
             Settings settings = ImmutableSettings.settingsBuilder()
-                    .put("cluster.name", config.getClusterName()).put("node.client", true).build();
+                    .put("cluster.name", config.getClusterName())
+                    .put("client.transport.ignore_cluster_name", false)
+                    .put("node.client", true)
+                    .put("client.transport.sniff", true)
+                    .build();
             Client client = new TransportClient(settings)
                     .addTransportAddress(new InetSocketTransportAddress(config.getIp(), config.getPort()));
             this.client = client;
         } else {
+            node = config.buildNode();
             client = node.client();
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/0c3017b6/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java
index d338498..f96c164 100644
--- a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java
+++ b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java
@@ -66,6 +66,19 @@ public class ElasticsearchConfigurationTest extends CamelTestSupport {
         assertFalse(conf.isLocal());
         assertFalse(conf.isData());
     }
+    
+    @Test
+    public void clusterConfWithIpAddress() throws Exception {
+        URI uri = new URI("elasticsearch://clustername?operation=INDEX&indexName=twitter&indexType=tweet&ip=127.0.0.1");
+        Map<String, Object> parameters = URISupport.parseParameters(uri);
+        ElasticsearchConfiguration conf = new ElasticsearchConfiguration(uri, parameters);
+        assertEquals("clustername", conf.getClusterName());
+        assertEquals("INDEX", conf.getOperation());
+        assertFalse(conf.isLocal());
+        assertFalse(conf.isData());
+        assertEquals("127.0.0.1", conf.getIp());
+        assertEquals(9300, conf.getPort().intValue());
+    }
 
     @Test
     public void localDataNode() throws Exception {