http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/AlertKafkaPlugin.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/AlertKafkaPlugin.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/AlertKafkaPlugin.java deleted file mode 100644 index 683f2f5..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/AlertKafkaPlugin.java +++ /dev/null @@ -1,140 +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.lang3.builder.HashCodeBuilder; -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.base.NotificationStatus; -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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -/** - * send alert to Kafka bus - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class AlertKafkaPlugin implements NotificationPlugin { - private static final Logger LOG = LoggerFactory.getLogger(AlertKafkaPlugin.class); - private List<NotificationStatus> statusList = new Vector<>(); - private Map<String, List<Map<String, String>>> kafaConfigs = new ConcurrentHashMap<>(); - private Config config; - - @Override - public void init(Config config, List<AlertDefinitionAPIEntity> initAlertDefs) throws Exception { - this.config = config; - for( AlertDefinitionAPIEntity entity : initAlertDefs ) { - List<Map<String,String>> configMaps = NotificationPluginUtils.deserializeNotificationConfig(entity.getNotificationDef()); - this.update(entity.getTags().get(Constants.POLICY_ID), configMaps, false); - } - } - - /** - * Update API to update policy delete/create/update in Notification Plug-ins - * @param notificationConfigCollection - * @param isPolicyDelete - * @throws Exception - */ - @Override - public void update(String policyId, List<Map<String,String>> notificationConfigCollection, boolean isPolicyDelete ) throws Exception { - if( isPolicyDelete ){ - LOG.info(" Policy been deleted.. Removing reference from Notification Plugin "); - this.kafaConfigs.remove(policyId); - return; - } - Vector<Map<String, String>> kafkaConfigList = new Vector<>(); - for(Map<String,String> notificationConfigMap : notificationConfigCollection){ - String notificationType = notificationConfigMap.get(NotificationConstants.NOTIFICATION_TYPE); - if(notificationType == null){ - LOG.error("invalid notificationType for this notification, ignoring and continue " + notificationConfigMap); - continue; - }else { - // single policy can have multiple configs , only load Kafka Config's - if (notificationType.equalsIgnoreCase(NotificationConstants.KAFKA_STORE)) { - kafkaConfigList.add(notificationConfigMap); - } - } - } - if(kafkaConfigList.size() != 0) { - kafaConfigs.put(policyId, kafkaConfigList); - } - } - - /** - * Post Notification to KafkaTopic - * @param alertEntity - */ - @Override - public void onAlert(AlertAPIEntity alertEntity) { - String policyId = alertEntity.getTags().get(Constants.POLICY_ID); - for(Map<String, String> kafkaConfig: this.kafaConfigs.get(policyId)) { - NotificationStatus status = new NotificationStatus(); - try{ - KafkaProducer producer = KafkaProducerSingleton.INSTANCE.getProducer(kafkaConfig); - producer.send(createRecord(alertEntity, kafkaConfig.get(NotificationConstants.TOPIC))); - status.successful = true; - status.errorMessage = ""; - }catch(Exception ex ){ - LOG.error("fail writing alert to Kafka bus", ex); - status.successful = false; - status.errorMessage = ex.getMessage(); - } - this.statusList.add(status); - } - } - - /** - * To Create KafkaProducer Record - * @param entity - * @return - * @throws Exception - */ - private ProducerRecord createRecord(AlertAPIEntity entity, String topic) throws Exception { - ProducerRecord record = new ProducerRecord(topic, NotificationPluginUtils.objectToStr(entity)); - return record; - } - - @Override - public List<NotificationStatus> getStatusList() { - return statusList; - } - - @Override - public int hashCode(){ - return new HashCodeBuilder().append(getClass().getCanonicalName()).toHashCode(); - } - - @Override - public boolean equals(Object o){ - if(o == this) - return true; - if(!(o instanceof AlertKafkaPlugin)) - return false; - return true; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/KafkaProducerSingleton.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/KafkaProducerSingleton.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/KafkaProducerSingleton.java deleted file mode 100644 index bc9e3c9..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/KafkaProducerSingleton.java +++ /dev/null @@ -1,47 +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 java.util.Map; -import java.util.Properties; - -import com.typesafe.config.Config; -import org.apache.eagle.notification.base.NotificationConstants; -import org.apache.eagle.notification.utils.NotificationPluginUtils; -import org.apache.kafka.clients.producer.KafkaProducer; - -/** - * The producer is thread safe and sharing a single producer instance across threads will generally be faster than having multiple instances. - */ -public enum KafkaProducerSingleton { - INSTANCE; - - public KafkaProducer<String, Object> getProducer(Map<String, String> config) throws Exception{ - Properties configMap = new Properties(); - String broker_list = config.get(NotificationConstants.BROKER_LIST); - configMap.put("bootstrap.servers", broker_list); - configMap.put("metadata.broker.list", broker_list); - configMap.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); - configMap.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); - configMap.put("request.required.acks", "1"); - configMap.put("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer"); - configMap.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer"); - KafkaProducer<String, Object> producer = new KafkaProducer<>(configMap); - return producer; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPlugin.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPlugin.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPlugin.java deleted file mode 100644 index 92ee0b5..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPlugin.java +++ /dev/null @@ -1,59 +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.eagle.alert.entity.AlertAPIEntity; -import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity; -import org.apache.eagle.notification.base.NotificationStatus; - -import java.util.List; -import java.util.Map; - -/** - * Created on 2/10/16. - * Notification Plug-in interface which provide abstraction layer to notify to different system - */ -public interface NotificationPlugin { - /** - * for initialization - * @throws Exception - */ - void init(Config config, List<AlertDefinitionAPIEntity> initAlertDefs) throws Exception; - - /** - * Update Plugin if any change in Policy Definition - * @param policy to be impacted - * @param notificationConfCollection - * @throws Exception - */ - void update(String policy, List<Map<String,String>> notificationConfCollection , boolean isPolicyDelete) throws Exception; - - /** - * Post a notification for the given alertEntity - * @param alertEntity - * @throws Exception - */ - - void onAlert(AlertAPIEntity alertEntity) throws Exception; - - /** - * Returns Status of Notification Post - * @return - */ - List<NotificationStatus> getStatusList(); -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginLoader.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginLoader.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginLoader.java deleted file mode 100644 index 4aa90c5..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginLoader.java +++ /dev/null @@ -1,92 +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.eagle.alert.entity.AlertNotificationEntity; -import org.apache.eagle.notification.base.NotificationConstants; -import org.apache.eagle.notification.dao.AlertNotificationDAO; -import org.apache.eagle.notification.dao.AlertNotificationDAOImpl; -import org.apache.eagle.service.client.EagleServiceConnector; -import org.reflections.Reflections; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Created on 2/10/16. - * don't support dynamic discovery as of 2/10 - */ -public class NotificationPluginLoader { - private static final Logger LOG = LoggerFactory.getLogger(NotificationPluginLoader.class); - private static NotificationPluginLoader instance = new NotificationPluginLoader(); - private static Map<String,NotificationPlugin> notificationMapping = new ConcurrentHashMap<>(); - - private Config config; - private boolean initialized = false; - - public static NotificationPluginLoader getInstance(){ - return instance; - } - - public void init(Config config){ - if(!initialized){ - synchronized (this){ - if(!initialized){ - internalInit(config); - initialized = true; - } - } - } - } - - private void internalInit(Config config){ - this.config = config; - loadPlugins(); - } - - /** - * Scan & Load Plugins - */ - private void loadPlugins(){ - try { - LOG.info("Start loading Plugins from eagle service ..."); - AlertNotificationDAO dao = new AlertNotificationDAOImpl(new EagleServiceConnector(config)); - List<AlertNotificationEntity> activeNotificationPlugins = dao.findAlertNotificationTypes(); - for(AlertNotificationEntity plugin : activeNotificationPlugins){ - notificationMapping.put(plugin.getTags().get(NotificationConstants.NOTIFICATION_TYPE), - (NotificationPlugin) Class.forName(plugin.getClassName()).newInstance()); - } - LOG.info("successfully loaded Plugins from eagle service " + activeNotificationPlugins); - }catch ( Exception ex ){ - LOG.error("Error in loading Notification Plugins: ", ex); - throw new IllegalStateException(ex); - } - } - - public Map<String, NotificationPlugin> getNotificationMapping() { - ensureInitialized(); - return notificationMapping; - } - - private void ensureInitialized(){ - if(!initialized) - throw new IllegalStateException("Plugin loader not initialized"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManager.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManager.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManager.java deleted file mode 100644 index fdf62d1..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManager.java +++ /dev/null @@ -1,39 +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 org.apache.eagle.alert.entity.AlertAPIEntity; -import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity; - -/** - * Created on 2/10/16. - */ -public interface NotificationPluginManager { - /** - * notify alerts to plugins for one specific alert entity - * @param entity - */ - void notifyAlert( AlertAPIEntity entity ); - - /** - * responds to changes of alert notification definition - * @param entity - * @param isDelete - */ - void updateNotificationPlugins(AlertDefinitionAPIEntity entity , boolean isDelete ); -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java deleted file mode 100644 index 8e9e3b2..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/plugin/NotificationPluginManagerImpl.java +++ /dev/null @@ -1,151 +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 policy/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.warn("no alert notification plugins 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(NotificationPlugin plugin: plugins.values()) { - plugin.update(policyId, notificationConfigCollection, false); - } - - policyNotificationMapping.put(policyId, plugins.values());// update policy - notification types map - LOG.info("Successfully broadcast 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)); - notifications.put(NotificationConstants.EAGLE_STORE, plugins.get(NotificationConstants.EAGLE_STORE)); - }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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java deleted file mode 100644 index e490be3..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/utils/NotificationPluginUtils.java +++ /dev/null @@ -1,67 +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.typesafe.config.Config; -import com.typesafe.config.ConfigObject; -import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.type.CollectionType; - -import java.util.List; -import java.util.Map; - -/** - * Common methods for Notification Plugin - */ -public class NotificationPluginUtils { - private final static ObjectMapper OBJECT_MAPPER = TaggedLogAPIEntity.buildObjectMapper(); - /** - * 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 { - CollectionType mapCollectionType = OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Map.class); - return OBJECT_MAPPER.readValue(notificationDef, mapCollectionType); - } - - /** - * Object to JSON String - * @param obj - * @return - * @throws Exception - */ - public static String objectToStr( Object obj ) throws Exception { - return OBJECT_MAPPER.writeValueAsString(obj); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm deleted file mode 100644 index 3e29439..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm +++ /dev/null @@ -1,266 +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> - </tr> - </table> - </td> - </tr> - - <tr> - <td align="center" valign="top"> - <!-- Eagle Body --> - <table width="580"> - <tr> - <!-- Title --> - <td align="center"> - <h1>$elem["application"] Alert 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["application"]</p> - </td> - </tr> - <tr> - <th> - <p>Policy Name</p> - </th> - <th> - <p>Severity</p> - </th> - </tr> - <tr> - <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> $elem["application"] alert found, please check.</p> - </td> - </tr> - <tr> - <!-- Copyright --> - <td align="center"> - <p><a href="<Eagle-Host>/alerts/alertlist.html">Apache 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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/application.conf ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/application.conf b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/application.conf deleted file mode 100644 index d57172b..0000000 --- a/eagle-core/eagle-alert-parent/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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/main/resources/notification-plugins-init.sh deleted file mode 100644 index 0293f9d..0000000 --- a/eagle-core/eagle-alert-parent/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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java deleted file mode 100644 index e1c2ead..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEagleStorePlugin.java +++ /dev/null @@ -1,50 +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 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.AlertEagleStorePlugin; -import org.junit.Assert; -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(""); - alert.setAlertContext(new AlertContext().toJsonString()); - plugin.onAlert(alert); - Assert.assertTrue(plugin.getStatusList().get(0).successful); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertEmailPlugin.java deleted file mode 100644 index 7a52369..0000000 --- a/eagle-core/eagle-alert-parent/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 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.Assert; -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\":\"[email protected]\",\"recipients\":\"[email protected]\",\"subject\":\"last check point time lag found.\",\"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.setDecodedAlertContext(new AlertContext()); - plugin.onAlert(alert); - Assert.assertTrue(plugin.getStatusList().get(0).successful); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java deleted file mode 100644 index 414211a..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestAlertKafkaPlugin.java +++ /dev/null @@ -1,57 +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 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.policy.common.Constants; -import org.junit.Assert; -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\",\"kafka_broker\":\"sandbox.hortonworks.com:6667\",\"topic\":\"sandbox_hdfs_audit_log\"}]"); - 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().toJsonString()); - plugin.onAlert(alert); - Thread.sleep(1000); // wait for message sent out - Assert.assertTrue(plugin.getStatusList().get(0).successful); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestGetAllNotifications.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestGetAllNotifications.java b/eagle-core/eagle-alert-parent/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-parent/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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginLoader.java deleted file mode 100644 index e128770..0000000 --- a/eagle-core/eagle-alert-parent/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 org.apache.eagle.notification.base.NotificationConstants; -import org.apache.eagle.notification.plugin.NotificationPluginLoader; -import org.junit.Assert; -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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginManager.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginManager.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginManager.java deleted file mode 100644 index 2b6f25d..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginManager.java +++ /dev/null @@ -1,93 +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 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.NotificationPluginManager; -import org.apache.eagle.notification.plugin.NotificationPluginManagerImpl; -import org.apache.eagle.policy.common.Constants; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.HashMap; - -public class TestNotificationPluginManager { - @Ignore - @Test - public void testUpdateNotificationPlugins() { - boolean isDelete = false; - AlertDefinitionAPIEntity alertDef = new AlertDefinitionAPIEntity(); - alertDef.setTags(new HashMap<String, String>()); - alertDef.getTags().put(Constants.POLICY_ID, "testPlugin"); - alertDef.setNotificationDef("[]"); - Config config = ConfigFactory.load(); - NotificationPluginManager manager = new NotificationPluginManagerImpl(config); - manager.updateNotificationPlugins(alertDef, isDelete); - Assert.assertTrue(true); - } - @Ignore - @Test - public void testUpdateNotificationPlugins2() { - boolean isDelete = false; - AlertDefinitionAPIEntity alertDef = new AlertDefinitionAPIEntity(); - alertDef.setTags(new HashMap<String, String>()); - alertDef.getTags().put(Constants.POLICY_ID, "testEmptyPlugins"); - alertDef.setNotificationDef("[{\"notificationType\":\"eagleStore\"},{\"notificationType\":\"kafka\",\"kafka_broker\":\"sandbox.hortonworks.com:6667\",\"topic\":\"testTopic\"}]"); - Config config = ConfigFactory.load(); - NotificationPluginManager manager = new NotificationPluginManagerImpl(config); - manager.updateNotificationPlugins(alertDef, isDelete); - Assert.assertTrue(true); - } - - @Ignore - @Test - public void testUpdateNotificationPluginsWithDelete() { - boolean isDelete = true; - AlertDefinitionAPIEntity alertDef = new AlertDefinitionAPIEntity(); - alertDef.setTags(new HashMap<String, String>()); - alertDef.getTags().put(Constants.POLICY_ID, "testEmptyPlugins"); - alertDef.setNotificationDef("[]"); - Config config = ConfigFactory.load(); - NotificationPluginManager manager = new NotificationPluginManagerImpl(config); - manager.updateNotificationPlugins(alertDef, isDelete); - Assert.assertTrue(true); - } - - @Ignore - @Test - public void testMultipleNotificationInstance() { - AlertAPIEntity alert = new AlertAPIEntity(); - alert.setTags(new HashMap<String, String>()); - alert.getTags().put(Constants.POLICY_ID, "testPlugin"); - alert.setDescription(""); - alert.setAlertContext(new AlertContext().toJsonString()); - - Config config = ConfigFactory.load(); - NotificationPluginManager manager = new NotificationPluginManagerImpl(config); - manager.notifyAlert(alert); - Assert.assertTrue(true); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginUtils.java b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginUtils.java deleted file mode 100644 index 022526c..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/java/org/apache/eagle/notifications/testcases/TestNotificationPluginUtils.java +++ /dev/null @@ -1,38 +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 org.apache.eagle.notification.utils.NotificationPluginUtils; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - - -public class TestNotificationPluginUtils { - @Ignore - @Test - public void testDeserializeNotificationConfig() throws Exception { - String notificationDef = "[]"; - List<Map<String,String>> list = NotificationPluginUtils.deserializeNotificationConfig(notificationDef); - Assert.assertTrue(list.isEmpty()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/resources/application.conf ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/resources/application.conf b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/resources/application.conf deleted file mode 100644 index 2c5e770..0000000 --- a/eagle-core/eagle-alert-parent/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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/resources/log4j.properties b/eagle-core/eagle-alert-parent/eagle-alert-notification-plugin/src/test/resources/log4j.properties deleted file mode 100644 index 3499c46..0000000 --- a/eagle-core/eagle-alert-parent/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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-process/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-process/pom.xml b/eagle-core/eagle-alert-parent/eagle-alert-process/pom.xml deleted file mode 100644 index 1d35d95..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-process/pom.xml +++ /dev/null @@ -1,137 +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 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> - <parent> - <groupId>org.apache.eagle</groupId> - <artifactId>eagle-alert-parent</artifactId> - <version>0.5.0-incubating-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - <packaging>jar</packaging> - <artifactId>eagle-alert-process</artifactId> - <name>eagle-alert-process</name> - - <dependencies> - <dependency> - <groupId>org.apache.eagle</groupId> - <artifactId>eagle-embed-server</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.eagle</groupId> - <artifactId>eagle-embed-server</artifactId> - <version>${project.version}</version> - <classifier>tests</classifier> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.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>org.apache.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>org.apache.eagle</groupId> - <artifactId>eagle-alert-base</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.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>org.apache.eagle</groupId> - <artifactId>eagle-stream-process-base</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java b/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java deleted file mode 100644 index 1e65408..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/DeduplicatorConfig.java +++ /dev/null @@ -1,42 +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 java.util.List; - -public class DeduplicatorConfig implements Serializable{ - private static final long serialVersionUID = 1L; - - private int alertDedupIntervalMin; - private List<String> fields; - - public int getAlertDedupIntervalMin() { - return alertDedupIntervalMin; - } - - public void setAlertDedupIntervalMin(int alertDedupIntervalMin) { - this.alertDedupIntervalMin = alertDedupIntervalMin; - } - public List<String> getFields() { - return fields; - } - - public void setFields(List<String> fields) { - this.fields = fields; - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java b/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java deleted file mode 100644 index f543d63..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/EmailNotificationConfig.java +++ /dev/null @@ -1,50 +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; - -@Deprecated -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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java b/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java deleted file mode 100644 index 60c87dc..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/NotificationConfig.java +++ /dev/null @@ -1,45 +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; - -@Deprecated -@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/0f11a591/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/Remediation.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-process/src/main/java/org/apache/eagle/alert/config/Remediation.java b/eagle-core/eagle-alert-parent/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-parent/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; - } -}
