You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ra...@apache.org on 2016/08/17 08:43:41 UTC
incubator-eagle git commit: EAGLE-471: fix AlertBolt introduce
un-serializble member
Repository: incubator-eagle
Updated Branches:
refs/heads/develop e383e8796 -> 2cd17cbfa
EAGLE-471: fix AlertBolt introduce un-serializble member
Author: Zeng,Bryant
Reviewer: Su, Ralph(ralphsu)
This closes #355
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/2cd17cbf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/2cd17cbf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/2cd17cbf
Branch: refs/heads/develop
Commit: 2cd17cbfa2a5788e9514a441c90d0e7076ca17ba
Parents: e383e87
Author: mizeng <mi...@ebaysf.com>
Authored: Wed Aug 17 13:51:08 2016 +0800
Committer: Ralph, Su <su...@gmail.com>
Committed: Wed Aug 17 16:41:15 2016 +0800
----------------------------------------------------------------------
.../eagle/alert/engine/runner/AlertBolt.java | 10 ++---
.../alert/engine/utils/SingletonExecutor.java | 44 ++++++++++++++++++++
2 files changed, 47 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2cd17cbf/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/runner/AlertBolt.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/runner/AlertBolt.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/runner/AlertBolt.java
index 9cfb59a..f653c9c 100755
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/runner/AlertBolt.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/runner/AlertBolt.java
@@ -39,6 +39,7 @@ import org.apache.eagle.alert.engine.evaluator.impl.PolicyGroupEvaluatorImpl;
import org.apache.eagle.alert.engine.model.PartitionedEvent;
import org.apache.eagle.alert.engine.router.AlertBoltSpecListener;
import org.apache.eagle.alert.engine.serialization.SerializationMetadataProvider;
+import org.apache.eagle.alert.engine.utils.SingletonExecutor;
import org.apache.eagle.alert.metric.MetricSystem;
import org.apache.eagle.alert.metric.source.MetricSource;
import org.apache.eagle.alert.service.IMetadataServiceClient;
@@ -50,8 +51,7 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.*;
/**
* Since 5/1/16.
@@ -70,7 +70,6 @@ public class AlertBolt extends AbstractStreamBolt implements AlertBoltSpecListen
private volatile Map<String, PolicyDefinition> cachedPolicies = new HashMap<>(); // for one streamGroup, there are multiple policies
private AlertBoltSpec spec;
-
public AlertBolt(String boltId, Config config, IMetadataChangeNotifyService changeNotifyService){
super(boltId, changeNotifyService, config);
this.boltId = boltId;
@@ -100,8 +99,6 @@ public class AlertBolt extends AbstractStreamBolt implements AlertBoltSpecListen
}
}
- private ExecutorService executors = Executors.newFixedThreadPool(5);
-
@Override
public void execute(Tuple input) {
this.streamContext.counter().scope("execute_count").incr();
@@ -133,6 +130,7 @@ public class AlertBolt extends AbstractStreamBolt implements AlertBoltSpecListen
system.report();
system.stop();
+ ExecutorService executors = SingletonExecutor.getExecutorService();
executors.submit(() -> {
// if spec version is out-of-date, need to refresh it
if (specVersionOutofdate){
@@ -212,8 +210,6 @@ public class AlertBolt extends AbstractStreamBolt implements AlertBoltSpecListen
sdf = sds;
specVersion = spec.getVersion();
this.spec = spec;
-
-
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2cd17cbf/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java
new file mode 100644
index 0000000..fdb9ed8
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * * 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.engine.utils;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class SingletonExecutor {
+
+ public static synchronized ExecutorService getExecutorService() {
+ return executorService;
+ }
+
+ private static ExecutorService executorService;
+
+ private static SingletonExecutor executor = new SingletonExecutor();
+
+ public SingletonExecutor() {
+ executorService = Executors.newFixedThreadPool(5);
+ }
+
+ public static void main(String[] args) {
+ System.out.println(SingletonExecutor.getExecutorService());
+ System.out.println(SingletonExecutor.getExecutorService());
+
+ }
+}