You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2016/03/03 19:10:17 UTC
[44/51] [partial] incubator-eagle git commit: EAGLE-184 Migrate eagle
website from https://github.com/eaglemonitoring/eaglemonitoring.github.io to
document branch
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java
deleted file mode 100644
index 2c77f1f..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java
+++ /dev/null
@@ -1,158 +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.eagle.notification.plugin;
-
-import com.typesafe.config.Config;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-import org.apache.eagle.notification.base.NotificationConstants;
-import org.apache.eagle.notification.utils.NotificationPluginUtils;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.policy.dao.PolicyDefinitionDAO;
-import org.apache.eagle.policy.dao.PolicyDefinitionEntityDAOImpl;
-import org.apache.eagle.service.client.EagleServiceConnector;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Created on 2/10/16.
- */
-public class NotificationPluginManagerImpl implements NotificationPluginManager {
- private static final Logger LOG = LoggerFactory.getLogger(NotificationPluginManagerImpl.class);
- // mapping from policy Id to NotificationPlugin instance
- private Map<String, Collection<NotificationPlugin>> policyNotificationMapping = new ConcurrentHashMap<>(1); //only one write thread
- private Config config;
-
- public NotificationPluginManagerImpl(Config config){
- this.config = config;
- internalInit();
- }
-
- private void internalInit(){
- // iterate all policy ids, keep those notification which belong to plugins
- PolicyDefinitionDAO policyDefinitionDao = new PolicyDefinitionEntityDAOImpl(new EagleServiceConnector( config ) , Constants.ALERT_DEFINITION_SERVICE_ENDPOINT_NAME);
- String site = config.getString("eagleProps.site");
- String application = config.getString("eagleProps.application");
- try{
- List<AlertDefinitionAPIEntity> activeAlertDefs = policyDefinitionDao.findActivePolicies( site , application);
- // initialize all loaded plugins
- NotificationPluginLoader.getInstance().init(config);
- for(NotificationPlugin plugin : NotificationPluginLoader.getInstance().getNotificationMapping().values()){
- plugin.init(config, activeAlertDefs);
- }
- // build policy and plugin mapping
- for( AlertDefinitionAPIEntity entity : activeAlertDefs ){
- Map<String, NotificationPlugin> plugins = pluginsForPolicy(entity);
- policyNotificationMapping.put(entity.getTags().get(Constants.POLICY_ID) , plugins.values());
- }
- }catch (Exception ex ){
- LOG.error("Error initializing poliy/notification mapping ", ex);
- throw new IllegalStateException(ex);
- }
- }
-
- @Override
- public void notifyAlert(AlertAPIEntity entity) {
- String policyId = entity.getTags().get(Constants.POLICY_ID);
- Collection<NotificationPlugin> plugins = policyNotificationMapping.get(policyId);
- if(plugins == null || plugins.size() == 0) {
- LOG.debug("no plugin found for policy " + policyId);
- return;
- }
- for(NotificationPlugin plugin : plugins){
- try {
- LOG.info("execute notification plugin " + plugin);
- plugin.onAlert(entity);
- }catch(Exception ex){
- LOG.error("fail invoking plugin's onAlert, continue ", ex);
- }
- }
- }
-
- @Override
- public void updateNotificationPlugins(AlertDefinitionAPIEntity alertDef, boolean isDelete) {
- try {
- // Update Notification Plugin about the change in AlertDefinition
- String policyId = alertDef.getTags().get(Constants.POLICY_ID);
- if(isDelete){
- // iterate all plugins and delete this policy
- for(NotificationPlugin plugin : policyNotificationMapping.get(policyId)){
- plugin.update(policyId, null, true);
- }
- policyNotificationMapping.remove(policyId);
- LOG.info("Deleted notifications for policy " + policyId);
- return;
- }
-
- Map<String, NotificationPlugin> plugins = pluginsForPolicy(alertDef);
- // calculate difference between current plugins and previous plugin
- Collection<NotificationPlugin> previousPlugins = policyNotificationMapping.get(policyId);
- if(previousPlugins != null) {
- Collection<NotificationPlugin> deletedPlugins = CollectionUtils.subtract(previousPlugins, plugins.values());
- LOG.info("Going to delete plugins " + deletedPlugins + ", for policy " + policyId);
- for (NotificationPlugin plugin : deletedPlugins) {
- plugin.update(policyId, null, true);
- }
- }
-
- // iterate current notifications and update it individually
- List<Map<String,String>> notificationConfigCollection = NotificationPluginUtils.deserializeNotificationConfig(alertDef.getNotificationDef());
- for( Map<String,String> notificationConf : notificationConfigCollection ) {
- String notificationType = notificationConf.get(NotificationConstants.NOTIFICATION_TYPE);
- // for backward compatibility, use email for default notification type
- if(notificationType == null){
- notificationType = NotificationConstants.EMAIL_NOTIFICATION;
- }
- NotificationPlugin plugin = plugins.get(notificationType);
- if(plugin != null){
- plugin.update(policyId, notificationConf, false);
- }
- }
-
- policyNotificationMapping.put(policyId, plugins.values());// update policy - notification types map
- LOG.info("Successfully broadcasted policy updates to all Notification Plugins ...");
- } catch (Exception e) {
- LOG.error("Error broadcasting policy notification changes ", e);
- }
- }
-
- private Map<String, NotificationPlugin> pluginsForPolicy(AlertDefinitionAPIEntity policy) throws Exception{
- NotificationPluginLoader loader = NotificationPluginLoader.getInstance();
- loader.init(config);
- Map<String, NotificationPlugin> plugins = loader.getNotificationMapping();
- // mapping from notificationType to plugin
- Map<String, NotificationPlugin> notifications = new HashMap<>();
- List<Map<String,String>> notificationConfigCollection = NotificationPluginUtils.deserializeNotificationConfig(policy.getNotificationDef());
- for( Map<String,String> notificationConf : notificationConfigCollection ){
- String notificationType = notificationConf.get(NotificationConstants.NOTIFICATION_TYPE);
- // for backward compatibility, by default notification type is email if notification type is not specified
- if(notificationType == null){
- LOG.warn("notificationType is null so use default notification type email for this policy " + policy);
- notifications.put(NotificationConstants.EMAIL_NOTIFICATION, plugins.get(NotificationConstants.EMAIL_NOTIFICATION));
- }else if(!plugins.containsKey(notificationType)){
- LOG.warn("No NotificationPlugin supports this notificationType " + notificationType);
- }else {
- notifications.put(notificationType, plugins.get(notificationType));
- }
- }
- return notifications;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java
deleted file mode 100644
index 350ecb5..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java
+++ /dev/null
@@ -1,68 +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.eagle.notification.utils;
-
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.CollectionType;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigObject;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Common methods for Notification Plugin
- */
-public class NotificationPluginUtils {
- /**
- * Fetch Notification specific property value
- * @param key
- * @return
- * @throws Exception
- */
- public static String getPropValue(Config config, String key ) throws Exception {
- if( config.getObject("eagleNotificationProps") == null )
- throw new Exception("Eagle Notification Properties not found in application.conf ");
- ConfigObject notificationConf = config.getObject("eagleNotificationProps");
- return notificationConf.get(key).unwrapped().toString();
- }
-
- /**
- * Deserialize Notification Definition and convert all config to Key Value Pairs
- * @param notificationDef
- * @return
- * @throws Exception
- */
- public static List<Map<String,String>> deserializeNotificationConfig( String notificationDef ) throws Exception {
- ObjectMapper mapper = new ObjectMapper();
- CollectionType mapCollectionType = mapper.getTypeFactory().constructCollectionType(List.class, Map.class);
- return mapper.readValue( notificationDef , mapCollectionType);
- }
-
- /**
- * Object to JSON String
- * @param obj
- * @return
- * @throws Exception
- */
- public static String objectToStr( Object obj ) throws Exception {
- ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(obj);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
deleted file mode 100644
index 4ceabad..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
+++ /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.
- -->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width"/>
- <style>
- body {
- width:100% !important;
- min-width: 100%;
- -webkit-text-size-adjust:100%;
- -ms-text-size-adjust:100%;
- margin:0;
- padding:0;
- }
-
- table {
- border-spacing: 0;
- border-collapse: collapse;
- }
-
- table th,
- table td {
- padding: 3px 0 3px 0;
- }
-
- .body {
- width: 100%;
- }
-
- p,a,h1,h2,h3,ul,ol,li {
- font-family: Helvetica, Arial, sans-serif;
- font-weight: normal;
- margin: 0;
- padding: 0;
- }
- p {
- font-size: 14px;
- line-height: 19px;
- }
- a {
- color: #3294b1;
- }
- h1 {
- font-size: 36px;
- margin: 15px 0 5px 0;
- }
- h2 {
- font-size: 32px;
- }
- h3 {
- font-size: 28px;
- }
-
- ul,ol {
- margin: 0 0 0 25px;
- padding: 0;
- }
-
- .btn {
- background: #2ba6cb !important;
- border: 1px solid #2284a1;
- padding: 10px 20px 10px 20px;
- text-align: center;
- }
- .btn:hover {
- background: #2795b6 !important;
- }
- .btn a {
- color: #FFFFFF;
- text-decoration: none;
- font-weight: bold;
- padding: 10px 20px 10px 20px;
- }
-
- .tableBordered {
- border-top: 1px solid #b9e5ff;
- }
- .tableBordered th {
- background: #ECF8FF;
- }
- .tableBordered th p {
- font-weight: bold;
- color: #3294b1;
- }
- .tableBordered th,
- .tableBordered td {
- color: #333333;
- border-bottom: 1px solid #b9e5ff;
- text-align: center;
- padding-bottom: 5px;
- }
-
- .panel {
- height: 100px;
- }
- </style>
- </head>
- <body>
- #set ( $elem = $alertList[0] )
- #set ( $alertUrl = $elem["alertDetailUrl"] )
- #set ( $policyUrl = $elem["policyDetailUrl"] )
- <table class="body">
- <tr>
- <td align="center" valign="top" style="background: #999999; padding: 0 0 0 0;">
- <!-- Eagle Header -->
- <table width="580">
- <tr>
- <td style="padding: 0 0 0 0;" align="left" >
- <p style="color:#FFFFFF;font-weight: bold; font-size: 24px">Eagle</p>
- </td>
- <td style="padding: 0 0 0 0;" align="right">
- <p style="color:#FFFFFF;font-weight: bold;">DAM Alert</p>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr>
- <td align="center" valign="top">
- <!-- Eagle Body -->
- <table width="580">
- <tr>
- <!-- Title -->
- <td align="center">
- <h1>Malicious Data Operation Detected</h1>
- </td>
- </tr>
- <tr>
- <!-- Time -->
- <td>
- <table width="580">
- <tr>
- <td>
- <p><b>Detected Time: $elem["alertTimestamp"]</b></p>
- </td>
- #set ( $severity = $elem["severity"] )
- #if (!$severity || ("$severity" == ""))
- #set ( $elem["severity"] = "WARNING")
- #end
- <td align="right">
- <p><b>
- Severity:
- #if ($elem["severity"] == "WARNING")
- <span>$elem["severity"]</span>
- #else
- <span style="color: #FF0000;">$elem["severity"]</span>
- #end
- </b></p>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <!-- Description -->
- <td valign="top" style="background: #ECF8FF; border: 1px solid #b9e5ff; padding: 10px 10px 12px 10px;">
- <p>$elem["alertMessage"]</p>
- </td>
- </tr>
- <tr>
- <!-- View Detail -->
- <td align="center" style="padding: 10px 0 0 0;">
- <table width="580">
- <tr>
- <td class="btn">
- <a href="$alertUrl">View Alert Details on Eagle Web</a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <!-- Basic Information -->
- <td style="padding: 20px 0 0 0;">
- <p><b>Basic Information:</b></p>
- </td>
- </tr>
- <tr>
- <!-- Basic Information Content -->
- <td>
- <table class="tableBordered" width="580">
- <tr>
- <th>
- <p>Site</p>
- </th>
- <th>
- <p>Data Source</p>
- </th>
- </tr>
- <tr>
- <td>
- <p>$elem["site"]</p>
- </td>
- <td>
- <p>$elem["dataSource"]</p>
- </td>
- </tr>
- <tr>
- <th>
- <p>Alert Type</p>
- </th>
- <th>
- <p>Policy Name</p>
- </th>
- <th>
- <p>Severity</p>
- </th>
- </tr>
- <tr>
- <td>
- <p>DAM Alert</p>
- </td>
- <td>
- <p>$elem["policyId"]</p>
- </td>
- <td>
- <p>$elem["severity"]</p>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <!-- View Detail -->
- <td align="center" style="padding: 10px 0 0 0;">
- <table width="580">
- <tr>
- <td class="btn">
- <a href="$policyUrl">View Policy Details on Eagle Web</a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <!-- Actions Required -->
- <td style="padding: 20px 0 0 0;">
- <p><b>Actions Required:</b></p>
- </td>
- </tr>
- <tr>
- <!-- Possible Root Causes Content -->
- <td class="panel" valign="top" style="background: #F4F4F4; border: 1px solid #AAAAAA; padding: 10px 10px 12px 10px;">
- <p> Malicious data operation found, please check.</p>
- </td>
- </tr>
- <tr>
- <!-- Copyright -->
- <td align="center">
- <p><a href="http://123.xyz.com/alerts/alertlist.html">Copyright 2014 @ Hadoop Eagle</a></p>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/application.conf b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/application.conf
deleted file mode 100644
index d57172b..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/application.conf
+++ /dev/null
@@ -1,69 +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.
-
-{
- "envContextConfig" : {
- "env" : "storm",
- "mode" : "cluster",
- "topologyName" : "sandbox-hdfsAuditLog-topology",
- "stormConfigFile" : "security-auditlog-storm.yaml",
- "parallelismConfig" : {
- "kafkaMsgConsumer" : 1,
- "hdfsAuditLogAlertExecutor*" : 1
- }
- },
- "dataSourceConfig": {
- "topic" : "sandbox_hdfs_audit_log",
- "zkConnection" : "127.0.0.1:2181",
- "brokerZkPath" : "/brokers",
- "zkConnectionTimeoutMS" : 15000,
- "fetchSize" : 1048586,
- "deserializerClass" : "org.apache.eagle.security.auditlog.HdfsAuditLogKafkaDeserializer",
- "transactionZKServers" : "127.0.0.1",
- "transactionZKPort" : 2181,
- "transactionZKRoot" : "/consumers",
- "consumerGroupId" : "eagle.hdfsaudit.consumer",
- "transactionStateUpdateMS" : 2000
- },
- "alertExecutorConfigs" : {
- "hdfsAuditLogAlertExecutor" : {
- "parallelism" : 1,
- "partitioner" : "org.apache.eagle.policy.DefaultPolicyPartitioner",
- "needValidation" : "true"
- }
- },
- "eagleProps" : {
- "site" : "sandbox",
- "dataSource": "hdfsAuditLog",
- "dataJoinPollIntervalSec" : 30,
- "mailHost" : "mailhost.com",
- "mailSmtpPort":"25",
- "mailDebug" : "true",
- "eagleService": {
- "host": "localhost",
- "port": 9099,
- "username": "admin",
- "password": "secret"
- }
- },
- "dynamicConfigSource" : {
- "enabled" : true,
- "initDelayMillis" : 0,
- "delayMillis" : 30000
- },
- "eagleNotificationProps" : {
- "kafka_broker":"192.168.56.101:6667"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh
deleted file mode 100644
index 0293f9d..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/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.
-
-CUR_DIR=$(dirname $0)
-source $CUR_DIR/../../../../../../eagle-assembly/src/main/bin/eagle-env.sh
-
-#####################################################################
-# Import notification plugin configuration into Eagle Service #
-#####################################################################
-
-## AlertNotificationService : schema for notifcation plugin configuration
-echo ""
-echo "Importing notification plugin configurations ... "
-curl -u ${EAGLE_SERVICE_USER}:${EAGLE_SERVICE_PASSWD} -X POST -H 'Content-Type:application/json' \
- "http://${EAGLE_SERVICE_HOST}:${EAGLE_SERVICE_PORT}/eagle-service/rest/entities?serviceName=AlertNotificationService" \
- -d '
- [
- {
- "prefix": "alertNotifications",
- "tags": {
- "notificationType": "email"
- },
- "className": "org.apache.eagle.notification.plugin.AlertEmailPlugin",
- "description": "send alert to email",
- "enabled":true
- },
- {
- "prefix": "alertNotifications",
- "tags": {
- "notificationType": "kafka"
- },
- "className": "org.apache.eagle.notification.plugin.AlertKafkaPlugin",
- "description": "send alert to kafka bus",
- "enabled":true
- },
- {
- "prefix": "alertNotifications",
- "tags": {
- "notificationType": "eagleStore"
- },
- "className": "org.apache.eagle.notification.plugin.AlertEagleStorePlugin",
- "description": "send alert to eagle store",
- "enabled":true
- }
- ]
- '
-
-## Finished
-echo ""
-echo "Finished initialization for alert notification plugins"
-
-exit 0
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java
deleted file mode 100644
index 74c8e40..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java
+++ /dev/null
@@ -1,48 +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.eagle.notifications.testcases;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-import org.apache.eagle.notification.plugin.AlertEagleStorePlugin;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-/**
- * Created on 2/11/16.
- */
-public class TestAlertEagleStorePlugin {
- @Ignore // only work when eagle service is up
- @Test
- public void testEagleStorePlugin() throws Exception{
- AlertEagleStorePlugin plugin = new AlertEagleStorePlugin();
- Config config = ConfigFactory.load();
- AlertDefinitionAPIEntity def = new AlertDefinitionAPIEntity();
- def.setNotificationDef("");
- plugin.init(config, Arrays.asList(def));
-
- AlertAPIEntity alert = new AlertAPIEntity();
- alert.setDescription("");
- plugin.onAlert(alert);
- Assert.assertTrue(plugin.getStatus().successful);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java
deleted file mode 100644
index b44c238..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java
+++ /dev/null
@@ -1,56 +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.eagle.notifications.testcases;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-import org.apache.eagle.common.metric.AlertContext;
-import org.apache.eagle.notification.plugin.AlertEmailPlugin;
-import org.apache.eagle.policy.common.Constants;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-
-/**
- * Created on 2/11/16.
- */
-public class TestAlertEmailPlugin {
- @Ignore // only works when there is correct email setup and eagle service
- @Test
- public void testAlertEmailPlugin() throws Exception{
- AlertEmailPlugin plugin = new AlertEmailPlugin();
- Config config = ConfigFactory.load();
- AlertDefinitionAPIEntity def = new AlertDefinitionAPIEntity();
- def.setTags(new HashMap<String, String>());
- def.getTags().put(Constants.POLICY_ID, "testPolicyId");
- def.setNotificationDef("[{\"notificationType\":\"email\",\"sender\":\"eagle@apache.org\",\"recipients\":\"eagle@apache.org\",\"subject\":\"last check point time lag found.\",\"flavor\":\"email\",\"id\":\"email_1\",\"tplFileName\":\"\"}]");
- plugin.init(config, Arrays.asList(def));
-
- AlertAPIEntity alert = new AlertAPIEntity();
- alert.setTags(new HashMap<String, String>());
- alert.getTags().put(Constants.POLICY_ID, "testPolicyId");
- alert.setDescription("");
- alert.setAlertContext(new AlertContext());
- plugin.onAlert(alert);
- Assert.assertTrue(plugin.getStatus().successful);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java
deleted file mode 100644
index b5ed63e..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java
+++ /dev/null
@@ -1,61 +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.eagle.notifications.testcases;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-import org.apache.eagle.common.metric.AlertContext;
-import org.apache.eagle.notification.plugin.AlertKafkaPlugin;
-import org.apache.eagle.notification.plugin.KafkaProducerSingleton;
-import org.apache.eagle.notification.utils.NotificationPluginUtils;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.kafka.clients.producer.KafkaProducer;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-
-@SuppressWarnings({ "unchecked", "rawtypes" })
-public class TestAlertKafkaPlugin {
- @Ignore // only work when kafka is ready for use
- @Test
- public void testAlertToKafkaBus() throws Exception
- {
- AlertKafkaPlugin plugin = new AlertKafkaPlugin();
- Config config = ConfigFactory.load();
- AlertDefinitionAPIEntity def = new AlertDefinitionAPIEntity();
- def.setTags(new HashMap<String, String>());
- def.getTags().put(Constants.POLICY_ID, "testPolicyId");
- def.setNotificationDef("[{\"notificationType\":\"kafka\",\"topic\":\"testTopic\"}]");
- plugin.init(config, Arrays.asList(def));
-
- AlertAPIEntity alert = new AlertAPIEntity();
- alert.setTags(new HashMap<String, String>());
- alert.getTags().put(Constants.POLICY_ID, "testPolicyId");
- alert.setDescription("");
- alert.setAlertContext(new AlertContext());
- plugin.onAlert(alert);
- Thread.sleep(1000); // wait for message sent out
- Assert.assertTrue(plugin.getStatus().successful);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestGetAllNotifications.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestGetAllNotifications.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestGetAllNotifications.java
deleted file mode 100644
index 2749648..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestGetAllNotifications.java
+++ /dev/null
@@ -1,41 +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.eagle.notifications.testcases;
-
-import com.typesafe.config.Config;
-import org.apache.eagle.alert.entity.AlertNotificationEntity;
-import org.apache.eagle.common.config.EagleConfigFactory;
-import org.apache.eagle.notification.dao.AlertNotificationDAO;
-import org.apache.eagle.notification.dao.AlertNotificationDAOImpl;
-import org.apache.eagle.service.client.EagleServiceConnector;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.List;
-
-public class TestGetAllNotifications {
- @Ignore
- @Test
- public void getAllNotification() throws Exception {
- Config config = EagleConfigFactory.load().getConfig();
- AlertNotificationDAO dao = new AlertNotificationDAOImpl( new EagleServiceConnector(config));
- List<AlertNotificationEntity> list = dao.findAlertNotificationTypes();
- System.out.println(" Fetch all Notifications : "+list);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java
deleted file mode 100644
index 624343b..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java
+++ /dev/null
@@ -1,41 +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.eagle.notifications.testcases;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import junit.framework.Assert;
-import org.apache.eagle.notification.base.NotificationConstants;
-import org.apache.eagle.notification.plugin.NotificationPluginLoader;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Created on 2/10/16.
- */
-public class TestNotificationPluginLoader {
- @Ignore //only work when connected to eagle service
- @Test
- public void testLoader(){
- Config config = ConfigFactory.load();
- NotificationPluginLoader loader = NotificationPluginLoader.getInstance();
- loader.init(config);
- Assert.assertTrue(loader.getNotificationMapping().keySet().contains(NotificationConstants.EAGLE_STORE));
- Assert.assertTrue(loader.getNotificationMapping().keySet().contains(NotificationConstants.KAFKA_STORE));
- Assert.assertTrue(loader.getNotificationMapping().keySet().contains(NotificationConstants.EMAIL_NOTIFICATION));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/application.conf
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/application.conf b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/application.conf
deleted file mode 100644
index 2c5e770..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/application.conf
+++ /dev/null
@@ -1,69 +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.
-
-{
- "envContextConfig" : {
- "env" : "storm",
- "mode" : "cluster",
- "topologyName" : "sandbox-hdfsAuditLog-topology",
- "stormConfigFile" : "security-auditlog-storm.yaml",
- "parallelismConfig" : {
- "kafkaMsgConsumer" : 1,
- "hdfsAuditLogAlertExecutor*" : 1
- }
- },
- "dataSourceConfig": {
- "topic" : "sandbox_hdfs_audit_log",
- "zkConnection" : "127.0.0.1:2181",
- "brokerZkPath" : "/brokers",
- "zkConnectionTimeoutMS" : 15000,
- "fetchSize" : 1048586,
- "deserializerClass" : "org.apache.eagle.security.auditlog.HdfsAuditLogKafkaDeserializer",
- "transactionZKServers" : "127.0.0.1",
- "transactionZKPort" : 2181,
- "transactionZKRoot" : "/consumers",
- "consumerGroupId" : "eagle.hdfsaudit.consumer",
- "transactionStateUpdateMS" : 2000
- },
- "alertExecutorConfigs" : {
- "hdfsAuditLogAlertExecutor" : {
- "parallelism" : 1,
- "partitioner" : "org.apache.eagle.policy.DefaultPolicyPartitioner",
- "needValidation" : "true"
- }
- },
- "eagleProps" : {
- "site" : "sandbox",
- "application": "hdfsAuditLog",
- "dataJoinPollIntervalSec" : 30,
- "mailHost" : "mailhost.com",
- "mailSmtpPort":"25",
- "mailDebug" : "true",
- "eagleService": {
- "host": "localhost",
- "port": 9099,
- "username": "admin",
- "password": "secret"
- }
- },
- "dynamicConfigSource" : {
- "enabled" : true,
- "initDelayMillis" : 0,
- "delayMillis" : 30000
- },
- "eagleNotificationProps" : {
- "kafka_broker":"192.168.56.101:6667"
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/log4j.properties b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/log4j.properties
deleted file mode 100644
index 3499c46..0000000
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,35 +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.
-
-log4j.rootLogger=INFO, stdout
-
- eagle.log.dir=./logs
- eagle.log.file=eagle.log
-
-# standard output
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %p [%t] %c{2}[%L]: %m%n
-
-# Daily Rolling File Appender
- log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
- log4j.appender.DRFA.File=${eagle.log.dir}/${eagle.log.file}
- log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
-## 30-day backup
-# log4j.appender.DRFA.MaxBackupIndex=30
- log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout
-
-# Pattern format: Date LogLevel LoggerName LogMessage
-log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p [%t] %c{2}[%L]: %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/pom.xml b/eagle-core/eagle-alert/eagle-alert-process/pom.xml
deleted file mode 100644
index fdf059d..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/pom.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version="1.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.
- -->
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>eagle</groupId>
- <artifactId>eagle-alert-parent</artifactId>
- <version>0.3.0</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <packaging>jar</packaging>
- <artifactId>eagle-alert-process</artifactId>
- <name>eagle-alert-process</name>
-
- <dependencies>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-embed-server</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-embed-server</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-embed-hbase</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <exclusions>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-embed-hbase</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-alert-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-metric</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wso2.siddhi</groupId>
- <artifactId>siddhi-core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.log4j.wso2</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jdk.tools</groupId>
- <artifactId>jdk.tools</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.wso2.siddhi</groupId>
- <artifactId>siddhi-extension-string</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-stream-process-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-alert-notification-plugin</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>test-jar</id>
- <phase>test-compile</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java
deleted file mode 100644
index 584abc7..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java
+++ /dev/null
@@ -1,37 +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.eagle.alert.config;
-
-import java.io.Serializable;
-
-public class DeduplicatorConfig implements Serializable{
- private static final long serialVersionUID = 1L;
- public int getAlertDedupIntervalMin() {
- return alertDedupIntervalMin;
- }
- public void setAlertDedupIntervalMin(int alertDedupIntervalMin) {
- this.alertDedupIntervalMin = alertDedupIntervalMin;
- }
- public int getEmailDedupIntervalMin() {
- return emailDedupIntervalMin;
- }
- public void setEmailDedupIntervalMin(int emailDedupIntervalMin) {
- this.emailDedupIntervalMin = emailDedupIntervalMin;
- }
- private int alertDedupIntervalMin;
- private int emailDedupIntervalMin;
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java
deleted file mode 100644
index 4816bc9..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java
+++ /dev/null
@@ -1,49 +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.eagle.alert.config;
-
-public class EmailNotificationConfig extends NotificationConfig{
- private static final long serialVersionUID = 1L;
- private String sender;
- private String recipients;
- private String tplFileName;
- private String subject;
- public String getSubject() {
- return subject;
- }
- public void setSubject(String subject) {
- this.subject = subject;
- }
- public String getRecipients() {
- return recipients;
- }
- public void setRecipients(String recipients) {
- this.recipients = recipients;
- }
- public String getSender() {
- return sender;
- }
- public void setSender(String sender) {
- this.sender = sender;
- }
- public String getTplFileName() {
- return tplFileName;
- }
- public void setTplFileName(String tplFileName) {
- this.tplFileName = tplFileName;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java
deleted file mode 100644
index 76f2d56..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java
+++ /dev/null
@@ -1,44 +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.eagle.alert.config;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "flavor", visible=true)
-public class NotificationConfig implements Serializable{
- private static final long serialVersionUID = 1L;
- private String id;
- private String flavor;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getFlavor() {
- return flavor;
- }
-
- public void setFlavor(String flavor) {
- this.flavor = flavor;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/Remediation.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/Remediation.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/Remediation.java
deleted file mode 100644
index ec52508..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/Remediation.java
+++ /dev/null
@@ -1,32 +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.eagle.alert.config;
-
-import java.io.Serializable;
-
-public class Remediation implements Serializable{
- private static final long serialVersionUID = 1L;
- private String id;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertDeduplicationExecutorBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertDeduplicationExecutorBase.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertDeduplicationExecutorBase.java
deleted file mode 100644
index 051df33..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertDeduplicationExecutorBase.java
+++ /dev/null
@@ -1,192 +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.eagle.alert.dedup;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.eagle.datastream.Collector;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.alert.config.DeduplicatorConfig;
-import org.apache.eagle.policy.dao.PolicyDefinitionDAO;
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-import org.apache.eagle.policy.DynamicPolicyLoader;
-import org.apache.eagle.policy.PolicyLifecycleMethods;
-import org.apache.eagle.common.config.EagleConfigConstants;
-import org.apache.eagle.dataproc.core.JsonSerDeserUtils;
-import org.apache.eagle.datastream.JavaStormStreamExecutor2;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.sun.jersey.client.impl.CopyOnWriteHashMap;
-import com.typesafe.config.Config;
-import scala.Tuple2;
-
-public abstract class AlertDeduplicationExecutorBase extends JavaStormStreamExecutor2<String, AlertAPIEntity> implements PolicyLifecycleMethods<AlertDefinitionAPIEntity> {
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(AlertDeduplicationExecutorBase.class);
- protected Config config;
- protected DEDUP_TYPE dedupType;
-
- private List<String> alertExecutorIdList;
- private volatile CopyOnWriteHashMap<String, DefaultDeduplicator<AlertAPIEntity>> alertDedups;
- private PolicyDefinitionDAO<AlertDefinitionAPIEntity> dao;
-
- public enum DEDUP_TYPE {
- ENTITY,
- EMAIL
- }
-
- public AlertDeduplicationExecutorBase(List<String> alertExecutorIdList, DEDUP_TYPE dedupType, PolicyDefinitionDAO<AlertDefinitionAPIEntity> dao){
- this.alertExecutorIdList = alertExecutorIdList;
- this.dedupType = dedupType;
- this.dao = dao;
- }
-
- @Override
- public void prepareConfig(Config config) {
- this.config = config;
- }
-
- public DefaultDeduplicator<AlertAPIEntity> createAlertDedup(AlertDefinitionAPIEntity alertDef) {
- DeduplicatorConfig dedupConfig = null;
- try {
- dedupConfig = JsonSerDeserUtils.deserialize(alertDef.getDedupeDef(), DeduplicatorConfig.class);
- }
- catch (Exception ex) {
- LOG.warn("Initial dedupConfig error, " + ex.getMessage());
- }
-
- if (dedupConfig != null) {
- if (dedupType.equals(DEDUP_TYPE.ENTITY)) {
- return new DefaultDeduplicator<>(dedupConfig.getAlertDedupIntervalMin());
- } else if (dedupType.equals(DEDUP_TYPE.EMAIL)) {
- return new DefaultDeduplicator<>(dedupConfig.getEmailDedupIntervalMin());
- }
- }
-
- return null;
- }
-
- @Override
- public void init() {
- String site = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.SITE);
- String dataSource = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.APPLICATION);
- Map<String, Map<String, AlertDefinitionAPIEntity>> initialAlertDefs;
- try {
- initialAlertDefs = dao.findActivePoliciesGroupbyExecutorId(site, dataSource);
- }
- catch (Exception ex) {
- LOG.error("fail to initialize initialAlertDefs: ", ex);
- throw new IllegalStateException("fail to initialize initialAlertDefs: ", ex);
- }
- Map<String, DefaultDeduplicator<AlertAPIEntity>> tmpDeduplicators = new HashMap<String, DefaultDeduplicator<AlertAPIEntity>>();
- if(initialAlertDefs == null || initialAlertDefs.isEmpty()){
- LOG.warn("No alert definitions was found for site: "+site+", dataSource: "+dataSource);
- } else {
- for (String alertExecutorId: alertExecutorIdList) {
- if(initialAlertDefs.containsKey(alertExecutorId)){
- for(AlertDefinitionAPIEntity alertDef : initialAlertDefs.get(alertExecutorId).values()){
- try {
- DefaultDeduplicator<AlertAPIEntity> deduplicator = createAlertDedup(alertDef);
- if (deduplicator != null)
- tmpDeduplicators.put(alertDef.getTags().get(Constants.POLICY_ID), deduplicator);
- else LOG.warn("The dedup interval is not set, alertDef: " + alertDef);
- }
- catch (Throwable t) {
- LOG.error("Got an exception when initial dedup config, probably dedup config is not set: " + t.getMessage() + "," + alertDef);
- }
- }
- } else {
- LOG.info(String.format("No alert definitions found for site: %s, dataSource: %s, alertExecutorId: %s",site,dataSource,alertExecutorId));
- }
- }
- }
-
- alertDedups = new CopyOnWriteHashMap<>();
- alertDedups.putAll(tmpDeduplicators);
- DynamicPolicyLoader<AlertDefinitionAPIEntity> policyLoader = DynamicPolicyLoader.getInstanceOf(AlertDefinitionAPIEntity.class);
- policyLoader.init(initialAlertDefs, dao, config);
- for (String alertExecutorId : alertExecutorIdList) {
- policyLoader.addPolicyChangeListener(alertExecutorId, this);
- }
- }
-
- @Override
- public void flatMap(java.util.List<Object> input, Collector<Tuple2<String, AlertAPIEntity>> outputCollector){
- String policyId = (String) input.get(0);
- AlertAPIEntity alertEntity = (AlertAPIEntity) input.get(1);
- DefaultDeduplicator<AlertAPIEntity> dedup;
- synchronized(alertDedups) {
- dedup = alertDedups.get(policyId);
- }
-
- List<AlertAPIEntity> ret = Arrays.asList(alertEntity);
- if (dedup == null) {
- LOG.warn("Dedup config for policyId " + policyId + " is not set or is not a valid config");
- } else {
- if (dedup.getDedupIntervalMin() == -1) {
- LOG.warn("the dedup interval is set as -1, which mean all alerts should be deduped(skipped)");
- return;
- }
- ret = dedup.dedup(ret);
- }
- for (AlertAPIEntity entity : ret) {
- outputCollector.collect(new Tuple2(policyId, entity));
- }
- }
-
- public void onPolicyCreated(Map<String, AlertDefinitionAPIEntity> added) {
- if(LOG.isDebugEnabled()) LOG.debug("Alert dedup config to be added : " + added);
- for(AlertDefinitionAPIEntity alertDef : added.values()){
- LOG.info("Alert dedup config really added " + alertDef);
- DefaultDeduplicator<AlertAPIEntity> dedup = createAlertDedup(alertDef);
- if (dedup != null) {
- synchronized(alertDedups) {
- alertDedups.put(alertDef.getTags().get(Constants.POLICY_ID), dedup);
- }
- }
- }
- }
-
- public void onPolicyChanged(Map<String, AlertDefinitionAPIEntity> changed) {
- LOG.info("Alert dedup config changed : " + changed);
- for(AlertDefinitionAPIEntity alertDef : changed.values()){
- LOG.info("Alert dedup config really changed " + alertDef);
- DefaultDeduplicator<AlertAPIEntity> dedup = createAlertDedup(alertDef);
- if (dedup != null) {
- synchronized(alertDedups) {
- alertDedups.put(alertDef.getTags().get(Constants.POLICY_ID), dedup);
- }
- }
- }
- }
-
- public void onPolicyDeleted(Map<String, AlertDefinitionAPIEntity> deleted) {
- LOG.info("alert dedup config deleted : " + deleted);
- for(AlertDefinitionAPIEntity alertDef : deleted.values()){
- LOG.info("alert dedup config deleted " + alertDef);
- // no cleanup to do, just remove it
- synchronized(alertDedups) {
- alertDedups.remove(alertDef.getTags().get(Constants.POLICY_ID));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEmailDeduplicationExecutor.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEmailDeduplicationExecutor.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEmailDeduplicationExecutor.java
deleted file mode 100644
index 8947d2c..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEmailDeduplicationExecutor.java
+++ /dev/null
@@ -1,30 +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.eagle.alert.dedup;
-
-import org.apache.eagle.policy.dao.PolicyDefinitionDAO;
-
-import java.util.List;
-
-public class AlertEmailDeduplicationExecutor extends AlertDeduplicationExecutorBase {
-
- private static final long serialVersionUID = 1L;
-
- public AlertEmailDeduplicationExecutor(List<String> alertExecutorIdList, PolicyDefinitionDAO dao){
- super(alertExecutorIdList, DEDUP_TYPE.EMAIL, dao);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEntityDeduplicationExecutor.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEntityDeduplicationExecutor.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEntityDeduplicationExecutor.java
deleted file mode 100644
index b30dbda..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/AlertEntityDeduplicationExecutor.java
+++ /dev/null
@@ -1,31 +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.eagle.alert.dedup;
-
-import java.util.List;
-
-import org.apache.eagle.policy.dao.PolicyDefinitionDAO;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-
-public class AlertEntityDeduplicationExecutor extends AlertDeduplicationExecutorBase {
-
- private static final long serialVersionUID = 1L;
-
- public AlertEntityDeduplicationExecutor(List<String> alertExecutorIdList, PolicyDefinitionDAO<AlertDefinitionAPIEntity> dao){
- super(alertExecutorIdList, DEDUP_TYPE.ENTITY, dao);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/DefaultDeduplicator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/DefaultDeduplicator.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/DefaultDeduplicator.java
deleted file mode 100644
index b968e38..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/DefaultDeduplicator.java
+++ /dev/null
@@ -1,116 +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.eagle.alert.dedup;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.commons.lang.time.DateUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-
-public class DefaultDeduplicator<T extends TaggedLogAPIEntity> implements EntityDeduplicator<T>{
- protected long dedupIntervalMin;
- protected Map<EntityTagsUniq, Long> entites = new HashMap<EntityTagsUniq, Long>();
- public static Logger LOG = LoggerFactory.getLogger(DefaultDeduplicator.class);
-
- public static enum AlertDeduplicationStatus{
- NEW,
- DUPLICATED,
- IGNORED
- }
-
- public DefaultDeduplicator() {
- this.dedupIntervalMin = 0;
- }
-
- public DefaultDeduplicator(long intervalMin) {
- this.dedupIntervalMin = intervalMin;
- }
-
- public void clearOldCache() {
- List<EntityTagsUniq> removedkeys = new ArrayList<EntityTagsUniq>();
- for (Entry<EntityTagsUniq, Long> entry : entites.entrySet()) {
- EntityTagsUniq entity = entry.getKey();
- if (System.currentTimeMillis() - 7 * DateUtils.MILLIS_PER_DAY > entity.createdTime) {
- removedkeys.add(entry.getKey());
- }
- }
- for (EntityTagsUniq alertKey : removedkeys) {
- entites.remove(alertKey);
- }
- }
-
- public AlertDeduplicationStatus checkDedup(EntityTagsUniq key){
- long current = key.timestamp;
- if(!entites.containsKey(key)){
- entites.put(key, current);
- return AlertDeduplicationStatus.NEW;
- }
-
- long last = entites.get(key);
- if(current - last >= dedupIntervalMin * DateUtils.MILLIS_PER_MINUTE){
- entites.put(key, current);
- return AlertDeduplicationStatus.DUPLICATED;
- }
-
- return AlertDeduplicationStatus.IGNORED;
- }
-
- public List<T> dedup(List<T> list) {
- clearOldCache();
- List<T> dedupList = new ArrayList<T>();
- int totalCount = list.size();
- int dedupedCount = 0;
- for(T entity: list) {
- if (entity.getTags() == null) {
- if(LOG.isDebugEnabled()) LOG.debug("Tags is null, don't know how to deduplicate, do nothing");
- } else {
- AlertDeduplicationStatus status = checkDedup(new EntityTagsUniq(entity.getTags(), entity.getTimestamp()));
- if (!status.equals(AlertDeduplicationStatus.IGNORED)) {
- dedupList.add(entity);
- } else {
- dedupedCount++;
- if (LOG.isDebugEnabled())
- LOG.debug(String.format("Entity is skipped because it's duplicated: " + entity.toString()));
- }
- }
- }
-
- if(dedupedCount>0){
- LOG.info(String.format("Skipped %s of %s alerts because they are duplicated",dedupedCount,totalCount));
- }else if(LOG.isDebugEnabled()){
- LOG.debug(String.format("Skipped %s of %s duplicated alerts",dedupedCount,totalCount));
- }
-
- return dedupList;
- }
-
- public EntityDeduplicator<T> setDedupIntervalMin(long dedupIntervalMin) {
- this.dedupIntervalMin = dedupIntervalMin;
- return this;
- }
-
- public long getDedupIntervalMin() {
- return dedupIntervalMin;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityDeduplicator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityDeduplicator.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityDeduplicator.java
deleted file mode 100644
index e108b94..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityDeduplicator.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.eagle.alert.dedup;
-
-import java.util.List;
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-
-/**
- * Dedup Eagle entities.
- *
- * @param <T> Eagle entity
- */
-public interface EntityDeduplicator<T extends TaggedLogAPIEntity> {
-
- EntityDeduplicator<T> setDedupIntervalMin(long intervalMin);
-
- long getDedupIntervalMin();
-
- List<T> dedup(List<T> list);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityTagsUniq.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityTagsUniq.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityTagsUniq.java
deleted file mode 100644
index 81c8ba6..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/dedup/EntityTagsUniq.java
+++ /dev/null
@@ -1,81 +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.eagle.alert.dedup;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @since Mar 19, 2015
- */
-public class EntityTagsUniq {
- public Map<String, String> tags;
- public Long timestamp; // entity's timestamp
- public long createdTime; // entityTagsUniq's created time, for cache removal;
-
- private static final Logger LOG = LoggerFactory.getLogger(EntityTagsUniq.class);
-
- public EntityTagsUniq(Map<String, String> tags, long timestamp) {
- this.tags = new HashMap<String, String>(tags);
- this.timestamp = timestamp;
- this.createdTime = System.currentTimeMillis();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EntityTagsUniq) {
- EntityTagsUniq au = (EntityTagsUniq) obj;
- if (tags.size() != au.tags.size()) return false;
- for (Entry<String, String> keyValue : au.tags.entrySet()) {
- boolean keyExist = tags.containsKey(keyValue.getKey());
- // sanity check
- if (tags.get(keyValue.getKey()) == null || keyValue.getValue() == null) {
- return true;
- }
- if ( !keyExist || !tags.get(keyValue.getKey()).equals(keyValue.getValue())) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- int hashCode = 0;
- for (Map.Entry<String,String> entry : tags.entrySet()) {
- if(entry.getValue() == null) {
- LOG.warn("Tag value for key ["+entry.getKey()+"] is null, skipped for hash code");
- }else {
- try {
- hashCode ^= entry.getValue().hashCode();
- } catch (Throwable t) {
- LOG.info("Got exception because of entry: " + entry, t);
- }
- }
- }
- return hashCode;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/executor/AlertExecutor.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/executor/AlertExecutor.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/executor/AlertExecutor.java
deleted file mode 100644
index 2eee6c5..0000000
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/executor/AlertExecutor.java
+++ /dev/null
@@ -1,41 +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.eagle.alert.executor;
-
-import org.apache.eagle.policy.ResultRender;
-import org.apache.eagle.policy.dao.PolicyDefinitionDAO;
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-import org.apache.eagle.policy.PolicyPartitioner;
-import org.apache.eagle.policy.executor.PolicyProcessExecutor;
-import org.apache.eagle.alert.siddhi.SiddhiAlertAPIEntityRender;
-
-public class AlertExecutor extends PolicyProcessExecutor<AlertDefinitionAPIEntity, AlertAPIEntity> {
-
- private final SiddhiAlertAPIEntityRender resultRender = new SiddhiAlertAPIEntityRender();
-
- public AlertExecutor(String alertExecutorId, PolicyPartitioner partitioner, int numPartitions, int partitionSeq,
- PolicyDefinitionDAO<AlertDefinitionAPIEntity> alertDefinitionDao, String[] sourceStreams) {
- super(alertExecutorId, partitioner, numPartitions, partitionSeq, alertDefinitionDao, sourceStreams,
- AlertDefinitionAPIEntity.class);
- }
-
- @Override
- public ResultRender<AlertDefinitionAPIEntity, AlertAPIEntity> getResultRender() {
- return resultRender;
- }
-}