This is an automated email from the ASF dual-hosted git repository. rmerriman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/metron.git
The following commit(s) were added to refs/heads/master by this push: new a2a46e6 METRON-2156 Remove Storm dependency from metron-hbase (merrimanr) closes apache/metron#1441 a2a46e6 is described below commit a2a46e6567c78e5066c0d3360d7838d1a5851fa7 Author: merrimanr <merrim...@gmail.com> AuthorDate: Thu Jun 20 08:29:21 2019 -0500 METRON-2156 Remove Storm dependency from metron-hbase (merrimanr) closes apache/metron#1441 --- metron-analytics/metron-profiler-client/pom.xml | 4 +- .../metron/profiler/client/ProfileWriter.java | 2 +- metron-analytics/metron-profiler-common/pom.xml | 2 +- .../metron/profiler/hbase/ColumnBuilder.java | 2 +- .../profiler/hbase/ValueOnlyColumnBuilder.java | 2 +- metron-analytics/metron-profiler-spark/pom.xml | 4 +- metron-analytics/metron-profiler-storm/pom.xml | 13 +- .../org/apache/metron/hbase/bolt/BatchHelper.java | 0 .../org/apache/metron/hbase/bolt/HBaseBolt.java | 2 +- .../metron/hbase/bolt/mapper/HBaseMapper.java | 1 + .../metron/profiler/storm/ProfileHBaseMapper.java | 2 +- .../apache/metron/hbase/bolt/HBaseBoltTest.java | 4 +- .../apache/metron/hbase/bolt/mapper}/Widget.java | 2 +- .../metron/hbase/bolt/mapper}/WidgetMapper.java | 5 +- metron-interface/metron-rest/pom.xml | 7 +- metron-platform/metron-data-management/pom.xml | 4 +- .../metron-elasticsearch-common/pom.xml | 2 +- .../integration/mock/MockHBaseConnector.java | 52 ---- metron-platform/metron-enrichment/pom.xml | 4 +- .../metron-hbase/{ => metron-hbase-common}/pom.xml | 69 +---- .../java/org/apache/metron/hbase}/ColumnList.java | 2 +- .../metron/hbase}/HBaseProjectionCriteria.java | 2 +- .../org/apache/metron/hbase/HTableProvider.java | 0 .../java/org/apache/metron/hbase}/IColumn.java | 2 +- .../java/org/apache/metron/hbase}/ICounter.java | 2 +- .../java/org/apache/metron/hbase/TableConfig.java | 0 .../org/apache/metron/hbase/TableProvider.java | 0 .../apache/metron/hbase/client/HBaseClient.java | 4 +- .../metron/hbase/client/HBaseClientTest.java | 126 +++------ .../metron/hbase/mock/MockHBaseTableProvider.java | 0 .../org/apache/metron/hbase/mock/MockHTable.java | 0 .../src/test/resources/log4j.properties | 0 metron-platform/metron-hbase/pom.xml | 283 +++------------------ .../java/org/apache/metron/hbase/Connector.java | 36 --- .../org/apache/metron/hbase/HTableConnector.java | 157 ------------ .../org/apache/metron/hbase/TupleTableConfig.java | 275 -------------------- .../metron-indexing/metron-indexing-common/pom.xml | 7 +- .../metron-parsing/metron-parsers-common/pom.xml | 7 - .../metron-parsing/metron-parsing-storm/pom.xml | 2 +- metron-platform/metron-pcap/pom.xml | 2 +- .../metron-solr/metron-solr-common/pom.xml | 2 +- .../metron-writer/metron-writer-common/pom.xml | 2 +- 42 files changed, 119 insertions(+), 975 deletions(-) diff --git a/metron-analytics/metron-profiler-client/pom.xml b/metron-analytics/metron-profiler-client/pom.xml index a0cfa1a..04d9740 100644 --- a/metron-analytics/metron-profiler-client/pom.xml +++ b/metron-analytics/metron-profiler-client/pom.xml @@ -65,7 +65,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <exclusions> <exclusion> @@ -84,7 +84,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java b/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java index 38f1c3e..4e00164 100644 --- a/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java +++ b/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java @@ -25,7 +25,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.HTableInterface; import org.apache.metron.hbase.HTableProvider; -import org.apache.metron.hbase.bolt.mapper.ColumnList; +import org.apache.metron.hbase.ColumnList; import org.apache.metron.hbase.client.HBaseClient; import org.apache.metron.profiler.ProfileMeasurement; import org.apache.metron.profiler.ProfilePeriod; diff --git a/metron-analytics/metron-profiler-common/pom.xml b/metron-analytics/metron-profiler-common/pom.xml index db81a71..bd2e5b6 100644 --- a/metron-analytics/metron-profiler-common/pom.xml +++ b/metron-analytics/metron-profiler-common/pom.xml @@ -34,7 +34,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <exclusions> <exclusion> diff --git a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ColumnBuilder.java b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ColumnBuilder.java index 7fc5daa..bc4deff 100644 --- a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ColumnBuilder.java +++ b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ColumnBuilder.java @@ -20,7 +20,7 @@ package org.apache.metron.profiler.hbase; -import org.apache.metron.hbase.bolt.mapper.ColumnList; +import org.apache.metron.hbase.ColumnList; import org.apache.metron.profiler.ProfileMeasurement; import java.io.Serializable; diff --git a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ValueOnlyColumnBuilder.java b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ValueOnlyColumnBuilder.java index 88ec806..0a4a99d 100644 --- a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ValueOnlyColumnBuilder.java +++ b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/ValueOnlyColumnBuilder.java @@ -23,7 +23,7 @@ package org.apache.metron.profiler.hbase; import org.apache.hadoop.hbase.util.Bytes; import org.apache.metron.common.utils.SerDeUtils; import org.apache.metron.profiler.ProfileMeasurement; -import org.apache.metron.hbase.bolt.mapper.ColumnList; +import org.apache.metron.hbase.ColumnList; /** * A ColumnBuilder that writes only the value of a ProfileMeasurement. diff --git a/metron-analytics/metron-profiler-spark/pom.xml b/metron-analytics/metron-profiler-spark/pom.xml index c63c253..b046cc4 100644 --- a/metron-analytics/metron-profiler-spark/pom.xml +++ b/metron-analytics/metron-profiler-spark/pom.xml @@ -81,7 +81,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <exclusions> <exclusion> @@ -96,7 +96,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-analytics/metron-profiler-storm/pom.xml b/metron-analytics/metron-profiler-storm/pom.xml index 5e72603..09bd238 100644 --- a/metron-analytics/metron-profiler-storm/pom.xml +++ b/metron-analytics/metron-profiler-storm/pom.xml @@ -130,18 +130,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> - <version>${project.parent.version}</version> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/BatchHelper.java b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/BatchHelper.java similarity index 100% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/BatchHelper.java rename to metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/BatchHelper.java diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/HBaseBolt.java b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/HBaseBolt.java similarity index 99% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/HBaseBolt.java rename to metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/HBaseBolt.java index 6953b18..ec860a5 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/HBaseBolt.java +++ b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/HBaseBolt.java @@ -29,7 +29,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.client.Durability; import org.apache.metron.hbase.HTableProvider; import org.apache.metron.hbase.TableProvider; -import org.apache.metron.hbase.bolt.mapper.ColumnList; +import org.apache.metron.hbase.ColumnList; import org.apache.metron.hbase.bolt.mapper.HBaseMapper; import org.apache.metron.hbase.client.HBaseClient; import org.apache.storm.Config; diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseMapper.java b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseMapper.java similarity index 97% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseMapper.java rename to metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseMapper.java index 6c7e5fb..9aba92f 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseMapper.java +++ b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseMapper.java @@ -20,6 +20,7 @@ package org.apache.metron.hbase.bolt.mapper; +import org.apache.metron.hbase.ColumnList; import org.apache.storm.tuple.Tuple; import java.io.Serializable; import java.util.Optional; diff --git a/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/profiler/storm/ProfileHBaseMapper.java b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/profiler/storm/ProfileHBaseMapper.java index f36496c..bbb5860 100644 --- a/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/profiler/storm/ProfileHBaseMapper.java +++ b/metron-analytics/metron-profiler-storm/src/main/java/org/apache/metron/profiler/storm/ProfileHBaseMapper.java @@ -21,7 +21,7 @@ package org.apache.metron.profiler.storm; import org.apache.metron.common.configuration.profiler.ProfileConfig; -import org.apache.metron.hbase.bolt.mapper.ColumnList; +import org.apache.metron.hbase.ColumnList; import org.apache.metron.hbase.bolt.mapper.HBaseMapper; import org.apache.metron.profiler.ProfileMeasurement; import org.apache.metron.profiler.hbase.ColumnBuilder; diff --git a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/bolt/HBaseBoltTest.java b/metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/HBaseBoltTest.java similarity index 97% rename from metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/bolt/HBaseBoltTest.java rename to metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/HBaseBoltTest.java index 6057095..bae3728 100644 --- a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/bolt/HBaseBoltTest.java +++ b/metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/HBaseBoltTest.java @@ -23,8 +23,8 @@ package org.apache.metron.hbase.bolt; import org.apache.metron.hbase.TableProvider; import org.apache.storm.Constants; import org.apache.storm.tuple.Tuple; -import org.apache.metron.hbase.Widget; -import org.apache.metron.hbase.WidgetMapper; +import org.apache.metron.hbase.bolt.mapper.Widget; +import org.apache.metron.hbase.bolt.mapper.WidgetMapper; import org.apache.metron.hbase.client.HBaseClient; import org.apache.metron.test.bolt.BaseBoltTest; import org.junit.Assert; diff --git a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/Widget.java b/metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/mapper/Widget.java similarity index 97% rename from metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/Widget.java rename to metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/mapper/Widget.java index 3733e5d..cadea52 100644 --- a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/Widget.java +++ b/metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/mapper/Widget.java @@ -18,7 +18,7 @@ * */ -package org.apache.metron.hbase; +package org.apache.metron.hbase.bolt.mapper; /** * A simple POJO used for testing. diff --git a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/WidgetMapper.java b/metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/mapper/WidgetMapper.java similarity index 93% rename from metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/WidgetMapper.java rename to metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/mapper/WidgetMapper.java index 6d56a4b..34e2dfb 100644 --- a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/WidgetMapper.java +++ b/metron-analytics/metron-profiler-storm/src/test/java/org/apache/metron/hbase/bolt/mapper/WidgetMapper.java @@ -18,12 +18,11 @@ * */ -package org.apache.metron.hbase; +package org.apache.metron.hbase.bolt.mapper; import org.apache.storm.tuple.Tuple; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.metron.hbase.bolt.mapper.ColumnList; -import org.apache.metron.hbase.bolt.mapper.HBaseMapper; +import org.apache.metron.hbase.ColumnList; import java.util.Optional; diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index dcf63a3..84269c2 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -225,6 +225,11 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> + <artifactId>metron-hbase-common</artifactId> + <version>${project.parent.version}</version> + </dependency> + <dependency> + <groupId>org.apache.metron</groupId> <artifactId>metron-hbase-client</artifactId> <version>${project.parent.version}</version> <exclusions> @@ -240,7 +245,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-data-management/pom.xml b/metron-platform/metron-data-management/pom.xml index b8d24a6..3e67c59 100644 --- a/metron-platform/metron-data-management/pom.xml +++ b/metron-platform/metron-data-management/pom.xml @@ -111,12 +111,12 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-elasticsearch/metron-elasticsearch-common/pom.xml b/metron-platform/metron-elasticsearch/metron-elasticsearch-common/pom.xml index a3a6dd7..190bcb2 100644 --- a/metron-platform/metron-elasticsearch/metron-elasticsearch-common/pom.xml +++ b/metron-platform/metron-elasticsearch/metron-elasticsearch-common/pom.xml @@ -46,7 +46,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-enrichment/metron-enrichment-common/src/test/java/org/apache/metron/enrichment/integration/mock/MockHBaseConnector.java b/metron-platform/metron-enrichment/metron-enrichment-common/src/test/java/org/apache/metron/enrichment/integration/mock/MockHBaseConnector.java deleted file mode 100644 index 3b16b6a..0000000 --- a/metron-platform/metron-enrichment/metron-enrichment-common/src/test/java/org/apache/metron/enrichment/integration/mock/MockHBaseConnector.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.enrichment.integration.mock; - -import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException; -import org.apache.metron.hbase.Connector; -import org.apache.metron.hbase.TupleTableConfig; - -import java.io.IOException; -import java.io.InterruptedIOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class MockHBaseConnector extends Connector { - static List<Put> puts = Collections.synchronizedList(new ArrayList<Put>()); - public MockHBaseConnector(TupleTableConfig conf, String _quorum, String _port) throws IOException { - super(conf, _quorum, _port); - } - - @Override - public void put(Put put) throws InterruptedIOException, RetriesExhaustedWithDetailsException { - puts.add(put); - } - - @Override - public void close() { - - } - public static void clear() { - puts.clear(); - } - public static List<Put> getPuts() { - return puts; - } -} diff --git a/metron-platform/metron-enrichment/pom.xml b/metron-platform/metron-enrichment/pom.xml index 9076f9c..1deb04a 100644 --- a/metron-platform/metron-enrichment/pom.xml +++ b/metron-platform/metron-enrichment/pom.xml @@ -42,7 +42,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> </dependency> @@ -72,7 +72,7 @@ <dependency> <!-- Need mock hbase table --> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-hbase/pom.xml b/metron-platform/metron-hbase/metron-hbase-common/pom.xml similarity index 74% copy from metron-platform/metron-hbase/pom.xml copy to metron-platform/metron-hbase/metron-hbase-common/pom.xml index 35f3284..84b24d3 100644 --- a/metron-platform/metron-hbase/pom.xml +++ b/metron-platform/metron-hbase/metron-hbase-common/pom.xml @@ -17,11 +17,11 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.metron</groupId> - <artifactId>metron-platform</artifactId> + <artifactId>metron-hbase</artifactId> <version>0.7.2</version> </parent> - <artifactId>metron-hbase</artifactId> - <name>metron-hbase</name> + <artifactId>metron-hbase-common</artifactId> + <name>metron-hbase-common</name> <url>https://metron.apache.org/</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -119,69 +119,6 @@ </exclusions> </dependency> <dependency> - <groupId>org.apache.storm</groupId> - <artifactId>storm-hbase</artifactId> - <version>${global_storm_version}</version> - <exclusions> - <exclusion> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-server</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-client</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.storm</groupId> - <artifactId>storm-core</artifactId> - <version>${global_storm_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - </exclusion> - <exclusion> - <artifactId>servlet-api</artifactId> - <groupId>javax.servlet</groupId> - </exclusion> - <exclusion> - <artifactId>log4j-over-slf4j</artifactId> - <groupId>org.slf4j</groupId> - </exclusion> - <exclusion> - <artifactId>disruptor</artifactId> - <groupId>com.googlecode.disruptor</groupId> - </exclusion> - <exclusion> - <artifactId>log4j-slf4j-impl</artifactId> - <groupId>org.apache.logging.log4j</groupId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.storm</groupId> - <artifactId>storm-hdfs</artifactId> - <version>${global_storm_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.apache.storm</groupId> - <artifactId>storm-core</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-client</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-server</artifactId> <version>${global_hbase_version}</version> diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/ColumnList.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/ColumnList.java similarity index 99% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/ColumnList.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/ColumnList.java index ad4f8d6..01a5cc6 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/ColumnList.java +++ b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/ColumnList.java @@ -18,7 +18,7 @@ * */ -package org.apache.metron.hbase.bolt.mapper; +package org.apache.metron.hbase; import java.util.ArrayList; import java.util.List; diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseProjectionCriteria.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/HBaseProjectionCriteria.java similarity index 98% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseProjectionCriteria.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/HBaseProjectionCriteria.java index 728d769..7432b02 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/HBaseProjectionCriteria.java +++ b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/HBaseProjectionCriteria.java @@ -18,7 +18,7 @@ * */ -package org.apache.metron.hbase.bolt.mapper; +package org.apache.metron.hbase; import com.google.common.collect.Lists; diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/HTableProvider.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/HTableProvider.java similarity index 100% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/HTableProvider.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/HTableProvider.java diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/IColumn.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/IColumn.java similarity index 96% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/IColumn.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/IColumn.java index d5749ad..b5255e3 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/IColumn.java +++ b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/IColumn.java @@ -18,7 +18,7 @@ * */ -package org.apache.metron.hbase.bolt.mapper; +package org.apache.metron.hbase; /** * Interface definition for classes that support being written to HBase as diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/ICounter.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/ICounter.java similarity index 96% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/ICounter.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/ICounter.java index 03fc9fe..73b65c0 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/bolt/mapper/ICounter.java +++ b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/ICounter.java @@ -18,7 +18,7 @@ * */ -package org.apache.metron.hbase.bolt.mapper; +package org.apache.metron.hbase; /** * Interface definition for classes that support being written to HBase as diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TableConfig.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/TableConfig.java similarity index 100% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TableConfig.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/TableConfig.java diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TableProvider.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/TableProvider.java similarity index 100% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TableProvider.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/TableProvider.java diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/client/HBaseClient.java b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/client/HBaseClient.java similarity index 98% rename from metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/client/HBaseClient.java rename to metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/client/HBaseClient.java index 51fc2c6..d0d934e 100644 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/client/HBaseClient.java +++ b/metron-platform/metron-hbase/metron-hbase-common/src/main/java/org/apache/metron/hbase/client/HBaseClient.java @@ -39,8 +39,8 @@ import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Bytes; import org.apache.metron.hbase.TableProvider; -import org.apache.metron.hbase.bolt.mapper.ColumnList; -import org.apache.metron.hbase.bolt.mapper.HBaseProjectionCriteria; +import org.apache.metron.hbase.ColumnList; +import org.apache.metron.hbase.HBaseProjectionCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/client/HBaseClientTest.java b/metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/client/HBaseClientTest.java similarity index 70% rename from metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/client/HBaseClientTest.java rename to metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/client/HBaseClientTest.java index e6247d0..1983fc7 100644 --- a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/client/HBaseClientTest.java +++ b/metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/client/HBaseClientTest.java @@ -32,12 +32,8 @@ import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Bytes; import org.apache.metron.hbase.TableProvider; -import org.apache.metron.hbase.Widget; -import org.apache.metron.hbase.WidgetMapper; -import org.apache.metron.hbase.bolt.mapper.ColumnList; -import org.apache.metron.hbase.bolt.mapper.HBaseMapper; -import org.apache.metron.hbase.bolt.mapper.HBaseProjectionCriteria; -import org.apache.storm.tuple.Tuple; +import org.apache.metron.hbase.ColumnList; +import org.apache.metron.hbase.HBaseProjectionCriteria; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -47,19 +43,15 @@ import org.junit.Test; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import static org.apache.metron.hbase.WidgetMapper.CF; -import static org.apache.metron.hbase.WidgetMapper.QCOST; -import static org.apache.metron.hbase.WidgetMapper.QNAME; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyListOf; import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -68,21 +60,20 @@ import static org.mockito.Mockito.when; */ public class HBaseClientTest { - private static final String tableName = "widgets"; + private static final String tableName = "table"; private static HBaseTestingUtility util; private static HBaseClient client; private static HTableInterface table; private static Admin admin; - private Tuple tuple1; - private Tuple tuple2; + private static byte[] cf = Bytes.toBytes("cf"); + private static byte[] column = Bytes.toBytes("column"); byte[] rowKey1; byte[] rowKey2; + byte[] value1 = Bytes.toBytes("value1"); + byte[] value2 = Bytes.toBytes("value2"); ColumnList cols1; ColumnList cols2; - private Widget widget1; - private Widget widget2; - private HBaseMapper mapper; @BeforeClass public static void startHBase() throws Exception { @@ -93,7 +84,7 @@ public class HBaseClientTest { util.startMiniCluster(); admin = util.getHBaseAdmin(); // create the table - table = util.createTable(Bytes.toBytes(tableName), WidgetMapper.CF); + table = util.createTable(Bytes.toBytes(tableName), cf); util.waitTableEnabled(table.getName()); // setup the client client = new HBaseClient((c,t) -> table, table.getConfiguration(), tableName); @@ -117,29 +108,17 @@ public class HBaseClientTest { @Before public void setupTuples() throws Exception { + rowKey1 = Bytes.toBytes("rowKey1"); + cols1 = new ColumnList(); + cols1.addColumn(cf, column, value1); - // create a mapper - mapper = new WidgetMapper(); - - // setup the first tuple - widget1 = new Widget("widget1", 100); - tuple1 = mock(Tuple.class); - when(tuple1.getValueByField(eq("widget"))).thenReturn(widget1); - - rowKey1 = mapper.rowKey(tuple1); - cols1 = mapper.columns(tuple1); - - // setup the second tuple - widget2 = new Widget("widget2", 200); - tuple2 = mock(Tuple.class); - when(tuple2.getValueByField(eq("widget"))).thenReturn(widget2); - - rowKey2 = mapper.rowKey(tuple2); - cols2 = mapper.columns(tuple2); + rowKey2 = Bytes.toBytes("rowKey2"); + cols2 = new ColumnList(); + cols2.addColumn(cf, column, value2); } /** - * Should be able to read/write a single Widget. + * Should be able to read/write a single row. */ @Test public void testWrite() throws Exception { @@ -149,7 +128,7 @@ public class HBaseClientTest { client.mutate(); HBaseProjectionCriteria criteria = new HBaseProjectionCriteria(); - criteria.addColumnFamily(WidgetMapper.CF_STRING); + criteria.addColumnFamily(Bytes.toString(cf)); // read back the tuple client.addGet(rowKey1, criteria); @@ -158,11 +137,12 @@ public class HBaseClientTest { // validate assertEquals(1, results.length); - assertEquals(widget1, toWidget(results[0])); + assertArrayEquals(rowKey1, results[0].getRow()); + assertArrayEquals(value1, results[0].getValue(cf, column)); } /** - * Should be able to read/write multiple Widgets in a batch. + * Should be able to read/write multiple rows in a batch. */ @Test public void testBatchWrite() throws Exception { @@ -176,7 +156,7 @@ public class HBaseClientTest { Assert.assertEquals(2, count); HBaseProjectionCriteria criteria = new HBaseProjectionCriteria(); - criteria.addColumnFamily(WidgetMapper.CF_STRING); + criteria.addColumnFamily(Bytes.toString(cf)); // read back both tuples client.addGet(rowKey1, criteria); @@ -185,11 +165,10 @@ public class HBaseClientTest { // validate assertEquals(2, results.length); - List<Widget> expected = Arrays.asList(widget1, widget2); - for(Result result : results) { - Widget widget = toWidget(result); - Assert.assertTrue(expected.contains(widget)); - } + assertArrayEquals(rowKey1, results[0].getRow()); + assertArrayEquals(value1, results[0].getValue(cf, column)); + assertArrayEquals(rowKey1, results[0].getRow()); + assertArrayEquals(value2, results[1].getValue(cf, column)); } /** @@ -203,7 +182,7 @@ public class HBaseClientTest { Assert.assertEquals(0, count); HBaseProjectionCriteria criteria = new HBaseProjectionCriteria(); - criteria.addColumnFamily(WidgetMapper.CF_STRING); + criteria.addColumnFamily(Bytes.toString(cf)); // read back both client.addGet(rowKey1, criteria); @@ -218,7 +197,7 @@ public class HBaseClientTest { } /** - * Should be able to read back widgets that were written with a TTL 30 days out. + * Should be able to read back rows that were written with a TTL 30 days out. */ @Test public void testWriteWithTimeToLive() throws Exception { @@ -230,7 +209,7 @@ public class HBaseClientTest { client.mutate(); HBaseProjectionCriteria criteria = new HBaseProjectionCriteria(); - criteria.addColumnFamily(WidgetMapper.CF_STRING); + criteria.addColumnFamily(Bytes.toString(cf)); // read back both tuples client.addGet(rowKey1, criteria); @@ -239,18 +218,17 @@ public class HBaseClientTest { // validate assertEquals(2, results.length); - List<Widget> expected = Arrays.asList(widget1, widget2); - for(Result result : results) { - Widget widget = toWidget(result); - Assert.assertTrue(expected.contains(widget)); - } + assertArrayEquals(rowKey1, results[0].getRow()); + assertArrayEquals(value1, results[0].getValue(cf, column)); + assertArrayEquals(rowKey1, results[0].getRow()); + assertArrayEquals(value2, results[1].getValue(cf, column)); } /** - * Should NOT be able to read widgets that are expired due to the TTL. + * Should NOT be able to read rows that are expired due to the TTL. */ @Test - public void testExpiredWidgets() throws Exception { + public void testExpiredRows() throws Exception { long timeToLive = TimeUnit.MILLISECONDS.toMillis(1); // add two mutations to the queue @@ -259,23 +237,20 @@ public class HBaseClientTest { client.mutate(); HBaseProjectionCriteria criteria = new HBaseProjectionCriteria(); - criteria.addColumnFamily(WidgetMapper.CF_STRING); + criteria.addColumnFamily(Bytes.toString(cf)); // wait for a second to ensure the TTL has expired Thread.sleep(TimeUnit.SECONDS.toMillis(2)); - // read back both tuples + // read back both rows client.addGet(rowKey1, criteria); client.addGet(rowKey2, criteria); Result[] results = client.getAll(); - // validate - the TTL should have expired all widgets - List<Widget> widgets = Arrays - .stream(results) - .map(r -> toWidget(r)) - .filter(w -> w != null) - .collect(Collectors.toList()); - assertEquals(0, widgets.size()); + // validate - the TTL should have expired all rows + assertEquals(2, results.length); + assertTrue(results[0].isEmpty()); + assertTrue(results[1].isEmpty()); } @Test(expected = RuntimeException.class) @@ -311,28 +286,11 @@ public class HBaseClientTest { when(tableProvider.getTable(any(), any())).thenReturn(table); HBaseProjectionCriteria criteria = new HBaseProjectionCriteria(); - criteria.addColumnFamily(WidgetMapper.CF_STRING); + criteria.addColumnFamily(Bytes.toString(cf)); client = new HBaseClient(tableProvider, HBaseConfiguration.create(), tableName); client.addGet(rowKey1, criteria); client.addGet(rowKey2, criteria); client.getAll(); } - - /** - * Transforms the HBase Result to a Widget. - * @param result The HBase Result. - * @return The Widget. - */ - private Widget toWidget(Result result) { - Widget widget = null; - - if(result.containsColumn(CF, QCOST) && result.containsColumn(CF, QNAME)) { - String name = Bytes.toString(result.getValue(CF, QNAME)); - int cost = Bytes.toInt(result.getValue(CF, QCOST)); - widget = new Widget(name, cost); - } - - return widget; - } } diff --git a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/mock/MockHBaseTableProvider.java b/metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/mock/MockHBaseTableProvider.java similarity index 100% rename from metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/mock/MockHBaseTableProvider.java rename to metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/mock/MockHBaseTableProvider.java diff --git a/metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/mock/MockHTable.java b/metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/mock/MockHTable.java similarity index 100% rename from metron-platform/metron-hbase/src/test/java/org/apache/metron/hbase/mock/MockHTable.java rename to metron-platform/metron-hbase/metron-hbase-common/src/test/java/org/apache/metron/hbase/mock/MockHTable.java diff --git a/metron-platform/metron-hbase/src/test/resources/log4j.properties b/metron-platform/metron-hbase/metron-hbase-common/src/test/resources/log4j.properties similarity index 100% rename from metron-platform/metron-hbase/src/test/resources/log4j.properties rename to metron-platform/metron-hbase/metron-hbase-common/src/test/resources/log4j.properties diff --git a/metron-platform/metron-hbase/pom.xml b/metron-platform/metron-hbase/pom.xml index 35f3284..a363618 100644 --- a/metron-platform/metron-hbase/pom.xml +++ b/metron-platform/metron-hbase/pom.xml @@ -1,259 +1,46 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software - Foundation (ASF) under one or more contributor license agreements. See the - NOTICE file distributed with this work for additional information regarding - copyright ownership. The ASF licenses this file to You under the Apache License, - Version 2.0 (the "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - OR CONDITIONS OF ANY KIND, either express or implied. See the License for - the specific language governing permissions and limitations under the License. +<!-- + Licensed to the Apache Software + Foundation (ASF) under one or more contributor license agreements. See the + NOTICE file distributed with this work for additional information regarding + copyright ownership. The ASF licenses this file to You under the Apache License, + Version 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>metron-hbase</artifactId> + <packaging>pom</packaging> + <name>metron-hbase</name> <parent> - <groupId>org.apache.metron</groupId> <artifactId>metron-platform</artifactId> + <groupId>org.apache.metron</groupId> <version>0.7.2</version> </parent> - <artifactId>metron-hbase</artifactId> - <name>metron-hbase</name> + <description>Metron parsers and platform support</description> <url>https://metron.apache.org/</url> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <slf4j.version>1.7.7</slf4j.version> - <storm.hdfs.version>0.1.2</storm.hdfs.version> - <guava.version>${global_hbase_guava_version}</guava.version> - </properties> - <dependencies> - <dependency> - <groupId>org.apache.metron</groupId> - <artifactId>metron-common</artifactId> - <version>${project.parent.version}</version> - <exclusions> - <exclusion> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.metron</groupId> - <artifactId>metron-test-utilities</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-auth</artifactId> - <version>${global_hadoop_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-client</artifactId> - <version>${global_hadoop_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-common</artifactId> - <classifier>tests</classifier> - <version>${global_hadoop_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-hdfs</artifactId> - <classifier>tests</classifier> - <version>${global_hadoop_version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-client</artifactId> - <version>${global_hbase_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - <exclusion> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.storm</groupId> - <artifactId>storm-hbase</artifactId> - <version>${global_storm_version}</version> - <exclusions> - <exclusion> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-server</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-client</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.storm</groupId> - <artifactId>storm-core</artifactId> - <version>${global_storm_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - </exclusion> - <exclusion> - <artifactId>servlet-api</artifactId> - <groupId>javax.servlet</groupId> - </exclusion> - <exclusion> - <artifactId>log4j-over-slf4j</artifactId> - <groupId>org.slf4j</groupId> - </exclusion> - <exclusion> - <artifactId>disruptor</artifactId> - <groupId>com.googlecode.disruptor</groupId> - </exclusion> - <exclusion> - <artifactId>log4j-slf4j-impl</artifactId> - <groupId>org.apache.logging.log4j</groupId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.storm</groupId> - <artifactId>storm-hdfs</artifactId> - <version>${global_storm_version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.apache.storm</groupId> - <artifactId>storm-core</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-client</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-server</artifactId> - <version>${global_hbase_version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-minicluster</artifactId> - <version>${global_hadoop_version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-testing-util</artifactId> - <version>${global_hbase_version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - <exclusion> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-hdfs</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.hadoop</groupId> - <artifactId>hadoop-minicluster</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>${global_mockito_version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.17</version> - <scope>provided</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>${global_jar_version}</version> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> + <scm> + <connection>scm:git:https://gitbox.apache.org/repos/asf/metron.git</connection> + <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/metron.git</developerConnection> + <tag>HEAD</tag> + <url>https://gitbox.apache.org/repos/asf/metron.git</url> + </scm> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + <modules> + <module>metron-hbase-common</module> + </modules> </project> diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/Connector.java b/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/Connector.java deleted file mode 100644 index e787e43..0000000 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/Connector.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.hbase; - -import org.apache.hadoop.hbase.client.Put; - -import java.io.IOException; - -public abstract class Connector { - protected TableConfig tableConf; - protected String _quorum; - protected String _port; - - public Connector(final TableConfig conf, String _quorum, String _port) throws IOException { - this.tableConf = conf; - this._quorum = _quorum; - this._port = _port; - } - public abstract void put(Put put) throws IOException; - public abstract void close(); -} diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/HTableConnector.java b/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/HTableConnector.java deleted file mode 100644 index 6d3c2c4..0000000 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/HTableConnector.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.metron.hbase; - -import java.io.IOException; -import java.io.Serializable; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.InvocationTargetException; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.client.HTableInterface; -import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.storm.generated.Bolt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * HTable connector for Storm {@link Bolt} - * <p> - * The HBase configuration is picked up from the first <tt>hbase-site.xml</tt> encountered in the - * classpath - */ -@SuppressWarnings("serial") -public class HTableConnector extends Connector implements Serializable{ - private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private Configuration conf; - protected HTableInterface table; - private String tableName; - private String connectorImpl; - - - /** - * Initialize HTable connection - * @param conf The {@link TupleTableConfig} - * @throws IOException - */ - public HTableConnector(final TableConfig conf, String _quorum, String _port) throws IOException { - super(conf, _quorum, _port); - this.connectorImpl = conf.getConnectorImpl(); - this.tableName = conf.getTableName(); - this.conf = HBaseConfiguration.create(); - - if(_quorum != null && _port != null) - { - this.conf.set("hbase.zookeeper.quorum", _quorum); - this.conf.set("hbase.zookeeper.property.clientPort", _port); - } - - LOG.info("Initializing connection to HBase table {} at {}", tableName, - this.conf.get("hbase.rootdir")); - - try { - this.table = getTableProvider().getTable(this.conf, this.tableName); - } catch (IOException ex) { - throw new IOException("Unable to establish connection to HBase table " + this.tableName, ex); - } - - if (conf.isBatch()) { - // Enable client-side write buffer - this.table.setAutoFlush(false, true); - LOG.info("Enabled client-side write buffer"); - } - - // If set, override write buffer size - if (conf.getWriteBufferSize() > 0) { - try { - this.table.setWriteBufferSize(conf.getWriteBufferSize()); - - LOG.info("Setting client-side write buffer to {}", conf.getWriteBufferSize()); - } catch (IOException ex) { - LOG.error("Unable to set client-side write buffer size for HBase table {}", this.tableName, - ex); - } - } - - // Check the configured column families exist - for (String cf : conf.getColumnFamilies()) { - if (!columnFamilyExists(cf)) { - throw new RuntimeException(String.format( - "HBase table '%s' does not have column family '%s'", conf.getTableName(), cf)); - } - } - } - - protected TableProvider getTableProvider() throws IOException { - if(connectorImpl == null || connectorImpl.length() == 0 || connectorImpl.charAt(0) == '$') { - return new HTableProvider(); - } - else { - try { - Class<? extends TableProvider> clazz = (Class<? extends TableProvider>) Class.forName(connectorImpl); - return clazz.getConstructor().newInstance(); - } catch (InstantiationException e) { - throw new IOException("Unable to instantiate connector.", e); - } catch (IllegalAccessException e) { - throw new IOException("Unable to instantiate connector: illegal access", e); - } catch (InvocationTargetException e) { - throw new IOException("Unable to instantiate connector", e); - } catch (NoSuchMethodException e) { - throw new IOException("Unable to instantiate connector: no such method", e); - } catch (ClassNotFoundException e) { - throw new IOException("Unable to instantiate connector: class not found", e); - } - } - } - - /** - * Checks to see if table contains the given column family - * @param columnFamily The column family name - * @return boolean - * @throws IOException - */ - private boolean columnFamilyExists(final String columnFamily) throws IOException { - return this.table.getTableDescriptor().hasFamily(Bytes.toBytes(columnFamily)); - } - - /** - * @return the table - */ - public HTableInterface getTable() { - return table; - } - - @Override - public void put(Put put) throws IOException { - table.put(put); - } - - /** - * Close the table - */ - @Override - public void close() { - try { - this.table.close(); - } catch (IOException ex) { - LOG.error("Unable to close connection to HBase table {}", tableName, ex); - } - } -} diff --git a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TupleTableConfig.java b/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TupleTableConfig.java deleted file mode 100644 index 5f6aae5..0000000 --- a/metron-platform/metron-hbase/src/main/java/org/apache/metron/hbase/TupleTableConfig.java +++ /dev/null @@ -1,275 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.hbase; - -import com.google.common.base.Joiner; -import java.io.IOException; -import java.io.Serializable; -import java.lang.invoke.MethodHandles; -import java.util.HashMap; -import java.util.HashSet; -import java.util.NavigableMap; -import java.util.Set; -import java.util.TreeMap; -import org.apache.hadoop.hbase.client.Durability; -import org.apache.hadoop.hbase.client.Increment; -import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.storm.tuple.Tuple; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Configuration for Storm {@link Tuple} to HBase serialization. - */ -@SuppressWarnings("serial") -public class TupleTableConfig extends TableConfig implements Serializable { - private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - static final long serialVersionUID = -1L; - public static final long DEFAULT_INCREMENT = 1L; - - protected String tupleRowKeyField; - protected String tupleTimestampField; - protected Durability durability = Durability.USE_DEFAULT; - private String fields; - - /** - * Initialize configuration - * - * @param table - * The HBase table name - * @param rowKeyField - * The {@link Tuple} field used to set the rowKey - */ - public TupleTableConfig(final String table, final String rowKeyField) { - super(table); - this.tupleRowKeyField = rowKeyField; - this.tupleTimestampField = ""; - this.columnFamilies = new HashMap<String, Set<String>>(); - } - - /** - * Initialize configuration - * - * @param table - * The HBase table name - * @param rowKeyField - * The {@link Tuple} field used to set the rowKey - * @param timestampField - * The {@link Tuple} field used to set the timestamp - */ - public TupleTableConfig(final String table, final String rowKeyField, final String timestampField) { - super(table); - this.tupleRowKeyField = rowKeyField; - this.tupleTimestampField = timestampField; - this.columnFamilies = new HashMap<String, Set<String>>(); - } - - public TupleTableConfig() { - super(null); - this.columnFamilies = new HashMap<String, Set<String>>(); - } - - - - public TupleTableConfig withRowKeyField(String rowKeyField) { - this.tupleRowKeyField = rowKeyField; - return this; - } - - public TupleTableConfig withTimestampField(String timestampField) { - this.tupleTimestampField = timestampField; - return this; - } - - public TupleTableConfig withFields(String fields) { - this.fields = fields; - return this; - } - - - - public String getFields() { - return fields; - } - - - - /** - * Add column family and column qualifier to be extracted from tuple - * - * @param columnFamily - * The column family name - * @param columnQualifier - * The column qualifier name - */ - public void addColumn(final String columnFamily, final String columnQualifier) { - Set<String> columns = this.columnFamilies.get(columnFamily); - - if (columns == null) { - columns = new HashSet<String>(); - } - columns.add(columnQualifier); - - this.columnFamilies.put(columnFamily, columns); - } - - /** - * Creates a HBase {@link Put} from a Storm {@link Tuple} - * - * @param tuple - * The {@link Tuple} - * @return {@link Put} - */ - public Put getPutFromTuple(final Tuple tuple) throws IOException{ - byte[] rowKey = null; - try { - rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField)); - } - catch(IllegalArgumentException iae) { - throw new IOException("Unable to retrieve " + tupleRowKeyField + " from " + tuple + " [ " + Joiner.on(',').join(tuple.getFields()) + " ]", iae); - } - - long ts = 0; - if (!tupleTimestampField.equals("")) { - ts = tuple.getLongByField(tupleTimestampField); - } - - Put p = new Put(rowKey); - - p.setDurability(durability); - - if (columnFamilies.size() > 0) { - for (String cf : columnFamilies.keySet()) { - byte[] cfBytes = Bytes.toBytes(cf); - for (String cq : columnFamilies.get(cf)) { - byte[] cqBytes = Bytes.toBytes(cq); - byte[] val = tuple.getBinaryByField(cq); - - if (ts > 0) { - p.add(cfBytes, cqBytes, ts, val); - } else { - p.add(cfBytes, cqBytes, val); - } - } - } - } - - return p; - } - - /** - * Creates a HBase {@link Increment} from a Storm {@link Tuple} - * - * @param tuple - * The {@link Tuple} - * @param increment - * The amount to increment the counter by - * @return {@link Increment} - */ - public Increment getIncrementFromTuple(final Tuple tuple, final long increment) { - byte[] rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField)); - - Increment inc = new Increment(rowKey); - inc.setDurability(durability); - - if (columnFamilies.size() > 0) { - for (String cf : columnFamilies.keySet()) { - byte[] cfBytes = Bytes.toBytes(cf); - for (String cq : columnFamilies.get(cf)) { - byte[] val; - try { - val = Bytes.toBytes(tuple.getStringByField(cq)); - } catch (IllegalArgumentException ex) { - // if cq isn't a tuple field, use cq for counter instead of tuple - // value - val = Bytes.toBytes(cq); - } - inc.addColumn(cfBytes, val, increment); - } - } - } - - return inc; - } - - /** - * Increment the counter for the given family and column by the specified - * amount - * <p> - * If the family and column already exist in the Increment the counter value - * is incremented by the specified amount rather than overridden, as it is in - * HBase's {@link Increment#addColumn(byte[], byte[], long)} method - * - * @param inc - * The {@link Increment} to update - * @param family - * The column family - * @param qualifier - * The column qualifier - * @param amount - * The amount to increment the counter by - */ - public static void addIncrement(Increment inc, final byte[] family, final byte[] qualifier, final Long amount) { - - NavigableMap<byte[], Long> set = inc.getFamilyMapOfLongs().get(family); - if (set == null) { - set = new TreeMap<byte[], Long>(Bytes.BYTES_COMPARATOR); - } - - // If qualifier exists, increment amount - Long counter = set.get(qualifier); - if (counter == null) { - counter = 0L; - } - set.put(qualifier, amount + counter); - - inc.getFamilyMapOfLongs().put(family, set); - } - - - - /** - * @param durability - * Sets whether to write to HBase's edit log. - * <p> - * Setting to false will mean fewer operations to perform when - * writing to HBase and hence better performance, but changes that - * haven't been flushed to a store file will be lost in the event of - * HBase failure - * <p> - * Enabled by default - */ - public void setDurability(Durability durability) { - this.durability = durability; - } - - - public Durability getDurability() { - return durability; - } - - - - /** - * @return the tupleRowKeyField - */ - public String getTupleRowKeyField() { - return tupleRowKeyField; - } -} diff --git a/metron-platform/metron-indexing/metron-indexing-common/pom.xml b/metron-platform/metron-indexing/metron-indexing-common/pom.xml index 74c0389..df81532 100644 --- a/metron-platform/metron-indexing/metron-indexing-common/pom.xml +++ b/metron-platform/metron-indexing/metron-indexing-common/pom.xml @@ -44,11 +44,6 @@ <artifactId>metron-writer-common</artifactId> <version>${project.parent.version}</version> </dependency> - <dependency> - <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> - <version>${project.parent.version}</version> - </dependency> <!-- Other --> @@ -162,7 +157,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <type>test-jar</type> <scope>test</scope> diff --git a/metron-platform/metron-parsing/metron-parsers-common/pom.xml b/metron-platform/metron-parsing/metron-parsers-common/pom.xml index c6b2d52..631bdd8 100644 --- a/metron-platform/metron-parsing/metron-parsers-common/pom.xml +++ b/metron-platform/metron-parsing/metron-parsers-common/pom.xml @@ -41,13 +41,6 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - <type>test-jar</type> - </dependency> - <dependency> - <groupId>org.apache.metron</groupId> <artifactId>metron-pcap</artifactId> <version>${project.parent.version}</version> </dependency> diff --git a/metron-platform/metron-parsing/metron-parsing-storm/pom.xml b/metron-platform/metron-parsing/metron-parsing-storm/pom.xml index 4867d44..2c5fd37 100644 --- a/metron-platform/metron-parsing/metron-parsing-storm/pom.xml +++ b/metron-platform/metron-parsing/metron-parsing-storm/pom.xml @@ -116,7 +116,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-pcap/pom.xml b/metron-platform/metron-pcap/pom.xml index 2e46ded..c839285 100644 --- a/metron-platform/metron-pcap/pom.xml +++ b/metron-platform/metron-pcap/pom.xml @@ -41,7 +41,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> </dependency> <dependency> diff --git a/metron-platform/metron-solr/metron-solr-common/pom.xml b/metron-platform/metron-solr/metron-solr-common/pom.xml index 24f8365..ffaf6d9 100644 --- a/metron-platform/metron-solr/metron-solr-common/pom.xml +++ b/metron-platform/metron-solr/metron-solr-common/pom.xml @@ -208,7 +208,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <scope>test</scope> <type>test-jar</type> diff --git a/metron-platform/metron-writer/metron-writer-common/pom.xml b/metron-platform/metron-writer/metron-writer-common/pom.xml index c34ea1f..0d91b52 100644 --- a/metron-platform/metron-writer/metron-writer-common/pom.xml +++ b/metron-platform/metron-writer/metron-writer-common/pom.xml @@ -192,7 +192,7 @@ </dependency> <dependency> <groupId>org.apache.metron</groupId> - <artifactId>metron-hbase</artifactId> + <artifactId>metron-hbase-common</artifactId> <version>${project.parent.version}</version> <type>test-jar</type> <scope>test</scope>