Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 57299200B65 for ; Wed, 17 Aug 2016 10:43:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 55B6E160A8C; Wed, 17 Aug 2016 08:43:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 74D1F160A86 for ; Wed, 17 Aug 2016 10:43:46 +0200 (CEST) Received: (qmail 65957 invoked by uid 500); 17 Aug 2016 08:43:45 -0000 Mailing-List: contact commits-help@eagle.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@eagle.incubator.apache.org Delivered-To: mailing list commits@eagle.incubator.apache.org Received: (qmail 65948 invoked by uid 99); 17 Aug 2016 08:43:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2016 08:43:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 43C28180565 for ; Wed, 17 Aug 2016 08:43:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id alzRImxy7YRP for ; Wed, 17 Aug 2016 08:43:43 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 546C95FBBE for ; Wed, 17 Aug 2016 08:43:42 +0000 (UTC) Received: (qmail 65924 invoked by uid 99); 17 Aug 2016 08:43:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2016 08:43:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 42EFFE02D4; Wed, 17 Aug 2016 08:43:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ralphsu@apache.org To: commits@eagle.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-eagle git commit: EAGLE-471: fix AlertBolt introduce un-serializble member Date: Wed, 17 Aug 2016 08:43:41 +0000 (UTC) archived-at: Wed, 17 Aug 2016 08:43:47 -0000 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 Authored: Wed Aug 17 13:51:08 2016 +0800 Committer: Ralph, Su 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 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()); + + } +}