You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by ly...@apache.org on 2016/12/03 17:20:50 UTC

incubator-metron git commit: METRON-595 Elasticsearch Writer only uses One IP Address (JonathanRider via dlyle65535) closes apache/incubator-metron#379

Repository: incubator-metron
Updated Branches:
  refs/heads/master 319c39e5a -> 2fd7f95c2


METRON-595 Elasticsearch Writer only uses One IP Address (JonathanRider via dlyle65535) closes apache/incubator-metron#379


Project: http://git-wip-us.apache.org/repos/asf/incubator-metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-metron/commit/2fd7f95c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-metron/tree/2fd7f95c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-metron/diff/2fd7f95c

Branch: refs/heads/master
Commit: 2fd7f95c240769a0c0002819aa1a180fd0592c99
Parents: 319c39e
Author: JonathanRider <jo...@capitalone.com>
Authored: Fri Dec 2 14:45:53 2016 -0500
Committer: David Lyle <dl...@gmail.com>
Committed: Fri Dec 2 14:45:53 2016 -0500

----------------------------------------------------------------------
 .../writer/ElasticsearchWriter.java             | 27 +++++++++++++++++---
 1 file changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/2fd7f95c/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/writer/ElasticsearchWriter.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/writer/ElasticsearchWriter.java b/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/writer/ElasticsearchWriter.java
index 7360649..69708fe 100644
--- a/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/writer/ElasticsearchWriter.java
+++ b/metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/writer/ElasticsearchWriter.java
@@ -73,11 +73,11 @@ public class ElasticsearchWriter implements BulkMessageWriter<JSONObject>, Seria
     Settings settings = settingsBuilder.build();
 
     try{
+      client = TransportClient.builder().settings(settings).build();
       for(HostnamePort hp : getIps(globalConfiguration)) {
-        client = TransportClient.builder().settings(settings).build()
-                .addTransportAddress(
-                        new InetSocketTransportAddress(InetAddress.getByName(hp.hostname), hp.port)
-                );
+        client.addTransportAddress(
+                new InetSocketTransportAddress(InetAddress.getByName(hp.hostname), hp.port)
+        );
       }
 
 
@@ -106,6 +106,25 @@ public class ElasticsearchWriter implements BulkMessageWriter<JSONObject>, Seria
       return Collections.emptyList();
     }
     if(ipObj instanceof String
+            && ipObj.toString().contains(",") && ipObj.toString().contains(":")){
+      List<String> ips = Arrays.asList(((String)ipObj).split(","));
+      List<HostnamePort> ret = new ArrayList<>();
+      for(String ip : ips) {
+        Iterable<String> tokens = Splitter.on(":").split(ip);
+        String host = Iterables.getFirst(tokens, null);
+        String portStr = Iterables.getLast(tokens, null);
+        ret.add(new HostnamePort(host, Integer.parseInt(portStr)));
+      }
+      return ret;
+    }else if(ipObj instanceof String
+            && ipObj.toString().contains(",")){
+      List<String> ips = Arrays.asList(((String)ipObj).split(","));
+      List<HostnamePort> ret = new ArrayList<>();
+      for(String ip : ips) {
+        ret.add(new HostnamePort(ip, Integer.parseInt(portObj + "")));
+      }
+      return ret;
+    }else if(ipObj instanceof String
     && !ipObj.toString().contains(":")
       ) {
       return ImmutableList.of(new HostnamePort(ipObj.toString(), Integer.parseInt(portObj + "")));