geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [21/25] geode git commit: GEODE-3436: Restore refactoring of DiskStoreCommands
Date Tue, 29 Aug 2017 16:30:38 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
new file mode 100644
index 0000000..eb2b544
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
@@ -0,0 +1,149 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.shell.core.annotation.CliCommand;
+
+import org.apache.geode.SystemFailure;
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.FunctionInvocationTargetException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.execute.AbstractExecution;
+import org.apache.geode.internal.cache.partitioned.ColocatedRegionDetails;
+import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.functions.ShowMissingDiskStoresFunction;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CompositeResultData;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.result.ResultDataException;
+import org.apache.geode.management.internal.cli.result.TabularResultData;
+import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.ResourcePermission;
+
+public class ShowMissingDiskStoreCommand implements GfshCommand {
+  @CliCommand(value = CliStrings.SHOW_MISSING_DISK_STORE,
+      help = CliStrings.SHOW_MISSING_DISK_STORE__HELP)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER,
+      operation = ResourcePermission.Operation.READ)
+  public Result showMissingDiskStore() {
+
+    try {
+      Set<DistributedMember> dataMembers = DiskStoreCommandsUtils.getNormalMembers(getCache());
+
+      if (dataMembers.isEmpty()) {
+        return ResultBuilder.createInfoResult(CliStrings.NO_CACHING_MEMBERS_FOUND_MESSAGE);
+      }
+      List<Object> results = getMissingDiskStoresList(dataMembers);
+      return toMissingDiskStoresTabularResult(results);
+    } catch (FunctionInvocationTargetException ignore) {
+      return ResultBuilder.createGemFireErrorResult(CliStrings.format(
+          CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, CliStrings.SHOW_MISSING_DISK_STORE));
+    } catch (VirtualMachineError e) {
+      SystemFailure.initiateFailure(e);
+      throw e;
+    } catch (Throwable t) {
+      SystemFailure.checkFailure();
+      if (t.getMessage() == null) {
+        return ResultBuilder.createGemFireErrorResult(
+            String.format(CliStrings.SHOW_MISSING_DISK_STORE__ERROR_MESSAGE, t));
+      }
+      return ResultBuilder.createGemFireErrorResult(
+          String.format(CliStrings.SHOW_MISSING_DISK_STORE__ERROR_MESSAGE, t.getMessage()));
+    }
+  }
+
+  private List<Object> getMissingDiskStoresList(Set<DistributedMember> members)
{
+    final Execution membersFunctionExecutor = getMembersFunctionExecutor(members);
+    if (membersFunctionExecutor instanceof AbstractExecution) {
+      ((AbstractExecution) membersFunctionExecutor).setIgnoreDepartedMembers(true);
+    }
+
+    final ResultCollector<?, ?> resultCollector =
+        membersFunctionExecutor.execute(new ShowMissingDiskStoresFunction());
+
+    final List<?> results = (List<?>) resultCollector.getResult();
+    final List<Object> distributedPersistentRecoveryDetails = new ArrayList<>(results.size());
+    for (final Object result : results) {
+      if (result instanceof Set) {
+        distributedPersistentRecoveryDetails.addAll((Set<Object>) result);
+      }
+    }
+    return distributedPersistentRecoveryDetails;
+  }
+
+  private Result toMissingDiskStoresTabularResult(final List<Object> resultDetails)
+      throws ResultDataException {
+    CompositeResultData crd = ResultBuilder.createCompositeResultData();
+    List<PersistentMemberPattern> missingDiskStores = new ArrayList<>();
+    List<ColocatedRegionDetails> missingColocatedRegions = new ArrayList<>();
+
+    for (Object detail : resultDetails) {
+      if (detail instanceof PersistentMemberPattern) {
+        missingDiskStores.add((PersistentMemberPattern) detail);
+      } else if (detail instanceof ColocatedRegionDetails) {
+        missingColocatedRegions.add((ColocatedRegionDetails) detail);
+      } else {
+        throw new ResultDataException("Unknown type of PersistentRecoveryFailures result");
+      }
+    }
+
+    boolean hasMissingDiskStores = !missingDiskStores.isEmpty();
+    boolean hasMissingColocatedRegions = !missingColocatedRegions.isEmpty();
+    if (hasMissingDiskStores) {
+      CompositeResultData.SectionResultData missingDiskStoresSection = crd.addSection();
+      missingDiskStoresSection.setHeader("Missing Disk Stores");
+      TabularResultData missingDiskStoreData = missingDiskStoresSection.addTable();
+
+      for (PersistentMemberPattern persistentMemberDetails : missingDiskStores) {
+        missingDiskStoreData.accumulate("Disk Store ID", persistentMemberDetails.getUUID());
+        missingDiskStoreData.accumulate("Host", persistentMemberDetails.getHost());
+        missingDiskStoreData.accumulate("Directory", persistentMemberDetails.getDirectory());
+      }
+    } else {
+      CompositeResultData.SectionResultData noMissingDiskStores = crd.addSection();
+      noMissingDiskStores.setHeader("No missing disk store found");
+    }
+    if (hasMissingDiskStores || hasMissingColocatedRegions) {
+      // For clarity, separate disk store and colocated region information
+      crd.addSection().setHeader("\n");
+    }
+
+    if (hasMissingColocatedRegions) {
+      CompositeResultData.SectionResultData missingRegionsSection = crd.addSection();
+      missingRegionsSection.setHeader("Missing Colocated Regions");
+      TabularResultData missingRegionData = missingRegionsSection.addTable();
+
+      for (ColocatedRegionDetails colocatedRegionDetails : missingColocatedRegions) {
+        missingRegionData.accumulate("Host", colocatedRegionDetails.getHost());
+        missingRegionData.accumulate("Distributed Member", colocatedRegionDetails.getMember());
+        missingRegionData.accumulate("Parent Region", colocatedRegionDetails.getParent());
+        missingRegionData.accumulate("Missing Colocated Region", colocatedRegionDetails.getChild());
+      }
+    } else {
+      CompositeResultData.SectionResultData noMissingColocatedRegions = crd.addSection();
+      noMissingColocatedRegions.setHeader("No missing colocated region found");
+    }
+    return ResultBuilder.buildResult(crd);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/UpgradeOfflineDiskStoreCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/UpgradeOfflineDiskStoreCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/UpgradeOfflineDiskStoreCommand.java
new file mode 100644
index 0000000..85b86db
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/UpgradeOfflineDiskStoreCommand.java
@@ -0,0 +1,177 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.GemFireIOException;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.CliUtil;
+import org.apache.geode.management.internal.cli.GfshParser;
+import org.apache.geode.management.internal.cli.LogWrapper;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+import org.apache.geode.management.internal.cli.util.DiskStoreUpgrader;
+
+public class UpgradeOfflineDiskStoreCommand implements GfshCommand {
+  @CliCommand(value = CliStrings.UPGRADE_OFFLINE_DISK_STORE,
+      help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__HELP)
+  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  public Result upgradeOfflineDiskStore(
+      @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__NAME, mandatory = true,
+          help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__NAME__HELP) String diskStoreName,
+      @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__DISKDIRS, mandatory = true,
+          help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__DISKDIRS__HELP) String[] diskDirs,
+      @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__MAXOPLOGSIZE,
+          unspecifiedDefaultValue = "-1",
+          help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__MAXOPLOGSIZE__HELP) long maxOplogSize,
+      @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__J,
+          help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__J__HELP) String[] jvmProps)
+      throws InterruptedException {
+
+    Result result;
+    LogWrapper logWrapper = LogWrapper.getInstance();
+
+    StringBuilder output = new StringBuilder();
+    StringBuilder error = new StringBuilder();
+    StringBuilder errorMessage = new StringBuilder();
+    Process upgraderProcess = null;
+
+    try {
+      String validatedDirectories = DiskStoreCommandsUtils.validatedDirectories(diskDirs);
+      if (validatedDirectories != null) {
+        throw new IllegalArgumentException(
+            "Could not find " + CliStrings.UPGRADE_OFFLINE_DISK_STORE__DISKDIRS + ": \""
+                + validatedDirectories + "\"");
+      }
+
+      List<String> commandList = new ArrayList<>();
+      commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
+          + File.separatorChar + "java");
+
+      DiskStoreCommandsUtils.configureLogging(commandList);
+
+      if (jvmProps != null && jvmProps.length != 0) {
+        commandList.addAll(Arrays.asList(jvmProps));
+      }
+      commandList.add("-classpath");
+      commandList.add(System.getProperty("java.class.path", "."));
+      commandList.add(DiskStoreUpgrader.class.getName());
+
+      commandList.add(CliStrings.UPGRADE_OFFLINE_DISK_STORE__NAME + "=" + diskStoreName);
+
+      if (diskDirs != null && diskDirs.length != 0) {
+        StringBuilder builder = new StringBuilder();
+        int arrayLength = diskDirs.length;
+        for (int i = 0; i < arrayLength; i++) {
+          if (File.separatorChar == '\\') {
+            builder.append(diskDirs[i].replace("\\", "/")); // see 46120
+          } else {
+            builder.append(diskDirs[i]);
+          }
+          if (i + 1 != arrayLength) {
+            builder.append(',');
+          }
+        }
+        commandList.add(CliStrings.UPGRADE_OFFLINE_DISK_STORE__DISKDIRS + "=" + builder.toString());
+      }
+      // -1 is ignore as maxOplogSize
+      commandList.add(CliStrings.UPGRADE_OFFLINE_DISK_STORE__MAXOPLOGSIZE + "=" + maxOplogSize);
+
+      ProcessBuilder procBuilder = new ProcessBuilder(commandList);
+      // procBuilder.redirectErrorStream(true);
+      upgraderProcess = procBuilder.start();
+      InputStream inputStream = upgraderProcess.getInputStream();
+      InputStream errorStream = upgraderProcess.getErrorStream();
+      BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream));
+      BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream));
+
+      String line;
+      while ((line = inputReader.readLine()) != null) {
+        output.append(line).append(GfshParser.LINE_SEPARATOR);
+      }
+
+      boolean switchToStackTrace = false;
+      while ((line = errorReader.readLine()) != null) {
+        if (!switchToStackTrace && DiskStoreUpgrader.STACKTRACE_START.equals(line))
{
+          switchToStackTrace = true;
+        } else if (switchToStackTrace) {
+          error.append(line).append(GfshParser.LINE_SEPARATOR);
+        } else {
+          errorMessage.append(line);
+        }
+      }
+
+      if (errorMessage.length() > 0) {
+        throw new GemFireIOException(errorMessage.toString());
+      }
+
+      upgraderProcess.destroy();
+      result = ResultBuilder.createInfoResult(output.toString());
+    } catch (IOException e) {
+      if (output.length() != 0) {
+        Gfsh.println(output.toString());
+      }
+      String fieldsMessage = (maxOplogSize != -1
+          ? CliStrings.UPGRADE_OFFLINE_DISK_STORE__MAXOPLOGSIZE + "=" + maxOplogSize + ","
: "");
+      fieldsMessage += CliUtil.arrayToString(diskDirs);
+      String errorString = CliStrings.format(
+          CliStrings.UPGRADE_OFFLINE_DISK_STORE__MSG__ERROR_WHILE_COMPACTING_DISKSTORE_0_WITH_1_REASON_2,
+          diskStoreName, fieldsMessage);
+      result = ResultBuilder.createUserErrorResult(errorString);
+      if (logWrapper.fineEnabled()) {
+        logWrapper.fine(e.getMessage(), e);
+      }
+    } catch (GemFireIOException e) {
+      if (output.length() != 0) {
+        Gfsh.println(output.toString());
+      }
+      result = ResultBuilder.createUserErrorResult(errorMessage.toString());
+      if (logWrapper.fineEnabled()) {
+        logWrapper.fine(error.toString());
+      }
+    } catch (IllegalArgumentException e) {
+      if (output.length() != 0) {
+        Gfsh.println(output.toString());
+      }
+      result = ResultBuilder.createUserErrorResult(e.getMessage());
+    } finally {
+      if (upgraderProcess != null) {
+        try {
+          // just to check whether the process has exited
+          // Process.exitValue() throws IllegalStateException if Process is alive
+          upgraderProcess.exitValue();
+        } catch (IllegalThreadStateException itse) {
+          // not yet terminated, destroy the process
+          upgraderProcess.destroy();
+        }
+      }
+    }
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ValidateDiskStoreCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ValidateDiskStoreCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ValidateDiskStoreCommand.java
new file mode 100644
index 0000000..029b384
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ValidateDiskStoreCommand.java
@@ -0,0 +1,104 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.GfshParser;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.DiskStoreValidater;
+
+public class ValidateDiskStoreCommand implements GfshCommand {
+  @CliCommand(value = CliStrings.VALIDATE_DISK_STORE, help = CliStrings.VALIDATE_DISK_STORE__HELP)
+  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  public Result validateDiskStore(
+      @CliOption(key = CliStrings.VALIDATE_DISK_STORE__NAME, mandatory = true,
+          help = CliStrings.VALIDATE_DISK_STORE__NAME__HELP) String diskStoreName,
+      @CliOption(key = CliStrings.VALIDATE_DISK_STORE__DISKDIRS, mandatory = true,
+          help = CliStrings.VALIDATE_DISK_STORE__DISKDIRS__HELP) String[] diskDirs,
+      @CliOption(key = CliStrings.VALIDATE_DISK_STORE__J,
+          help = CliStrings.VALIDATE_DISK_STORE__J__HELP) String[] jvmProps) {
+    try {
+      // create a new process ...bug 46075
+      StringBuilder dirList = new StringBuilder();
+      for (String diskDir : diskDirs) {
+        dirList.append(diskDir);
+        dirList.append(";");
+      }
+
+      List<String> commandList = new ArrayList<>();
+      commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
+          + File.separatorChar + "java");
+
+      DiskStoreCommandsUtils.configureLogging(commandList);
+
+      if (jvmProps != null && jvmProps.length != 0) {
+        commandList.addAll(Arrays.asList(jvmProps));
+      }
+
+      // Pass any java options on to the command
+      String opts = System.getenv("JAVA_OPTS");
+      if (opts != null) {
+        commandList.add(opts);
+      }
+      commandList.add("-classpath");
+      commandList.add(System.getProperty("java.class.path", "."));
+      commandList.add(DiskStoreValidater.class.getName());
+      commandList.add(diskStoreName);
+      commandList.add(dirList.toString());
+
+      ProcessBuilder procBuilder = new ProcessBuilder(commandList);
+      StringBuilder output = new StringBuilder();
+      String errorString = "";
+
+      Process validateDiskStoreProcess = procBuilder.redirectErrorStream(true).start();
+      InputStream inputStream = validateDiskStoreProcess.getInputStream();
+      BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+      String line;
+
+      while ((line = br.readLine()) != null) {
+        output.append(line).append(GfshParser.LINE_SEPARATOR);
+      }
+      validateDiskStoreProcess.destroy();
+
+      output.append(errorString).append(GfshParser.LINE_SEPARATOR);
+      String resultString =
+          "Validating " + diskStoreName + GfshParser.LINE_SEPARATOR + output.toString();
+      return ResultBuilder.createInfoResult(resultString);
+    } catch (IOException ex) {
+      return ResultBuilder.createGemFireErrorResult(CliStrings
+          .format(CliStrings.VALIDATE_DISK_STORE__MSG__IO_ERROR, diskStoreName, ex.getMessage()));
+    } catch (Exception ex) {
+      // StringPrintWriter s = new StringPrintWriter();
+      // ex.printStackTrace(s);
+      return ResultBuilder.createGemFireErrorResult(CliStrings
+          .format(CliStrings.VALIDATE_DISK_STORE__MSG__ERROR, diskStoreName, ex.getMessage()));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
index 2e06811..1f646d6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.management.internal.cli.commands.ListDiskStoresCommand;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 
@@ -32,8 +33,21 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
  * The DiskStoreCommandsController class implements GemFire Management REST API web service
  * endpoints for the Gfsh Disk Store Commands.
  * <p/>
- * 
- * @see org.apache.geode.management.internal.cli.commands.DiskStoreCommands
+ *
+ * @see org.apache.geode.management.internal.cli.commands.AlterOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.BackupDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.CompactDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.CompactOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.CreateDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.DescribeDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.DescribeOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.DestroyDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.ExportOfflineDiskStoreCommand
+ * @see ListDiskStoresCommand
+ * @see org.apache.geode.management.internal.cli.commands.RevokeMissingDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.ShowMissingDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.UpgradeOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.ValidateDiskStoreCommand
  * @see org.apache.geode.management.internal.web.controllers.AbstractCommandsController
  * @see org.springframework.stereotype.Controller
  * @see org.springframework.web.bind.annotation.PathVariable

http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
index 07cdb11..1002f5d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
@@ -36,7 +36,23 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DataPolicy;
@@ -76,28 +92,26 @@ import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.WaitCriterion;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
 
 /**
  * The DiskStoreCommandsDUnitTest class is a distributed test suite of test cases for testing
the
  * disk store commands that are part of Gfsh.
  * </p>
  *
- * @see org.apache.geode.management.internal.cli.commands.DiskStoreCommands
+ * @see org.apache.geode.management.internal.cli.commands.AlterOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.BackupDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.CompactDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.CompactOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.CreateDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.DescribeDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.DescribeOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.DestroyDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.ExportOfflineDiskStoreCommand
+ * @see ListDiskStoresCommand
+ * @see org.apache.geode.management.internal.cli.commands.RevokeMissingDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.ShowMissingDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.UpgradeOfflineDiskStoreCommand
+ * @see org.apache.geode.management.internal.cli.commands.ValidateDiskStoreCommand
  * @see org.junit.Assert
  * @see org.junit.Test
  * @since GemFire 7.0

http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsJUnitTest.java
index 1902656..f8cd657 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsJUnitTest.java
@@ -14,7 +14,10 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -49,10 +52,11 @@ import org.apache.geode.test.junit.categories.UnitTest;
 
 /**
  * The DiskStoreCommandsJUnitTest class is a test suite of test cases testing the contract
and
- * functionality of the DiskStoreCommands class implementing commands in the GemFire shell
(gfsh)
- * that access and modify disk stores in GemFire.
+ * functionality of the command classes relating to disk stores that implement commands in
the
+ * GemFire shell (gfsh) that access and modify disk stores in GemFire.
  *
- * @see org.apache.geode.management.internal.cli.commands.DiskStoreCommands
+ * @see org.apache.geode.management.internal.cli.commands.DescribeDiskStoreCommand
+ * @see ListDiskStoresCommand
  * @see org.apache.geode.management.internal.cli.domain.DiskStoreDetails
  * @see org.apache.geode.management.internal.cli.functions.DescribeDiskStoreFunction
  * @see org.apache.geode.management.internal.cli.functions.ListDiskStoresFunction
@@ -61,6 +65,7 @@ import org.apache.geode.test.junit.categories.UnitTest;
  * @see org.jmock.lib.legacy.ClassImposteriser
  * @see org.junit.Assert
  * @see org.junit.Test
+ *
  * @since GemFire 7.0
  */
 @Category(UnitTest.class)
@@ -84,9 +89,14 @@ public class DiskStoreCommandsJUnitTest {
     mockContext = null;
   }
 
-  private DiskStoreCommands createDiskStoreCommands(final InternalCache cache,
+  private DescribeDiskStoreCommand createDescribeDiskStoreCommand(final InternalCache cache,
+      final DistributedMember distributedMember, final Execution functionExecutor) {
+    return new TestDescribeDiskStoreCommand(cache, distributedMember, functionExecutor);
+  }
+
+  private ListDiskStoresCommand createListDiskStoreCommand(final InternalCache cache,
       final DistributedMember distributedMember, final Execution functionExecutor) {
-    return new TestDiskStoreCommands(cache, distributedMember, functionExecutor);
+    return new TestListDiskStoresCommand(cache, distributedMember, functionExecutor);
   }
 
   private DiskStoreDetails createDiskStoreDetails(final String memberId,
@@ -123,15 +133,15 @@ public class DiskStoreCommandsJUnitTest {
         oneOf(mockFunctionExecutor).execute(with(aNonNull(DescribeDiskStoreFunction.class)));
         will(returnValue(mockResultCollector));
         oneOf(mockResultCollector).getResult();
-        will(returnValue(Arrays.asList(expectedDiskStoredDetails)));
+        will(returnValue(Collections.singletonList(expectedDiskStoredDetails)));
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockMember, mockFunctionExecutor);
+    final DescribeDiskStoreCommand describeCommand =
+        createDescribeDiskStoreCommand(mockCache, mockMember, mockFunctionExecutor);
 
     final DiskStoreDetails actualDiskStoreDetails =
-        commands.getDiskStoreDescription(memberId, diskStoreName);
+        describeCommand.getDiskStoreDescription(memberId, diskStoreName);
 
     assertNotNull(actualDiskStoreDetails);
     assertEquals(expectedDiskStoredDetails, actualDiskStoreDetails);
@@ -156,10 +166,11 @@ public class DiskStoreCommandsJUnitTest {
       }
     });
 
-    final DiskStoreCommands commands = createDiskStoreCommands(mockCache, mockMember, null);
+    final DescribeDiskStoreCommand describeCommand =
+        createDescribeDiskStoreCommand(mockCache, mockMember, null);
 
     try {
-      commands.getDiskStoreDescription(memberId, diskStoreName);
+      describeCommand.getDiskStoreDescription(memberId, diskStoreName);
     } catch (MemberNotFoundException expected) {
       assertEquals(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, memberId),
           expected.getMessage());
@@ -192,11 +203,11 @@ public class DiskStoreCommandsJUnitTest {
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockMember, mockFunctionExecutor);
+    final DescribeDiskStoreCommand describeCommand =
+        createDescribeDiskStoreCommand(mockCache, mockMember, mockFunctionExecutor);
 
     try {
-      commands.getDiskStoreDescription(memberId, diskStoreName);
+      describeCommand.getDiskStoreDescription(memberId, diskStoreName);
     } catch (DiskStoreNotFoundException expected) {
       assertEquals("expected", expected.getMessage());
       throw expected;
@@ -228,11 +239,11 @@ public class DiskStoreCommandsJUnitTest {
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockMember, mockFunctionExecutor);
+    final DescribeDiskStoreCommand describeCommand =
+        createDescribeDiskStoreCommand(mockCache, mockMember, mockFunctionExecutor);
 
     try {
-      commands.getDiskStoreDescription(memberId, diskStoreName);
+      describeCommand.getDiskStoreDescription(memberId, diskStoreName);
     } catch (RuntimeException expected) {
       assertEquals("expected", expected.getMessage());
       throw expected;
@@ -265,15 +276,15 @@ public class DiskStoreCommandsJUnitTest {
         oneOf(mockFunctionExecutor).execute(with(aNonNull(DescribeDiskStoreFunction.class)));
         will(returnValue(mockResultCollector));
         oneOf(mockResultCollector).getResult();
-        will(returnValue(Arrays.asList(new Object())));
+        will(returnValue(Collections.singletonList(new Object())));
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockMember, mockFunctionExecutor);
+    final DescribeDiskStoreCommand describeCommand =
+        createDescribeDiskStoreCommand(mockCache, mockMember, mockFunctionExecutor);
 
     try {
-      commands.getDiskStoreDescription(memberId, diskStoreName);
+      describeCommand.getDiskStoreDescription(memberId, diskStoreName);
     } catch (RuntimeException expected) {
       assertEquals(
           CliStrings.format(CliStrings.UNEXPECTED_RETURN_TYPE_EXECUTING_COMMAND_ERROR_MESSAGE,
@@ -308,7 +319,7 @@ public class DiskStoreCommandsJUnitTest {
     final List<DiskStoreDetails> expectedDiskStores =
         Arrays.asList(diskStoreDetails1, diskStoreDetails2, diskStoreDetails3, diskStoreDetails4);
 
-    final List<Set<DiskStoreDetails>> results = new ArrayList<Set<DiskStoreDetails>>();
+    final List<Set<DiskStoreDetails>> results = new ArrayList<>();
 
     results.add(CollectionUtils.asSet(diskStoreDetails4, diskStoreDetails3));
     results.add(CollectionUtils.asSet(diskStoreDetails1, diskStoreDetails2));
@@ -323,11 +334,11 @@ public class DiskStoreCommandsJUnitTest {
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockDistributedMember, mockFunctionExecutor);
+    final ListDiskStoresCommand listCommand =
+        createListDiskStoreCommand(mockCache, mockDistributedMember, mockFunctionExecutor);
 
     final List<DiskStoreDetails> actualDiskStores =
-        commands.getDiskStoreListing(commands.getNormalMembers(mockCache));
+        listCommand.getDiskStoreListing(Collections.singleton(mockDistributedMember));
 
     Assert.assertNotNull(actualDiskStores);
     assertEquals(expectedDiskStores, actualDiskStores);
@@ -349,11 +360,11 @@ public class DiskStoreCommandsJUnitTest {
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockDistributedMember, mockFunctionExecutor);
+    final ListDiskStoresCommand listCommand =
+        createListDiskStoreCommand(mockCache, mockDistributedMember, mockFunctionExecutor);
 
     try {
-      commands.getDiskStoreListing(commands.getNormalMembers(mockCache));
+      listCommand.getDiskStoreListing(Collections.singleton(mockDistributedMember));
     } catch (RuntimeException expected) {
       assertEquals("expected", expected.getMessage());
       throw expected;
@@ -376,9 +387,9 @@ public class DiskStoreCommandsJUnitTest {
     final DiskStoreDetails diskStoreDetails =
         createDiskStoreDetails("memberOne", "cacheServerDiskStore");
 
-    final List<DiskStoreDetails> expectedDiskStores = Arrays.asList(diskStoreDetails);
+    final List<DiskStoreDetails> expectedDiskStores = Collections.singletonList(diskStoreDetails);
 
-    final List<Object> results = new ArrayList<Object>();
+    final List<Object> results = new ArrayList<>();
 
     results.add(CollectionUtils.asSet(diskStoreDetails));
     results.add(new FunctionInvocationTargetException("expected"));
@@ -393,23 +404,23 @@ public class DiskStoreCommandsJUnitTest {
       }
     });
 
-    final DiskStoreCommands commands =
-        createDiskStoreCommands(mockCache, mockDistributedMember, mockFunctionExecutor);
+    final ListDiskStoresCommand listCommand =
+        createListDiskStoreCommand(mockCache, mockDistributedMember, mockFunctionExecutor);
 
     final List<DiskStoreDetails> actualDiskStores =
-        commands.getDiskStoreListing(commands.getNormalMembers(mockCache));
+        listCommand.getDiskStoreListing(Collections.singleton(mockDistributedMember));
 
     Assert.assertNotNull(actualDiskStores);
     assertEquals(expectedDiskStores, actualDiskStores);
   }
 
-  private static class TestDiskStoreCommands extends DiskStoreCommands {
+  private static class TestDescribeDiskStoreCommand extends DescribeDiskStoreCommand {
 
     private final InternalCache cache;
     private final DistributedMember distributedMember;
     private final Execution functionExecutor;
 
-    public TestDiskStoreCommands(final InternalCache cache,
+    TestDescribeDiskStoreCommand(final InternalCache cache,
         final DistributedMember distributedMember, final Execution functionExecutor) {
       assert cache != null : "The Cache cannot be null!";
       this.cache = cache;
@@ -433,12 +444,37 @@ public class DiskStoreCommandsJUnitTest {
       Assert.assertNotNull(members);
       return this.functionExecutor;
     }
+  }
+
+  private static class TestListDiskStoresCommand extends ListDiskStoresCommand {
+
+    private final InternalCache cache;
+    private final DistributedMember distributedMember;
+    private final Execution functionExecutor;
+
+    TestListDiskStoresCommand(final InternalCache cache, final DistributedMember distributedMember,
+        final Execution functionExecutor) {
+      assert cache != null : "The Cache cannot be null!";
+      this.cache = cache;
+      this.distributedMember = distributedMember;
+      this.functionExecutor = functionExecutor;
+    }
 
     @Override
-    protected Set<DistributedMember> getNormalMembers(final InternalCache cache) {
+    public InternalCache getCache() {
+      return this.cache;
+    }
+
+    @Override
+    public Set<DistributedMember> getMembers(final InternalCache cache) {
       assertSame(getCache(), cache);
       return Collections.singleton(this.distributedMember);
     }
-  }
 
+    @Override
+    public Execution getMembersFunctionExecutor(final Set<DistributedMember> members)
{
+      Assert.assertNotNull(members);
+      return this.functionExecutor;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/ca808714/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
index 8d4be8b..1fe0bd1 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
@@ -14,7 +14,25 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import org.apache.geode.cache.*;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.LogWriterUtils.getDUnitLogLevel;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.DiskStore;
+import org.apache.geode.cache.DiskStoreFactory;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.Scope;
 import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
@@ -22,18 +40,6 @@ import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import static org.apache.geode.test.dunit.Assert.assertEquals;
-import static org.apache.geode.test.dunit.Assert.assertNotNull;
-import static org.apache.geode.test.dunit.Host.getHost;
-import static org.apache.geode.test.dunit.LogWriterUtils.getDUnitLogLevel;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
 
 /**
  * The ListAndDescribeDiskStoreCommandsDUnitTest class is a test suite of functional tests
cases
@@ -41,7 +47,9 @@ import static org.apache.geode.distributed.ConfigurationProperties.*;
  * </p>
  *
  * @see org.apache.geode.management.internal.cli.commands.CliCommandTestBase
- * @see org.apache.geode.management.internal.cli.commands.DiskStoreCommands
+ * @see ListDiskStoresCommand
+ * @see org.apache.geode.management.internal.cli.commands.DescribeDiskStoreCommand
+ *
  * @since GemFire 7.0
  */
 @Category(DistributedTest.class)


Mime
View raw message