You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2016/03/17 04:03:08 UTC
[3/4] incubator-eagle git commit: Implement
SiddhiPolicyExceptionHandler for handling exceptions
Implement SiddhiPolicyExceptionHandler for handling exceptions
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/16ae0c31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/16ae0c31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/16ae0c31
Branch: refs/heads/master
Commit: 16ae0c316bb84c290abbdfee8376637132f7bb62
Parents: 267a8d3
Author: Hao Chen <ha...@apache.org>
Authored: Sun Mar 13 13:34:22 2016 +0800
Committer: Hao Chen <ha...@apache.org>
Committed: Sun Mar 13 13:34:22 2016 +0800
----------------------------------------------------------------------
.../policy/siddhi/SiddhiPolicyEvaluator.java | 22 +++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/16ae0c31/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java
index 1929b16..c289d08 100644
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java
+++ b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/siddhi/SiddhiPolicyEvaluator.java
@@ -16,6 +16,8 @@
*/
package org.apache.eagle.policy.siddhi;
+import com.lmax.disruptor.ExceptionHandler;
+import com.lmax.disruptor.FatalExceptionHandler;
import com.typesafe.config.Config;
import org.apache.eagle.alert.entity.AbstractPolicyDefinitionEntity;
import org.apache.eagle.alert.entity.AlertStreamSchemaEntity;
@@ -37,6 +39,7 @@ import org.wso2.siddhi.query.api.execution.query.Query;
import org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute;
import org.wso2.siddhi.query.compiler.exception.SiddhiParserException;
+import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.*;
@@ -130,6 +133,7 @@ public class SiddhiPolicyEvaluator<T extends AbstractPolicyDefinitionEntity, K>
try {
executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
+ executionPlanRuntime.handleExceptionWith(new SiddhiPolicyExceptionHandler());
for (String sourceStream : sourceStreams) {
siddhiInputHandlers.put(sourceStream, executionPlanRuntime.getInputHandler(sourceStream));
@@ -312,4 +316,20 @@ public class SiddhiPolicyEvaluator<T extends AbstractPolicyDefinitionEntity, K>
@Override
public String getMarkdownReason() { return siddhiRuntime.markdownReason; }
-}
+
+ private static class SiddhiPolicyExceptionHandler implements Serializable, ExceptionHandler<Object> {
+ private final static Logger LOG = LoggerFactory.getLogger(SiddhiPolicyExceptionHandler.class);
+
+ public void handleEventException(Throwable ex, long sequence, Object event) {
+ LOG.warn("Exception processing event: " + sequence + " " + event, ex);
+ }
+
+ public void handleOnStartException(Throwable ex) {
+ LOG.warn("Exception during onStart()", ex);
+ }
+
+ public void handleOnShutdownException(Throwable ex) {
+ LOG.warn("Exception during onShutdown()", ex);
+ }
+ }
+}
\ No newline at end of file