eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qingwz...@apache.org
Subject eagle git commit: [EAGLE-1007] Fix memory leak in ExecutionRuntimeManager
Date Mon, 17 Apr 2017 12:42:26 GMT
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 <qingwzhao@apache.org>

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 <qingwzhao@apache.org>
Authored: Mon Apr 17 20:42:16 2017 +0800
Committer: Zhao, Qingwen <qingwzhao@apache.org>
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<Environment, ExecutionRuntime> executionRuntimeCache = (Map<Environment,
ExecutionRuntime>) field.get(manager);
+
+        Assert.assertTrue(executionRuntimeCache.size() == 1);
+
+    }
+}


Mime
View raw message