You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ra...@apache.org on 2016/08/23 04:04:33 UTC
incubator-eagle git commit: EAGLE-491: AlertPublisherImpl dedup
throws exception when dedup column is not configured
Repository: incubator-eagle
Updated Branches:
refs/heads/develop 71f253c91 -> 4b891ba01
EAGLE-491: AlertPublisherImpl dedup throws exception when dedup column is not configured
Author: Zeng, Bryant
Reviewer: ralphsu
This closes #376
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/4b891ba0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/4b891ba0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/4b891ba0
Branch: refs/heads/develop
Commit: 4b891ba01328ccc02a7d2d80dbbd7e4bc46e1284
Parents: 71f253c
Author: mizeng <mi...@ebaysf.com>
Authored: Tue Aug 23 09:52:24 2016 +0800
Committer: Ralph, Su <su...@gmail.com>
Committed: Tue Aug 23 12:00:49 2016 +0800
----------------------------------------------------------------------
.../bin/kafka-console-consumer.sh | 18 ++++++++++++++++++
.../publisher/impl/AbstractPublishPlugin.java | 2 +-
.../publisher/impl/DefaultDeduplicator.java | 4 +++-
.../engine/router/TestAlertPublisherBolt.java | 10 ++++++++++
.../router/publishments-empty-dedup-field.json | 20 ++++++++++++++++++++
5 files changed, 52 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/4b891ba0/eagle-core/eagle-alert-parent/eagle-alert/alert-devtools/bin/kafka-console-consumer.sh
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-devtools/bin/kafka-console-consumer.sh b/eagle-core/eagle-alert-parent/eagle-alert/alert-devtools/bin/kafka-console-consumer.sh
new file mode 100755
index 0000000..21f669d
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-devtools/bin/kafka-console-consumer.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# 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.
+
+exec $(dirname $0)/run-class.sh kafka.tools.ConsoleConsumer "$@"
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/4b891ba0/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
index b71bf4a..7a67011 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
@@ -46,7 +46,7 @@ public abstract class AbstractPublishPlugin implements AlertPublishPlugin {
try {
Object obj = Class.forName(serializerClz).getConstructor(Map.class).newInstance(conf);
if (!(obj instanceof IEventSerializer)) {
- throw new Exception(String.format("serializer %s of publishement %s is not subclass to %s!",
+ throw new Exception(String.format("serializer %s of publishment %s is not subclass to %s!",
publishment.getSerializer(),
publishment.getName(),
IEventSerializer.class.getName()));
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/4b891ba0/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/DefaultDeduplicator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/DefaultDeduplicator.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/DefaultDeduplicator.java
index a5e7b5a..43be2e1 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/DefaultDeduplicator.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/DefaultDeduplicator.java
@@ -57,7 +57,9 @@ public class DefaultDeduplicator implements AlertDeduplicator {
public DefaultDeduplicator(String intervalMin, List<String> customDedupFields) {
setDedupIntervalMin(intervalMin);
- this.customDedupFields = customDedupFields;
+ if (customDedupFields != null){
+ this.customDedupFields = customDedupFields;
+ }
}
public void clearOldCache() {
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/4b891ba0/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
index 9afa21d..9989068 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
@@ -153,6 +153,16 @@ public class TestAlertPublisherBolt {
}
+ @Test
+ public void testEmptyCustomFieldDedupEvent() throws Exception {
+ List<Publishment> pubs = loadEntities("/router/publishments-empty-dedup-field.json", Publishment.class);
+ AlertPublishPlugin plugin = AlertPublishPluginsFactory.createNotificationPlugin(pubs.get(0), null, null);
+ AlertStreamEvent event1 = createWithStreamDef("host1", "testapp1");
+ AlertStreamEvent event2 = createWithStreamDef("host2", "testapp2");
+ Assert.assertNotNull(plugin.dedup(event1));
+ Assert.assertNull(plugin.dedup(event2));
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/4b891ba0/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/router/publishments-empty-dedup-field.json
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/router/publishments-empty-dedup-field.json b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/router/publishments-empty-dedup-field.json
new file mode 100644
index 0000000..cba4960
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/router/publishments-empty-dedup-field.json
@@ -0,0 +1,20 @@
+[
+ {
+ "name":"test-stream-output",
+ "type":"org.apache.eagle.alert.engine.publisher.impl.AlertEmailPublisher",
+ "policyIds": [
+ "perfmon_cpu_host_check", "perfmon_cpu_pool_check"
+ ],
+ "properties": {
+ "subject":"Eagle Test Alert",
+ "template":"",
+ "sender": "sender@corp.com",
+ "recipients": "receiver@corp.com",
+ "smtp.server":"mailhost.com",
+ "connection": "plaintext",
+ "smtp.port": "25"
+ },
+ "dedupIntervalMin" : "PT1M",
+ "serializer" : "org.apache.eagle.alert.engine.publisher.impl.StringEventSerializer"
+ }
+]
\ No newline at end of file