metron git commit: METRON-539 Added functions to hash values. (jjmeyer0) closes apache/metron#641

2017-08-25 Thread jmeyer
Repository: metron
Updated Branches:
  refs/heads/master 174964832 -> a2bae0bce


METRON-539 Added functions to hash values. (jjmeyer0) closes apache/metron#641


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

Branch: refs/heads/master
Commit: a2bae0bce4d0739c5b1b7e5d803ee1c44ea529ca
Parents: 1749648
Author: jjmeyer0 
Authored: Fri Aug 25 11:25:17 2017 -0500
Committer: jmeyer 
Committed: Fri Aug 25 11:25:17 2017 -0500

--
 metron-stellar/stellar-common/README.md | 118 ++-
 .../common/utils/hashing/DefaultHasher.java |  97 +
 .../stellar/common/utils/hashing/Hasher.java|  35 
 .../stellar/dsl/functions/HashFunctions.java|  86 
 .../common/utils/hashing/DefaultHasherTest.java |  59 ++
 .../dsl/functions/HashFunctionsTest.java| 205 +++
 6 files changed, 548 insertions(+), 52 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/metron/blob/a2bae0bc/metron-stellar/stellar-common/README.md
--
diff --git a/metron-stellar/stellar-common/README.md 
b/metron-stellar/stellar-common/README.md
index f12c77d..a25c831 100644
--- a/metron-stellar/stellar-common/README.md
+++ b/metron-stellar/stellar-common/README.md
@@ -101,62 +101,63 @@ In the core language functions, we support basic 
functional programming primitiv
 
 ## Stellar Core Functions
 
-|  
|
-| --   
|
-| [ `ABS`](../../metron-analytics/metron-statistics#abs)   
|
-| [ `APPEND_IF_MISSING`](#append_if_missing)   
|
-| [ `BIN`](../../metron-analytics/metron-statistics#bin)   
|
-| [ `BLOOM_ADD`](#bloom_add)   
|
-| [ `BLOOM_EXISTS`](#bloom_exists) 
|
-| [ `BLOOM_INIT`](#bloom_init) 
|
-| [ `BLOOM_MERGE`](#bloom_merge)   
|
+|  
  |
+| --   
  |
+| [ `ABS`](../../metron-analytics/metron-statistics#abs)   
  |
+| [ `APPEND_IF_MISSING`](#append_if_missing)   
  |
+| [ `BIN`](../../metron-analytics/metron-statistics#bin)   
  |
+| [ `BLOOM_ADD`](#bloom_add)   
  |
+| [ `BLOOM_EXISTS`](#bloom_exists) 
  |
+| [ `BLOOM_INIT`](#bloom_init) 
  |
+| [ `BLOOM_MERGE`](#bloom_merge)   
  |
 | [ `CEILING`](#ceiling)   
|
 | [ `COS`](#cos)   
|
-| [ `CHOP`](#chop) 
|
-| [ `CHOMP`](#chomp)   
|
-| [ `COUNT_MATCHES`](#count_matches)   
|
-| [ `DAY_OF_MONTH`](#day_of_month) 
|
-| [ `DAY_OF_WEEK`](#day_of_week)   
|
-| [ `DAY_OF_YEAR`](#day_of_year)   
|
-| [ `DECODE`](#decode) 
|
-| [ `DOMAIN_REMOVE_SUBDOMAINS`](#domain_remove_subdomains) 
|
-| [ `DOMAIN_REMOVE_TLD`](#domain_remove_tld)   
|
-| [ `DOMAIN_TO_TLD`](#domain_to_tld)   
|
-| [ `ENCODE`](#encode) 
|
-| [ `ENDS_WITH`](#ends_with)   
|
-| [ `ENRICHMENT_EXISTS`](#enrichment_exists)   
|
-| [ `ENRICHMENT_GET`](#enrichment_get) 
|
+| [ `CHOP`](#chop) 
  

metron git commit: METRON-1131: The Stellar REPL rejects valid hostnames for zookeeper in its CLI options this closes apache/incubator-metron#715

2017-08-25 Thread cestella
Repository: metron
Updated Branches:
  refs/heads/master f34affdb2 -> 174964832


METRON-1131: The Stellar REPL rejects valid hostnames for zookeeper in its CLI 
options this closes apache/incubator-metron#715


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

Branch: refs/heads/master
Commit: 174964832eafba927ae4e7aa407d2a1100a8b776
Parents: f34affd
Author: cstella 
Authored: Fri Aug 25 09:17:48 2017 -0400
Committer: cstella 
Committed: Fri Aug 25 09:17:48 2017 -0400

--
 .../shell/StellarShellOptionsValidator.java | 24 ++--
 .../shell/StellarShellOptionsValidatorTest.java |  9 
 2 files changed, 22 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/metron/blob/17496483/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidator.java
--
diff --git 
a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidator.java
 
b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidator.java
index 411c288..97f5b70 100644
--- 
a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidator.java
+++ 
b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidator.java
@@ -21,21 +21,31 @@
 package org.apache.metron.stellar.common.shell;
 
 import java.io.File;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.function.Predicate;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.validator.routines.InetAddressValidator;
 
 public class StellarShellOptionsValidator {
 
   private static final Pattern validPortPattern = 
Pattern.compile("(^.*)[:](\\d+)$");
-  private static final Pattern validHostNamePattern;
+  private static final Predicate hostnameValidator = hostname -> {
+if(StringUtils.isEmpty(hostname)) {
+  return false;
+}
+try {
+  InetAddress add = InetAddress.getByName(hostname);
+  return true;
+} catch (UnknownHostException e) {
+  return false;
+}
+  };
+
 
-  static {
-validHostNamePattern = Pattern.compile(
-"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)"
-+ "*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$");
-  }
 
   private static final InetAddressValidator inetAddressValidator = 
InetAddressValidator
   .getInstance();
@@ -79,7 +89,7 @@ public class StellarShellOptionsValidator {
 String name = matcher.group(1);
 Integer port = Integer.parseInt(matcher.group(2));
 
-if (!validHostNamePattern.matcher(name).matches() && 
!inetAddressValidator.isValid(name)) {
+if (!hostnameValidator.test(name) && !inetAddressValidator.isValid(name)) {
   throw new IllegalArgumentException(
   String.format("Zookeeper Option %s is not a valid host name or ip 
address  %s", name, z));
 }

http://git-wip-us.apache.org/repos/asf/metron/blob/17496483/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidatorTest.java
--
diff --git 
a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidatorTest.java
 
b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidatorTest.java
index 4f74308..52fef96 100644
--- 
a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidatorTest.java
+++ 
b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/common/shell/StellarShellOptionsValidatorTest.java
@@ -28,6 +28,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.File;
+import java.util.regex.Pattern;
 
 import static org.junit.Assert.*;
 
@@ -35,15 +36,15 @@ public class StellarShellOptionsValidatorTest {
 
   @Test
   public void validateOptions() throws Exception {
-String[] validZHostArg = new String[]{"-z", "host1:"};
+String[] validZHostArg = new String[]{"-z", "localhost:"};
 String[] validZIPArg = new String[]{"-z", "10.10.10.3:"};
-String[] invalidZNoPortArg = new String[]{"-z", "host1"};
+String[] invalidZNoPortArg = new String[]{"-z", "youtube.com"};