eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ralp...@apache.org
Subject [1/2] incubator-eagle git commit: [EAGLE-439] Introduce policy enable/disable support
Date Wed, 10 Aug 2016 02:34:30 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/develop 53370c2e7 -> a0458ba26


[EAGLE-439] Introduce policy enable/disable support


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/17670aca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/17670aca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/17670aca

Branch: refs/heads/develop
Commit: 17670acae1ad64ca378e8a60676f027845528dd8
Parents: 1d84256
Author: Xiancheng Li <xiancheng.li@ebay.com>
Authored: Mon Aug 8 18:00:43 2016 +0800
Committer: Xiancheng Li <xiancheng.li@ebay.com>
Committed: Wed Aug 10 09:34:13 2016 +0800

----------------------------------------------------------------------
 .gitignore                                      |  1 +
 .../engine/coordinator/PolicyDefinition.java    | 15 ++++++++++-
 .../provider/ScheduleContextBuilder.java        |  8 ++++--
 .../src/test/resources/simple/policies.json     | 27 ++++++++++++++++++++
 4 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/17670aca/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 992c9af..b9640d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,7 @@ target/
 target/*
 */target/*
 **/target/*
+**/bin/*
 pom.xml.tag
 pom.xml.releaseBackup
 pom.xml.versionsBackup

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/17670aca/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinition.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinition.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinition.java
index f97eb2b..95de4c9 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinition.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/engine/coordinator/PolicyDefinition.java
@@ -36,6 +36,7 @@ public class PolicyDefinition implements Serializable{
     private List<String> outputStreams = new ArrayList<String>();
 
     private Definition definition;
+    private PolicyStatus policyStatus = PolicyStatus.ENABLED;
 
     // one stream only have one partition in one policy, since we don't support stream alias
     private List<StreamPartition> partitionSpec = new ArrayList<StreamPartition>();
@@ -103,7 +104,15 @@ public class PolicyDefinition implements Serializable{
         this.parallelismHint = parallelism;
     }
 
-    @Override
+    public PolicyStatus getPolicyStatus() {
+		return policyStatus;
+	}
+
+	public void setPolicyStatus(PolicyStatus policyStatus) {
+		this.policyStatus = policyStatus;
+	}
+
+	@Override
     public int hashCode() {
         return new HashCodeBuilder().
                 append(name).
@@ -191,6 +200,10 @@ public class PolicyDefinition implements Serializable{
             return String.format("{type=\"%s\",value=\"%s\"",type,value);
         }
     }
+    
+    public static enum PolicyStatus {
+    	ENABLED, DISABLED
+    }
 
     @Override
     public String toString() {

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/17670aca/eagle-core/eagle-alert-parent/eagle-alert/alert-coordinator/src/main/java/org/apache/eagle/alert/coordinator/provider/ScheduleContextBuilder.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-coordinator/src/main/java/org/apache/eagle/alert/coordinator/provider/ScheduleContextBuilder.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-coordinator/src/main/java/org/apache/eagle/alert/coordinator/provider/ScheduleContextBuilder.java
index fd09462..9013f04 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-coordinator/src/main/java/org/apache/eagle/alert/coordinator/provider/ScheduleContextBuilder.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-coordinator/src/main/java/org/apache/eagle/alert/coordinator/provider/ScheduleContextBuilder.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata;
 import org.apache.eagle.alert.coordination.model.ScheduleState;
@@ -38,6 +39,7 @@ import org.apache.eagle.alert.coordinator.model.AlertBoltUsage;
 import org.apache.eagle.alert.coordinator.model.GroupBoltUsage;
 import org.apache.eagle.alert.coordinator.model.TopologyUsage;
 import org.apache.eagle.alert.engine.coordinator.PolicyDefinition;
+import org.apache.eagle.alert.engine.coordinator.PolicyDefinition.PolicyStatus;
 import org.apache.eagle.alert.engine.coordinator.Publishment;
 import org.apache.eagle.alert.engine.coordinator.StreamDefinition;
 import org.apache.eagle.alert.service.IMetadataServiceClient;
@@ -86,10 +88,12 @@ public class ScheduleContextBuilder {
     public IScheduleContext buildContext() {
         topologies = listToMap(client.listTopologies());
         kafkaSources = listToMap(client.listDataSources());
-        policies = listToMap(client.listPolicies());
+        // filter out disabled policies
+        policies = listToMap(client.listPolicies().stream().filter(
+        		(t) -> t.getPolicyStatus() != PolicyStatus.DISABLED).collect(Collectors.toList()));
         publishments = listToMap(client.listPublishment());
         streamDefinitions = listToMap(client.listStreams());
-
+        
         // TODO: See ScheduleState comments on how to improve the storage
         ScheduleState state = client.getVersionedSpec();
 

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/17670aca/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/simple/policies.json
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/simple/policies.json
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/simple/policies.json
index 5edece9..c214f2c 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/simple/policies.json
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/simple/policies.json
@@ -50,5 +50,32 @@
 			}
 		}
 	]
+},
+{
+	"name": "perfmon_cpu_pool_check_2",
+	"description" : "policy to check pool perfmon_cpu",
+	"inputStreams": [
+		"perfmon_cpu_stream"
+	],
+	"outputStreams": [
+		"perfmon_cpu_check_output_2"
+	],
+	"definition": {
+		"type": "siddhi",
+		"value": "from perfmon_cpu_stream[value > 90.0] select * group by pool insert into perfmon_cpu_check_output_2;"
+	},
+	"partitionSpec": [
+		{
+			"streamId" : "perfmon_cpu_stream",
+			"type" : "GROUPBY",
+			"columns" : [
+				"pool"
+			],
+			"sortSpec": {
+				"windowPeriod" : "PT1M"
+			}
+		}
+	],
+	"policyStatus": "DISABLED"
 }
 ]
\ No newline at end of file


Mime
View raw message