metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ceste...@apache.org
Subject [60/66] [abbrv] incubator-metron git commit: METRON-253: Reloading parser configurations from zookeeper doesn't call init(). This closes apache/incubator-metron#170
Date Fri, 24 Jun 2016 21:37:43 GMT
METRON-253: Reloading parser configurations from zookeeper doesn't call init(). This closes
apache/incubator-metron#170


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

Branch: refs/heads/master
Commit: 5c22a4d161414e2376ac34c0fa44535607a1dc62
Parents: e81650b
Author: cstella <cestella@gmail.com>
Authored: Thu Jun 23 15:41:51 2016 -0400
Committer: cstella <cestella@gmail.com>
Committed: Thu Jun 23 15:41:51 2016 -0400

----------------------------------------------------------------------
 .../common/configuration/FieldTransformer.java  | 22 +++++++++++---------
 .../configuration/ParserConfigurations.java     |  1 +
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/5c22a4d1/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/FieldTransformer.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/FieldTransformer.java
b/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/FieldTransformer.java
index cc0c8b4..6948a92 100644
--- a/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/FieldTransformer.java
+++ b/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/FieldTransformer.java
@@ -34,7 +34,7 @@ public class FieldTransformer implements Serializable {
   private List<String> output;
   private FieldTransformation transformation;
   private Map<String, Object> config = new HashMap<>();
-
+  private boolean initialized = false;
   public FieldTransformer() {
   }
 
@@ -81,17 +81,19 @@ public class FieldTransformer implements Serializable {
   }
 
   public void initAndValidate() {
-    if(getTransformation() == null) {
-      throw new IllegalStateException("Mapping cannot be null.");
-    }
-
-    if(output== null || output.isEmpty()) {
-      if(input == null || input.isEmpty()) {
-        throw new IllegalStateException("You must specify an input field if you want to leave
the output fields empty");
+    if(!initialized) {
+      if (getTransformation() == null) {
+        throw new IllegalStateException("Mapping cannot be null.");
       }
-      else {
-        output = input;
+
+      if (output == null || output.isEmpty()) {
+        if (input == null || input.isEmpty()) {
+          throw new IllegalStateException("You must specify an input field if you want to
leave the output fields empty");
+        } else {
+          output = input;
+        }
       }
+      initialized = true;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/5c22a4d1/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/ParserConfigurations.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/ParserConfigurations.java
b/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/ParserConfigurations.java
index 72630d9..ab7463f 100644
--- a/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/ParserConfigurations.java
+++ b/metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/ParserConfigurations.java
@@ -39,6 +39,7 @@ public class ParserConfigurations extends Configurations {
   }
 
   public void updateSensorParserConfig(String sensorType, SensorParserConfig sensorParserConfig)
{
+    sensorParserConfig.init();
     configurations.put(getKey(sensorType), sensorParserConfig);
   }
 


Mime
View raw message