eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yonzhang2...@apache.org
Subject [03/13] incubator-eagle git commit: EAGLE-341 clean inner process alert engine code clean inner process alert engine code
Date Sun, 14 Aug 2016 06:23:03 GMT
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/alert/entity/SiteDescServiceEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/alert/entity/SiteDescServiceEntity.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/alert/entity/SiteDescServiceEntity.java
deleted file mode 100644
index a8245cf..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/alert/entity/SiteDescServiceEntity.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.alert.entity;
-
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-import org.apache.eagle.log.entity.meta.*;
-import org.apache.eagle.policy.common.Constants;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@Table("eagleSiteDesc")
-@ColumnFamily("f")
-@Prefix("eagleSiteDesc")
-@Service(Constants.SITE_DESCRIPTION_SERVICE_ENDPOINT_NAME)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@TimeSeries(false)
-@Tags({"site"})
-public class SiteDescServiceEntity extends TaggedLogAPIEntity {
-    @Column("a")
-    private Boolean enabled;
-
-    public Boolean getEnabled() {
-        return enabled;
-    }
-
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
-        valueChanged("enabled");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/DynamicPolicyLoader.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/DynamicPolicyLoader.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/DynamicPolicyLoader.java
deleted file mode 100644
index 20da2cf..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/DynamicPolicyLoader.java
+++ /dev/null
@@ -1,268 +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.policy;
-
-import com.netflix.config.*;
-import com.sun.jersey.client.impl.CopyOnWriteHashMap;
-import com.typesafe.config.Config;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity;
-import org.apache.eagle.common.config.EagleConfigConstants;
-import org.apache.eagle.policy.dao.PolicyDefinitionDAO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- *
- * @param <T>
- */
-public class DynamicPolicyLoader<T extends AbstractPolicyDefinitionEntity> {
-	private static final Logger LOG = LoggerFactory.getLogger(DynamicPolicyLoader.class);
-	
-	private final int defaultInitialDelayMillis = 30*1000;
-	private final int defaultDelayMillis = 60*1000;
-	private final boolean defaultIgnoreDeleteFromSource = true;
-    /**
-     * one alertExecutor may have multiple instances, that is why there is a list of PolicyLifecycleMethods
-     */
-	private volatile CopyOnWriteHashMap<String, List<PolicyLifecycleMethods<T>>> policyChangeListeners = new CopyOnWriteHashMap<>();
-    private volatile CopyOnWriteHashMap<String, List<PolicyDistributionReportMethods>> policyDistributionUpdaters = new CopyOnWriteHashMap<>();
-	private static DynamicPolicyLoader instance = new DynamicPolicyLoader();
-	private volatile boolean initialized = false;
-	
-	public void addPolicyChangeListener(String alertExecutorId, PolicyLifecycleMethods<T> alertExecutor){
-		synchronized(policyChangeListeners) {
-			if (policyChangeListeners.get(alertExecutorId) == null) {
-				policyChangeListeners.put(alertExecutorId, new ArrayList<PolicyLifecycleMethods<T>>());
-			}
-			policyChangeListeners.get(alertExecutorId).add(alertExecutor);
-		}
-	}
-
-	private static ConcurrentHashMap<Class, DynamicPolicyLoader> maps = new ConcurrentHashMap<Class, DynamicPolicyLoader>();
-    public void addPolicyDistributionReporter(String alertExecutorId, PolicyDistributionReportMethods policyDistUpdater){
-        synchronized(policyDistributionUpdaters) {
-            if(policyDistributionUpdaters.get(alertExecutorId) == null) {
-                policyDistributionUpdaters.put(alertExecutorId, new ArrayList<PolicyDistributionReportMethods>());
-            }
-            policyDistributionUpdaters.get(alertExecutorId).add(policyDistUpdater);
-        }
-    }
-	
-	@SuppressWarnings("unchecked")
-	public static <K extends AbstractPolicyDefinitionEntity> DynamicPolicyLoader<K> getInstanceOf(Class<K> clz) {
-		if (maps.containsKey(clz)) {
-			return maps.get(clz);
-		} else {
-			DynamicPolicyLoader<K> loader = new DynamicPolicyLoader<K>();
-			maps.putIfAbsent(clz, loader);
-			return maps.get(clz);
-		}
-	}
-	
-	/**
-	 * singleton with init would be good for unit test as well, and it ensures that
-	 * initialization happens only once before you use it.  
-	 * @param config
-	 * @param dao
-	 */
-	public void init(Map<String, Map<String, T>> initialAlertDefs, 
-			PolicyDefinitionDAO<T> dao, Config config){
-		if(!initialized){
-			synchronized(this){
-				if(!initialized){
-					internalInit(initialAlertDefs, dao, config);
-					initialized = true;
-				}
-			}
-		}
-	}
-	
-	/**
-	 * map from alertExecutorId+partitionId to AlertExecutor which implements PolicyLifecycleMethods
-	 * @param initialAlertDefs
-	 * @param dao
-	 * @param config
-	 */
-	private void internalInit(Map<String, Map<String, T>> initialAlertDefs,
-			PolicyDefinitionDAO<T> dao, Config config){
-		if(!config.getBoolean("dynamicConfigSource.enabled")) {
-            return;
-        }
-		AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler(
-                config.getInt("dynamicConfigSource.initDelayMillis"),
-                config.getInt("dynamicConfigSource.delayMillis"),
-                false
-        );
-
-		scheduler.addPollListener(new PollListener(){
-			@SuppressWarnings("unchecked")
-			@Override
-			public void handleEvent(EventType eventType, PollResult lastResult,
-					Throwable exception) {
-				if (lastResult == null) {
-					LOG.error("The lastResult is null, something must be wrong, probably the eagle service is dead!");
-					throw new RuntimeException("The lastResult is null, probably the eagle service is dead! ", exception);
-				}
-				Map<String, Object> added = lastResult.getAdded();
-				Map<String, Object> changed = lastResult.getChanged();
-				Map<String, Object> deleted = lastResult.getDeleted();
-				for(Map.Entry<String, List<PolicyLifecycleMethods<T>>> entry : policyChangeListeners.entrySet()){
-					String alertExecutorId = entry.getKey();
-					for (PolicyLifecycleMethods<T> policyLifecycleMethod : entry.getValue()) {
-						Map<String, T> addedPolicies = (Map<String, T>)added.get(trimPartitionNum(alertExecutorId));
-						if(addedPolicies != null && addedPolicies.size() > 0){
-							policyLifecycleMethod.onPolicyCreated(addedPolicies);
-						}
-						Map<String, T> changedPolicies = (Map<String, T>)changed.get(trimPartitionNum(alertExecutorId));
-						if(changedPolicies != null && changedPolicies.size() > 0){
-							policyLifecycleMethod.onPolicyChanged(changedPolicies);
-						}
-						Map<String, T> deletedPolicies = (Map<String, T>)deleted.get(trimPartitionNum(alertExecutorId));
-						if(deletedPolicies != null && deletedPolicies.size() > 0){
-							policyLifecycleMethod.onPolicyDeleted(deletedPolicies);
-						}
-					}
-				}
-
-                // notify policyDistributionUpdaters
-                for(Map.Entry<String, List<PolicyDistributionReportMethods>> entry : policyDistributionUpdaters.entrySet()){
-                    for(PolicyDistributionReportMethods policyDistributionUpdateMethod : entry.getValue()){
-                        policyDistributionUpdateMethod.report();
-                    }
-                }
-			}
-			private String trimPartitionNum(String alertExecutorId){
-				int i = alertExecutorId.lastIndexOf('_');
-				if(i != -1){
-					return alertExecutorId.substring(0, i);
-				}
-				return alertExecutorId;
-			}
-		});
-		
-		ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
-		      
-		PolledConfigurationSource source = new DynamicPolicySource<T>(initialAlertDefs, dao, config);
-
-		try{
-			DynamicConfiguration dbSourcedConfiguration = new DynamicConfiguration(source, scheduler);
-			finalConfig.addConfiguration(dbSourcedConfiguration);
-		}catch(Exception ex){
-			LOG.warn("Fail loading from DB, continue without DB sourced configuration", ex);
-		}
-	}
-	
-	public static class DynamicPolicySource<M extends AbstractPolicyDefinitionEntity> implements PolledConfigurationSource {
-		private static Logger LOG = LoggerFactory.getLogger(DynamicPolicySource.class);
-		private Config config;
-		private PolicyDefinitionDAO<M> dao;
-		/**
-		 * mapping from alertExecutorId to list of policies 
-		 */
-		private Map<String, Map<String, M>> cachedAlertDefs;
-		
-		public DynamicPolicySource(Map<String, Map<String, M>> initialAlertDefs, PolicyDefinitionDAO<M> dao, Config config){
-			this.cachedAlertDefs = initialAlertDefs;
-			this.dao = dao;
-			this.config = config;
-		}
-
-		public PollResult poll(boolean initial, Object checkPoint) throws Exception {
-			LOG.info("Poll policy from eagle service " +  config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.HOST) +
-					":" + config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PORT) );
-			Map<String, Map<String, M>> newAlertDefs = 
-					dao.findActivePoliciesGroupbyExecutorId(config.getString("eagleProps.site"),
-                            config.getString("eagleProps.application"));
-			
-			// compare runtime alertDefs with cachedAlertDefs and figure out what are added/deleted/updated
-			Map<String, Object> added = new HashMap<String, Object>();
-			Map<String, Object> changed = new HashMap<String, Object>();
-			Map<String, Object> deleted = new HashMap<String, Object>();
-			
-			Set<String> newAlertExecutorIds = newAlertDefs.keySet();
-			Set<String> cachedAlertExecutorIds = cachedAlertDefs.keySet();
-			
-			// dynamically adding new alert executor is not supported, because alert executor is pre-built while program starts up
-			Collection<String> addedAlertExecutorIds = CollectionUtils.subtract(newAlertExecutorIds, cachedAlertExecutorIds);
-			if(addedAlertExecutorIds != null && addedAlertExecutorIds.size() > 0){
-				LOG.warn("New alertExecutorIds are found : " + addedAlertExecutorIds);
-			}
-			
-			// if one alert executor is missing, it means all policy under that alert executor should be removed
-			Collection<String> deletedAlertExecutorIds = CollectionUtils.subtract(cachedAlertExecutorIds, newAlertExecutorIds);
-			if(deletedAlertExecutorIds != null && deletedAlertExecutorIds.size() > 0){
-				LOG.warn("Some alertExecutorIds are deleted : " + deletedAlertExecutorIds);
-				for(String deletedAlertExecutorId : deletedAlertExecutorIds){
-					deleted.put(deletedAlertExecutorId, cachedAlertDefs.get(deletedAlertExecutorId));
-				}
-			}
-			
-			// we need calculate added/updated/deleted policy for all executors which are not deleted
-//			Collection<String> updatedAlertExecutorIds = CollectionUtils.intersection(newAlertExecutorIds, cachedAlertExecutorIds);
-            Collection<String> updatedAlertExecutorIds = newAlertExecutorIds;
-			for(String updatedAlertExecutorId : updatedAlertExecutorIds){
-				Map<String, M> newPolicies = newAlertDefs.get(updatedAlertExecutorId);
-				Map<String, M> cachedPolicies = cachedAlertDefs.get(updatedAlertExecutorId);
-				PolicyComparator.compare(updatedAlertExecutorId, newPolicies, cachedPolicies, added, changed, deleted);
-			}
-			
-			cachedAlertDefs = newAlertDefs;
-
-			return PollResult.createIncremental(added, changed, deleted, new Date().getTime());
-		}
-	}
-	
-	public static class PolicyComparator {
-		
-		public static <M extends AbstractPolicyDefinitionEntity> void compare(String alertExecutorId, Map<String, M> newPolicies, Map<String, M> cachedPolicies, 
-				Map<String, Object> added, Map<String, Object> changed, Map<String, Object> deleted){
-			Set<String> newPolicyIds = newPolicies.keySet();
-            Set<String> cachedPolicyIds = cachedPolicies != null ? cachedPolicies.keySet() : new HashSet<String>();
-			Collection<String> addedPolicyIds = CollectionUtils.subtract(newPolicyIds, cachedPolicyIds);
-			Collection<String> deletedPolicyIds = CollectionUtils.subtract(cachedPolicyIds, newPolicyIds);
-			Collection<String> changedPolicyIds = CollectionUtils.intersection(cachedPolicyIds, newPolicyIds);
-			if(addedPolicyIds != null && addedPolicyIds.size() > 0){
-				Map<String, M> tmp = new HashMap<String, M>();
-				for(String addedPolicyId : addedPolicyIds){
-					tmp.put(addedPolicyId, newPolicies.get(addedPolicyId));
-				}
-				added.put(alertExecutorId, tmp);
-			}
-			if(deletedPolicyIds != null && deletedPolicyIds.size() > 0){
-				Map<String, M> tmp = new HashMap<String, M>();
-				for(String deletedPolicyId : deletedPolicyIds){
-					tmp.put(deletedPolicyId, cachedPolicies.get(deletedPolicyId));
-				}
-				deleted.put(alertExecutorId, tmp);
-			}
-			if(changedPolicyIds != null && changedPolicyIds.size() > 0){
-				Map<String, M> tmp = new HashMap<String, M>();
-				for(String changedPolicyId : changedPolicyIds){
-					// check if policy is really changed
-					if(!newPolicies.get(changedPolicyId).equals(cachedPolicies.get(changedPolicyId))){
-						tmp.put(changedPolicyId, newPolicies.get(changedPolicyId));
-					}
-				}
-				changed.put(alertExecutorId, tmp);
-			}
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PartitionUtils.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PartitionUtils.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PartitionUtils.java
deleted file mode 100644
index bc9a13f..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PartitionUtils.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.policy;
-
-
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity;
-
-public class PartitionUtils {
-	
-	public static boolean accept(AlertDefinitionAPIEntity alertDef, PolicyPartitioner partitioner, int numPartitions, int partitionSeq){
-		int targetPartitionSeq = partitioner.partition(numPartitions, alertDef.getTags().get(Constants.POLICY_TYPE), alertDef.getTags().get(Constants.POLICY_ID));
-		if(targetPartitionSeq == partitionSeq)
-			return true;
-		return false;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistStatsDAOLogReporter.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistStatsDAOLogReporter.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistStatsDAOLogReporter.java
deleted file mode 100644
index 30868f3..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistStatsDAOLogReporter.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.policy;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-
-/**
- * just append log
- */
-public class PolicyDistStatsDAOLogReporter implements PolicyDistributionStatsDAO{
-    private static Logger LOG = LoggerFactory.getLogger(PolicyDistStatsDAOLogReporter.class);
-
-    @Override
-    public void reportPolicyMembership(String policyGroupId, Set<String> policyIds) {
-        if(policyIds != null){
-            StringBuilder sb = new StringBuilder();
-            sb.append("policyDistirbutionStats for " + policyGroupId + "[" + "total: " + policyIds.size() + ", ");
-            for(String policyId : policyIds){
-                sb.append(policyId + ",");
-            }
-            sb.append("]");
-            LOG.info(sb.toString());
-        }else{
-            LOG.warn("No policies are assigned to " + policyGroupId);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionReportMethods.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionReportMethods.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionReportMethods.java
deleted file mode 100644
index 7181857..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionReportMethods.java
+++ /dev/null
@@ -1,27 +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.policy;
-
-/**
- * framework will call report method, it is AlertExecutor's responsibility to report policy distribution information
- */
-public interface PolicyDistributionReportMethods {
-    void report();
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStats.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStats.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStats.java
deleted file mode 100644
index 7a70c95..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStats.java
+++ /dev/null
@@ -1,74 +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.policy;
-
-/**
- * fields for a policy distribution statistics
- */
-public class PolicyDistributionStats {
-    private String policyGroupId;   // normally groupId is alertExecutorId
-    private String policyId;
-    private boolean markDown;       // true if this policy is marked down, false otherwise
-    private double weight;          // comprehensive factors for policy overhead
-
-    public String getPolicyId() {
-        return policyId;
-    }
-
-    public void setPolicyId(String policyId) {
-        this.policyId = policyId;
-    }
-
-    public boolean isMarkDown() {
-        return markDown;
-    }
-
-    public void setMarkDown(boolean markDown) {
-        this.markDown = markDown;
-    }
-
-    public double getWeight() {
-        return weight;
-    }
-
-    public void setWeight(double weight) {
-        this.weight = weight;
-    }
-
-    public String getPolicyGroupId() {
-        return policyGroupId;
-    }
-
-    public void setPolicyGroupId(String policyGroupId) {
-        this.policyGroupId = policyGroupId;
-    }
-
-    public String toString(){
-        StringBuilder sb = new StringBuilder();
-        sb.append("policyId:");
-        sb.append(policyId);
-        sb.append(", markDown:");
-        sb.append(markDown);
-        sb.append(", weight:");
-        sb.append(weight);
-
-        return sb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStatsDAO.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStatsDAO.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStatsDAO.java
deleted file mode 100644
index 12b2b83..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistributionStatsDAO.java
+++ /dev/null
@@ -1,26 +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.policy;
-
-import java.util.Set;
-
-public interface PolicyDistributionStatsDAO {
-    public void reportPolicyMembership(String policyGroupId, Set<String> policyIds);
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistroStatsLogReporter.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistroStatsLogReporter.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistroStatsLogReporter.java
deleted file mode 100644
index c4033f0..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyDistroStatsLogReporter.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.policy;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-
-/**
- * just append log
- */
-public class PolicyDistroStatsLogReporter implements PolicyDistributionStatsDAO{
-    private static Logger LOG = LoggerFactory.getLogger(PolicyDistroStatsLogReporter.class);
-
-    @Override
-    public void reportPolicyMembership(String policyGroupId, Set<String> policyIds) {
-        if(policyIds != null){
-            StringBuilder sb = new StringBuilder();
-            sb.append("policyDistributionStats for " + policyGroupId +", total: " + policyIds.size() + ", [");
-            for(String policyId : policyIds){
-                sb.append(policyId + ",");
-            }
-            if(policyIds.size() > 0){
-                sb.deleteCharAt(sb.length()-1);
-            }
-            sb.append("]");
-            LOG.info(sb.toString());
-        }else{
-            LOG.warn("No policies are assigned to " + policyGroupId);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyEvaluatorServiceProvider.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyEvaluatorServiceProvider.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyEvaluatorServiceProvider.java
deleted file mode 100644
index f862883..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyEvaluatorServiceProvider.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.policy;
-
-import java.util.List;
-
-import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity;
-
-import com.fasterxml.jackson.databind.Module;
-
-/**
- * to provide extensibility, we need a clear differentiation between framework job and provider logic
- * policy evaluator framework:
- * - connect to eagle data source
- * - read all policy definitions
- * - compare with cached policy definitions
- * - figure out if policy is created, deleted or updated
- *   - if policy is created, then invoke onPolicyCreated
- *   - if policy is deleted, then invoke onPolicyDeleted
- *   - if policy is updated, then invoke onPolicyUpdated
- * - for policy report, replace old evaluator engine with new evaluator engine which is created by policy evaluator provider
- * - specify # of executors for this alert executor id
- * - dynamically balance # of policies evaluated by each alert executor
- *   - use zookeeper to balance. eaglePolicies/${alertExecutorId}/${alertExecutorInstanceId} => list of policies
- * 
- * policy evaluator business features:
- * - register mapping between policy type and PolicyEvaluator
- * - create evaluator engine runtime when configuration is changed
- *
- */
-public interface PolicyEvaluatorServiceProvider<T extends AbstractPolicyDefinitionEntity> {
-	String getPolicyType();
-	Class<? extends PolicyEvaluator<T>> getPolicyEvaluator();
-	List<Module> getBindingModules();
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyLifecycleMethods.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyLifecycleMethods.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyLifecycleMethods.java
deleted file mode 100644
index ad5d5c9..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyLifecycleMethods.java
+++ /dev/null
@@ -1,27 +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.policy;
-
-import java.util.Map;
-
-import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity;
-
-public interface PolicyLifecycleMethods<T extends AbstractPolicyDefinitionEntity> {
-	void onPolicyCreated(Map<String, T> added);
-	void onPolicyChanged(Map<String, T> changed);
-	void onPolicyDeleted(Map<String, T> deleted);
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyManager.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyManager.java
deleted file mode 100644
index 3f3581d..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/PolicyManager.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.policy;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.Module;
-
-public class PolicyManager {
-	private final static Logger LOG = LoggerFactory.getLogger(PolicyManager.class);
-	private static PolicyManager instance = new PolicyManager();
-
-	private ServiceLoader<PolicyEvaluatorServiceProvider> loader;
-	
-	private Map<String, Class<? extends PolicyEvaluator>> policyEvaluators = new HashMap<String, Class<? extends PolicyEvaluator>>();
-	private Map<String, List<Module>> policyModules = new HashMap<String, List<Module>>();
-	
-	private PolicyManager(){
-		loader = ServiceLoader.load(PolicyEvaluatorServiceProvider.class);
-		Iterator<PolicyEvaluatorServiceProvider> iter = loader.iterator();
-		while(iter.hasNext()){
-			PolicyEvaluatorServiceProvider factory = iter.next();
-			LOG.info("Supported policy type : " + factory.getPolicyType());
-			policyEvaluators.put(factory.getPolicyType(), factory.getPolicyEvaluator());
-			policyModules.put(factory.getPolicyType(), factory.getBindingModules());
-		}
-	}
-	
-	public static PolicyManager getInstance(){
-		return instance;
-	}
-	
-	public Class<? extends PolicyEvaluator> getPolicyEvaluator(String policyType){
-		return policyEvaluators.get(policyType);
-	}
-	
-	public List<Module> getPolicyModules(String policyType){
-		return policyModules.get(policyType);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/UrlBuilder.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/UrlBuilder.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/UrlBuilder.java
deleted file mode 100644
index 1267e93..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/UrlBuilder.java
+++ /dev/null
@@ -1,63 +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.policy.common;
-
-import org.apache.eagle.alert.entity.AlertAPIEntity;
-import org.apache.eagle.common.EagleBase64Wrapper;
-import org.apache.eagle.common.config.EagleConfigConstants;
-import org.apache.eagle.log.entity.HBaseInternalLogHelper;
-import org.apache.eagle.log.entity.InternalLog;
-import org.apache.eagle.log.entity.RowkeyBuilder;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.mortbay.util.UrlEncoded;
-import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class UrlBuilder {
-
-    private static final Logger logger = LoggerFactory.getLogger(UrlBuilder.class);
-
-    public static String getEncodedRowkey(AlertAPIEntity entity) throws Exception {
-        InternalLog log = HBaseInternalLogHelper.convertToInternalLog(entity, EntityDefinitionManager.getEntityDefinitionByEntityClass(entity.getClass()));
-        return EagleBase64Wrapper.encodeByteArray2URLSafeString(RowkeyBuilder.buildRowkey(log));
-    }
-
-    public static String buildAlertDetailUrl(String host, int port, AlertAPIEntity entity) {
-        String baseUrl = "http://" + host + ":" + String.valueOf(port) + "/eagle-service/ui/#/common/alertDetail/";
-        try {
-            return baseUrl + UrlEncoded.encodeString(getEncodedRowkey(entity));
-        }
-        catch (Exception ex) {
-            logger.error("Fail to populate encodedRowkey for alert Entity" + entity.toString());
-            return "N/A";
-        }
-    }
-
-    public static String buiildPolicyDetailUrl(String host, int port, Map<String, String> tags) {
-        String baseUrl = "http://" + host + ":" + String.valueOf(port) + "/eagle-service/ui/#/common/policyDetail/?";
-        String format = "policy=%s&site=%s&executor=%s";
-        String policy = tags.get(Constants.POLICY_ID);
-        String site = tags.get(EagleConfigConstants.SITE);
-        String alertExecutorID = tags.get(Constants.ALERT_EXECUTOR_ID);
-        if (policy != null && site != null && alertExecutorID != null) {
-            return baseUrl + String.format(format, policy, site, alertExecutorID);
-        }
-        return "N/A";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/config/AbstractPolicyDefinition.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/config/AbstractPolicyDefinition.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/config/AbstractPolicyDefinition.java
deleted file mode 100644
index a0999e6..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/config/AbstractPolicyDefinition.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.policy.config;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-/**
- * base fields for all policy definition
- */
-@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible=true)
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class AbstractPolicyDefinition {
-	private String type;
-    /**
-     * @return type in string
-     */
-	public String getType() {
-		return type;
-	}
-
-    /**
-     * @param type set type value
-     */
-	public void setType(String type) {
-		this.type = type;
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAO.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAO.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAO.java
deleted file mode 100644
index 03ede74..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAO.java
+++ /dev/null
@@ -1,26 +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.policy.dao;
-
-import org.apache.eagle.alert.entity.AlertExecutorEntity;
-
-import java.util.List;
-
-public interface AlertExecutorDAO {
-    List<AlertExecutorEntity> findAlertExecutorByDataSource(String application) throws Exception;
-    List<AlertExecutorEntity> findAlertExecutor(String application, String alertExecutorId) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAOImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAOImpl.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAOImpl.java
deleted file mode 100644
index 0584fe2..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertExecutorDAOImpl.java
+++ /dev/null
@@ -1,88 +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.policy.dao;
-
-import java.util.List;
-
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.alert.entity.AlertExecutorEntity;
-import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
-import org.apache.eagle.service.client.EagleServiceConnector;
-import org.apache.eagle.service.client.IEagleServiceClient;
-import org.apache.eagle.service.client.impl.EagleServiceClientImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AlertExecutorDAOImpl implements AlertExecutorDAO{
-	
-    private static final Logger LOG = LoggerFactory.getLogger(AlertExecutorDAOImpl.class);
-    
-    private final EagleServiceConnector connector;
-
-    public AlertExecutorDAOImpl(EagleServiceConnector connector){
-        this.connector = connector;
-    }
-
-    @Override
-    public List<AlertExecutorEntity> findAlertExecutorByDataSource(String application) throws Exception{
-        try {
-            IEagleServiceClient client = new EagleServiceClientImpl(connector);
-            String query = Constants.ALERT_EXECUTOR_SERVICE_ENDPOINT_NAME + "[@application=\"" + application + "\"]{*}";
-            GenericServiceAPIResponseEntity<AlertExecutorEntity> response =  client.search()
-                    .startTime(0)
-                    .endTime(10 * DateUtils.MILLIS_PER_DAY)
-                    .pageSize(Integer.MAX_VALUE)
-                    .query(query)
-                    .send();
-            client.close();
-            if (response.getException() != null) {
-                throw new Exception("Got an exception when query eagle service: " + response.getException());
-            }
-            return response.getObj();
-        }
-        catch (Exception ex) {
-            LOG.error("Got an exception when query stream metadata service ", ex);
-            throw new IllegalStateException(ex);
-        }
-    }
-
-    @Override
-    public List<AlertExecutorEntity> findAlertExecutor(String application, String alertExecutorId) throws Exception{
-        try {
-            IEagleServiceClient client = new EagleServiceClientImpl(connector);
-            String query = Constants.ALERT_EXECUTOR_SERVICE_ENDPOINT_NAME + "[@application=\"" + application + "\""
-                    + " AND @alertExecutorId=\"" + alertExecutorId + "\""
-                    + "]{*}";
-            GenericServiceAPIResponseEntity<AlertExecutorEntity> response =  client.search()
-                    .startTime(0)
-                    .endTime(10 * DateUtils.MILLIS_PER_DAY)
-                    .pageSize(Integer.MAX_VALUE)
-                    .query(query)
-                    .send();
-            client.close();
-            if (response.getException() != null) {
-                throw new Exception("Got an exception when query eagle service: " + response.getException());
-            }
-            return response.getObj();
-        }
-        catch (Exception ex) {
-            LOG.error("Got an exception when query stream metadata service ", ex);
-            throw new IllegalStateException(ex);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAO.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAO.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAO.java
deleted file mode 100644
index fd3dbb9..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAO.java
+++ /dev/null
@@ -1,25 +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.policy.dao;
-
-import org.apache.eagle.alert.entity.AlertStreamEntity;
-
-import java.util.List;
-
-public interface AlertStreamDAO {
-    List<AlertStreamEntity> findAlertStreamByDataSource(String dataSource) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAOImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAOImpl.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAOImpl.java
deleted file mode 100644
index c13d8b5..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamDAOImpl.java
+++ /dev/null
@@ -1,60 +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.policy.dao;
-
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.alert.entity.AlertStreamEntity;
-import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
-import org.apache.eagle.service.client.EagleServiceConnector;
-import org.apache.eagle.service.client.IEagleServiceClient;
-import org.apache.eagle.service.client.impl.EagleServiceClientImpl;
-import org.apache.commons.lang.time.DateUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class AlertStreamDAOImpl implements AlertStreamDAO{
-    private final Logger LOG = LoggerFactory.getLogger(AlertStreamDAOImpl.class);
-    private final EagleServiceConnector connector;
-
-    public AlertStreamDAOImpl(EagleServiceConnector connector){
-        this.connector = connector;
-    }
-
-    public List<AlertStreamEntity> findAlertStreamByDataSource(String application) throws Exception{
-        try {
-            IEagleServiceClient client = new EagleServiceClientImpl(connector);
-            String query = Constants.ALERT_STREAM_SERVICE_ENDPOINT_NAME + "[@application=\"" + application + "\"]{*}";
-            GenericServiceAPIResponseEntity<AlertStreamEntity> response =  client.search()
-                    .startTime(0)
-                    .endTime(10 * DateUtils.MILLIS_PER_DAY)
-                    .pageSize(Integer.MAX_VALUE)
-                    .query(query)
-                    .send();
-            client.close();
-            if (response.getException() != null) {
-                throw new Exception("Got an exception when query eagle service: " + response.getException());
-            }
-            return response.getObj();
-        }
-        catch (Exception ex) {
-            LOG.error("Got an exception when query stream metadata service ", ex);
-            throw new IllegalStateException(ex);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAO.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAO.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAO.java
deleted file mode 100644
index f5740f0..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAO.java
+++ /dev/null
@@ -1,25 +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.policy.dao;
-
-import java.util.List;
-
-import org.apache.eagle.alert.entity.AlertStreamSchemaEntity;
-
-public interface AlertStreamSchemaDAO {
-	List<AlertStreamSchemaEntity> findAlertStreamSchemaByApplication(String application) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAOImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAOImpl.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAOImpl.java
deleted file mode 100644
index 69c74db..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/AlertStreamSchemaDAOImpl.java
+++ /dev/null
@@ -1,84 +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.policy.dao;
-
-import java.util.List;
-
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.alert.entity.AlertStreamSchemaEntity;
-import org.apache.eagle.common.config.EagleConfigConstants;
-import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
-import org.apache.eagle.service.client.IEagleServiceClient;
-import org.apache.eagle.service.client.impl.EagleServiceClientImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.typesafe.config.Config;
-
-public class AlertStreamSchemaDAOImpl implements AlertStreamSchemaDAO {
-	private final Logger LOG = LoggerFactory.getLogger(AlertStreamSchemaDAOImpl.class);
-	
-	private final String eagleServiceHost;
-	private final Integer eagleServicePort;
-	private String username;
-	private String password;
-
-	public AlertStreamSchemaDAOImpl(String eagleServiceHost, Integer eagleServicePort) {
-		this(eagleServiceHost, eagleServicePort, null, null);
-	}
-
-	public AlertStreamSchemaDAOImpl(String eagleServiceHost, Integer eagleServicePort, String username, String password) {
-		this.eagleServiceHost = eagleServiceHost;
-		this.eagleServicePort = eagleServicePort;
-		this.username = username;
-		this.password = password;
-	}
-
-	public AlertStreamSchemaDAOImpl(Config config) {
-		this.eagleServiceHost = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.HOST);
-		this.eagleServicePort = config.getInt(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PORT);
-		if (config.hasPath(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME) &&
-			config.hasPath(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD)) {
-			this.username = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME);
-			this.password = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD);
-		}
-	}
-	
-	@Override
-	public List<AlertStreamSchemaEntity> findAlertStreamSchemaByApplication(String application) throws Exception {
-		try {
-			IEagleServiceClient client = new EagleServiceClientImpl(eagleServiceHost, eagleServicePort, username, password);
-			String query = Constants.ALERT_STREAM_SCHEMA_SERVICE_ENDPOINT_NAME + "[@application=\"" + application + "\"]{*}";
-			GenericServiceAPIResponseEntity<AlertStreamSchemaEntity> response =  client.search()
-																		                .startTime(0)
-																		                .endTime(10 * DateUtils.MILLIS_PER_DAY)
-																		                .pageSize(Integer.MAX_VALUE)
-																		                .query(query)
-																	                    .send();
-			client.close();
-			if (response.getException() != null) {
-				throw new Exception("Got an exception when query eagle service: " + response.getException()); 
-			}			
-			return response.getObj();
-		}
-		catch (Exception ex) {
-			LOG.error("Got an exception when query stream metadata service ", ex);
-			throw new IllegalStateException(ex);
-		}					   
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionDAO.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionDAO.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionDAO.java
deleted file mode 100644
index faa81d9..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionDAO.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.policy.dao;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity;
-
-/**
- * @param <T> - Policy definition type
- */
-public interface PolicyDefinitionDAO<T extends AbstractPolicyDefinitionEntity> extends Serializable{
-	/**
-	 * find list of active alert definitions for one specific site and dataSource
-	 * @return
-	 */
-	List<T> findActivePolicies(String site, String application) throws Exception;
-	
-	/**
-	 * find map from alertExecutorId to map from policy Id to alert definition for one specific site and dataSource
-	 * Map from alertExecutorId to map from policyId to policy definition
-       (site,dataSource) => Map[alertExecutorId,Map[policyId,alertDefinition]]
-	 * @return
-	 */
-	Map<String, Map<String, T>> findActivePoliciesGroupbyExecutorId(String site, String dataSource) throws Exception;
-
-    /**
-     * Persists alert definition entity updated with markdown columns into HBase.
-     */
-    void updatePolicyDetails(T entity);
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0f11a591/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionEntityDAOImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionEntityDAOImpl.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionEntityDAOImpl.java
deleted file mode 100644
index 2c8616c..0000000
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/dao/PolicyDefinitionEntityDAOImpl.java
+++ /dev/null
@@ -1,118 +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.policy.dao;
-
-import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity;
-import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
-import org.apache.eagle.policy.common.Constants;
-import org.apache.eagle.service.client.EagleServiceClientException;
-import org.apache.eagle.service.client.EagleServiceConnector;
-import org.apache.eagle.service.client.IEagleServiceClient;
-import org.apache.eagle.service.client.impl.EagleServiceClientImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @since Dec 17, 2015
- *
- */
-public class PolicyDefinitionEntityDAOImpl<T extends AbstractPolicyDefinitionEntity> implements PolicyDefinitionDAO<T> {
-
-	private static final long serialVersionUID = 1L;
-
-	private static final Logger LOG = LoggerFactory.getLogger(PolicyDefinitionEntityDAOImpl.class);
-	private final EagleServiceConnector connector;
-	private final String servicePointName;
-
-	public PolicyDefinitionEntityDAOImpl(EagleServiceConnector connector, String serviceName){
-		this.connector = connector;
-		this.servicePointName = serviceName;
-	}
-
-    @Override
-	public List<T> findActivePolicies(String site, String application) throws Exception {
-		try {
-			IEagleServiceClient client = new EagleServiceClientImpl(connector);
-			String query = servicePointName + "[@site=\"" + site + "\" AND @application=\"" + application + "\" AND @enabled=\"true\"]{*}";
-			GenericServiceAPIResponseEntity<T> response = client.search()
-												                .pageSize(Integer.MAX_VALUE)
-												                .query(query)
-											                    .send();
-			client.close();
-			if (response.getException() != null) {
-				throw new Exception("Got an exception when query eagle service: " + response.getException()); 
-			}
-			List<T> list = response.getObj();
-			List<T> enabledList = new ArrayList<T>();
-			for (T entity : list) {
-				if (entity.isEnabled()) enabledList.add(entity);
-			}
-			return enabledList;
-		}
-		catch (Exception ex) {
-			LOG.error("Got an exception when query alert Def service", ex);
-			throw new IllegalStateException(ex);
-		}					   
-	}
-    
-    
-
-    @Override
-	public Map<String, Map<String, T>> findActivePoliciesGroupbyExecutorId(String site, String application)
-			throws Exception {
-		List<T> list = findActivePolicies(site, application);
-		Map<String, Map<String, T>> map = new HashMap<String, Map<String, T>>();
-		for (T entity : list) {
-			// support both executorId and legacy alertExecutorId
-			String executorID = entity.getTags().containsKey(Constants.EXECUTOR_ID) ? entity.getTags().get(Constants.EXECUTOR_ID)
-					: entity.getTags().get(Constants.ALERT_EXECUTOR_ID);
-
-			if (map.get(executorID) == null) {
-				map.put(executorID, new HashMap<String, T>());
-			}
-			map.get(executorID).put(entity.getTags().get("policyId"), entity);
-		}
-		return map;
-	}
-
-    @Override
-    public void updatePolicyDetails(T entity) {
-        IEagleServiceClient client = new EagleServiceClientImpl(connector);
-
-        List<T> entityList = new ArrayList<>();
-        entityList.add(entity);
-
-        try {
-            client.create(entityList, servicePointName);
-        } catch (IOException | EagleServiceClientException exception) {
-            LOG.error("Exception in updating markdown for policy in HBase ", exception);
-        } finally {
-            try {
-                if (null != client)
-                    client.close();
-            } catch (IOException exception) {
-                LOG.error("Unable to close Eagle service client ", exception);
-            }
-        }
-    }
-}


Mime
View raw message