refactor for testability

Extract inner Interceptor class from ExportLogsCommand


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

Branch: refs/heads/feature/GEODE-2420
Commit: 99ebe3fc5adffe912ff7619da7c7667cc16f925d
Parents: 73fb726
Author: Ken Howe <kh...@pivotal.io>
Authored: Fri Mar 17 12:59:59 2017 -0700
Committer: Ken Howe <kh...@pivotal.io>
Committed: Mon Mar 27 14:21:59 2017 -0700

----------------------------------------------------------------------
 .../internal/cli/commands/ExportLogsCommand.java     | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/99ebe3fc/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
index 6ffe58f..d6da5e4 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
@@ -102,7 +102,13 @@ public class ExportLogsCommand implements CommandMarker {
           specifiedDefaultValue = 
CliStrings.EXPORT_LOGS__FILESIZELIMIT__SPECIFIED_DEFAULT,
           help = CliStrings.EXPORT_LOGS__FILESIZELIMIT__HELP) String 
fileSizeLimit) {
     Result result = null;
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    GemFireCacheImpl cache = this.cache;
+    if (cache == null || cache.isClosed()) {
+      new Exception("KEN: cache is null").printStackTrace();
+      cache = GemFireCacheImpl.getInstance();
+    } else {
+      new Exception("KEN: cache has been created").printStackTrace();
+    }
     try {
       Set<DistributedMember> targetMembers =
           CliUtil.findMembersIncludingLocators(groups, memberIds);
@@ -214,11 +220,8 @@ public class ExportLogsCommand implements CommandMarker {
       return 0;
     }
 
-      // validate log level
-      String logLevel = arguments.get("log-level");
-      if (StringUtils.isBlank(logLevel) || LogLevel.getLevel(logLevel) == 
null) {
-        return ResultBuilder.createUserErrorResult("Invalid log level: " + 
logLevel);
-      }
+    int sizeLimit = parseSize(fileSizeLimit);
+    int byteMultiplier = parseByteMultiplier(fileSizeLimit);
 
     return sizeLimit * byteMultiplier;
   }

Reply via email to