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 25BEC200C59 for ; Mon, 17 Apr 2017 14:42:28 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 245AA160BAB; Mon, 17 Apr 2017 12:42:28 +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 6BEFE160B9C for ; Mon, 17 Apr 2017 14:42:27 +0200 (CEST) Received: (qmail 3505 invoked by uid 500); 17 Apr 2017 12:42:26 -0000 Mailing-List: contact commits-help@eagle.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@eagle.apache.org Delivered-To: mailing list commits@eagle.apache.org Received: (qmail 3496 invoked by uid 99); 17 Apr 2017 12:42:26 -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; Mon, 17 Apr 2017 12:42:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 74A89DFFD7; Mon, 17 Apr 2017 12:42:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: qingwzhao@apache.org To: commits@eagle.apache.org Message-Id: <581beee14fc04f258a31ce364125a351@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: eagle git commit: [EAGLE-1007] Fix memory leak in ExecutionRuntimeManager Date: Mon, 17 Apr 2017 12:42:26 +0000 (UTC) archived-at: Mon, 17 Apr 2017 12:42:28 -0000 Repository: eagle Updated Branches: refs/heads/master d20f2e116 -> fc7281d71 [EAGLE-1007] Fix memory leak in ExecutionRuntimeManager https://issues.apache.org/jira/browse/EAGLE-1007 Author: Zhao, Qingwen Closes #917 from qingwen220/EAGLE-1007. Project: http://git-wip-us.apache.org/repos/asf/eagle/repo Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/fc7281d7 Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/fc7281d7 Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/fc7281d7 Branch: refs/heads/master Commit: fc7281d715f57f2f911079d24f5c09b1f79c50cf Parents: d20f2e1 Author: Zhao, Qingwen Authored: Mon Apr 17 20:42:16 2017 +0800 Committer: Zhao, Qingwen Committed: Mon Apr 17 20:42:16 2017 +0800 ---------------------------------------------------------------------- .../app/environment/AbstractEnvironment.java | 10 +++++ .../ExecutionRuntimeManagerTest.java | 45 ++++++++++++++++++++ 2 files changed, 55 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/eagle/blob/fc7281d7/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/AbstractEnvironment.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/AbstractEnvironment.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/AbstractEnvironment.java index ec2ffe1..5e3a38b 100644 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/AbstractEnvironment.java +++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/environment/AbstractEnvironment.java @@ -62,6 +62,16 @@ public abstract class AbstractEnvironment implements Environment { .append(this.config()).build(); } + @Override + public boolean equals(Object obj) { + if (obj instanceof AbstractEnvironment) { + Environment environment = (Environment) obj; + return this.getClass().equals(obj.getClass()) + && this.config.equals(environment.config()); + } + return false; + } + public StreamProvider stream() { return streamProvider; } http://git-wip-us.apache.org/repos/asf/eagle/blob/fc7281d7/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/ExecutionRuntimeManagerTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/ExecutionRuntimeManagerTest.java b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/ExecutionRuntimeManagerTest.java new file mode 100644 index 0000000..eacda9f --- /dev/null +++ b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/environment/ExecutionRuntimeManagerTest.java @@ -0,0 +1,45 @@ +/* + * 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.app.environment; + +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import org.apache.eagle.app.environment.impl.StormEnvironment; +import org.junit.Assert; +import org.junit.Test; + +import java.lang.reflect.Field; +import java.util.Map; + +public class ExecutionRuntimeManagerTest { + + @Test + public void test() throws NoSuchFieldException, IllegalAccessException { + Config config = ConfigFactory.load(); + ExecutionRuntimeManager manager = ExecutionRuntimeManager.getInstance(); + manager.getRuntime(StormEnvironment.class, config); + manager.getRuntime(StormEnvironment.class, config); + + Field field = manager.getClass().getDeclaredField("executionRuntimeCache"); + field.setAccessible(true); + Map executionRuntimeCache = (Map) field.get(manager); + + Assert.assertTrue(executionRuntimeCache.size() == 1); + + } +}