camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-7502 fix the issue that camel-elastichsearch - starts up an instance even though IP specified
Date Thu, 12 Jun 2014 08:19:28 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 85f7778b2 -> 11db3d5df


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/11db3d5d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/11db3d5d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/11db3d5d

Branch: refs/heads/camel-2.13.x
Commit: 11db3d5dfa8bcdcdacbcb4c5586bca3f726096b9
Parents: 85f7778
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Jun 12 16:07:51 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Jun 12 16:19:08 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/11db3d5d/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/11db3d5d/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 {


Mime
View raw message