geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [22/49] geode git commit: GEODE-2576: delete the zip file on locator after it's being streamed to client.
Date Fri, 17 Mar 2017 20:10:57 GMT
GEODE-2576: delete the zip file on locator after it's being streamed to client.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/a4b32303
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/a4b32303
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/a4b32303

Branch: refs/heads/feature/GEODE-2420
Commit: a4b3230325cddf8ea431f5d2dbf249e475c0ddae
Parents: f4f9b6b
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Wed Mar 8 16:41:34 2017 -0800
Committer: Ken Howe <khowe@pivotal.io>
Committed: Fri Mar 17 13:09:44 2017 -0700

----------------------------------------------------------------------
 .../web/controllers/ExportLogController.java    |  6 ++++-
 .../ExportLogsFunctionIntegrationTest.java      |  8 ++-----
 .../commands/ExportLogsOverHttpDUnitTest.java   |  5 ++++
 .../commands/QueryNamesOverHttpDUnitTest.java   | 24 ++++++++------------
 4 files changed, 21 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/a4b32303/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
index f3a5934..0351573 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ExportLogController.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.management.internal.web.controllers;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -91,11 +92,14 @@ public class ExportLogController extends AbstractCommandsController {
     String filePath = ResultBuilder.fromJson(result).nextLine().trim();
 
     HttpHeaders respHeaders = new HttpHeaders();
+    File zipFile = new File(filePath);
     try {
-      InputStreamResource isr = new InputStreamResource(new FileInputStream(new File(filePath)));
+      InputStreamResource isr = new InputStreamResource(new FileInputStream(zipFile));
       return new ResponseEntity<InputStreamResource>(isr, respHeaders, HttpStatus.OK);
     } catch (Exception ex) {
       throw new RuntimeException("IOError writing file to output stream", ex);
+    } finally {
+      FileUtils.deleteQuietly(zipFile);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a4b32303/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
index 72c39dc..cdc5766 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -25,7 +25,6 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.execute.FunctionContextImpl;
-import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.logging.log4j.Level;
@@ -41,15 +40,12 @@ import java.io.IOException;
 public class ExportLogsFunctionIntegrationTest {
 
   @Rule
-  public ServerStarterRule serverStarterRule = new ServerStarterRule();
-
-  private Server server;
+  public ServerStarterRule serverStarterRule = new ServerStarterRule().startServer();
   private File serverWorkingDir;
 
   @Before
   public void setup() throws Exception {
-    server = serverStarterRule.startServer();
-    serverWorkingDir = server.getWorkingDir();
+    serverWorkingDir = serverStarterRule.getWorkingDir();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/a4b32303/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
index 8c9442a..cc4ae28 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDUnitTest.java
@@ -25,6 +25,7 @@ import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
 import java.io.File;
+import java.util.Arrays;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
@@ -58,6 +59,10 @@ public class ExportLogsOverHttpDUnitTest extends ExportStatsDUnitTest {
         new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
 
     assertThat(actualZipEntries).isEqualTo(expectedZipEntries);
+
+    // also verify that the zip file on locator is deleted
+    assertThat(Arrays.stream(locator.getWorkingDir().listFiles())
+        .filter(file -> file.getName().endsWith(".zip")).collect(Collectors.toSet())).isEmpty();
   }
 
   protected String getZipPathFromCommandResult(String message) {

http://git-wip-us.apache.org/repos/asf/geode/blob/a4b32303/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
index 4ec9c0d..22ca6e3 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
@@ -29,7 +29,6 @@ import org.apache.geode.management.internal.web.http.HttpMethod;
 import org.apache.geode.management.internal.web.shell.RestHttpOperationInvoker;
 import org.apache.geode.test.dunit.rules.LocatorStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -48,21 +47,16 @@ public class QueryNamesOverHttpDUnitTest {
   protected static int jmxPort = ports[0];
   protected static int httpPort = ports[1];
 
-  @Rule
-  public LocatorStarterRule locatorRule = new LocatorStarterRule();
-
-  @Before
-  public void before() throws Exception {
-    Properties locatorProps = new Properties() {
-      {
-        setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-        setProperty(HTTP_SERVICE_PORT, httpPort + "");
-        setProperty(JMX_MANAGER_PORT, jmxPort + "");
-      }
-    };
-    locatorRule.startLocator(locatorProps);
-  }
+  protected static Properties locatorProps = new Properties() {
+    {
+      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+      setProperty(HTTP_SERVICE_PORT, httpPort + "");
+      setProperty(JMX_MANAGER_PORT, jmxPort + "");
+    }
+  };
 
+  @Rule
+  public LocatorStarterRule locatorRule = new LocatorStarterRule().startLocator(locatorProps);
 
   @Test
   public void testQueryNameOverHttp() throws Exception {


Mime
View raw message