You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2017/02/22 17:17:12 UTC
[2/2] geode git commit: GEODE-2267: spotless
GEODE-2267: spotless
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/112f2669
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/112f2669
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/112f2669
Branch: refs/heads/feature/GEODE-2267
Commit: 112f26699414bda43acc4a29311135bbac875fd1
Parents: 4a70020
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Feb 22 09:15:50 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Feb 22 09:15:50 2017 -0800
----------------------------------------------------------------------
.../geode/management/cli/CliMetaData.java | 8 +--
.../internal/cli/CliAroundInterceptor.java | 9 ++--
.../geode/management/internal/cli/CliUtil.java | 12 +++--
.../management/internal/cli/CommandRequest.java | 4 +-
.../cli/commands/MiscellaneousCommands.java | 25 +++++----
.../cli/shell/GfshExecutionStrategy.java | 11 ++--
.../internal/cli/util/ExportLogsRepository.java | 22 ++++----
.../management/internal/cli/util/MergeLogs.java | 15 +++---
.../MiscellaneousCommandsController.java | 20 +++----
.../web/shell/AbstractHttpOperationInvoker.java | 14 ++---
.../web/shell/RestHttpOperationInvoker.java | 7 ++-
.../internal/cli/commands/ExportLogsDUnit.java | 55 ++++++++++----------
.../ExportLogsFunctionIntegrationTest.java | 3 +-
.../internal/cli/util/MergeLogsTest.java | 46 ++++++++--------
.../dunit/rules/GfshShellConnectionRule.java | 12 ++---
.../cli/commands/CommandOverHttpDUnitTest.java | 6 +--
.../cli/commands/ExportLogsOverHttpDunit.java | 4 +-
.../RestHttpOperationInvokerJUnitTest.java | 8 +--
.../SimpleHttpOperationInvokerJUnitTest.java | 6 +--
19 files changed, 146 insertions(+), 141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java b/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
index dc7d741..e69d78a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
+++ b/geode-core/src/main/java/org/apache/geode/management/cli/CliMetaData.java
@@ -44,10 +44,10 @@ public @interface CliMetaData {
boolean shellOnly() default false;
/**
- * Indicates when executed over http, is this command downloading files from the member.
- * When this is set to true, the RestHttpOperationInvoker will use an extractor to extract
- * the inputstream in the response to a temporary file and it's up to your command's interceptor's
- * postExecution to use that temp file to fit your need.
+ * Indicates when executed over http, is this command downloading files from the member. When this
+ * is set to true, the RestHttpOperationInvoker will use an extractor to extract the inputstream
+ * in the response to a temporary file and it's up to your command's interceptor's postExecution
+ * to use that temp file to fit your need.
**/
boolean isFileDownloadOverHttp() default false;
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
index 2eeebb5..9bf8b55 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliAroundInterceptor.java
@@ -31,6 +31,7 @@ public interface CliAroundInterceptor {
/**
* called by the OperationInvoker before the command is executed
+ *
* @param parseResult
* @return
*/
@@ -39,19 +40,21 @@ public interface CliAroundInterceptor {
}
@Deprecated
- default public Result postExecution(GfshParseResult parseResult, Result commandResult){
+ default public Result postExecution(GfshParseResult parseResult, Result commandResult) {
return commandResult;
}
/**
* called by the OperationInvoker after the command is executed
+ *
* @param parseResult
* @param commandResult
* @param tempFile: if the command's isFileDownloadOverHttp is true, the is the File downloaded
- * after the http response is processed.
+ * after the http response is processed.
* @return
*/
- default public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
+ default public Result postExecution(GfshParseResult parseResult, Result commandResult,
+ Path tempFile) {
return postExecution(parseResult, commandResult);
}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index fe56186..4c416d7 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -302,9 +302,11 @@ public class CliUtil {
}
/**
- * Finds all Members (including both servers and locators) which belong to the given arrays of groups or members.
+ * Finds all Members (including both servers and locators) which belong to the given arrays of
+ * groups or members.
*/
- public static Set<DistributedMember> findMembersIncludingLocators(String[] groups, String[] members) {
+ public static Set<DistributedMember> findMembersIncludingLocators(String[] groups,
+ String[] members) {
Cache cache = CacheFactory.getAnyInstance();
Set<DistributedMember> allMembers = getAllMembers(cache);
@@ -312,7 +314,8 @@ public class CliUtil {
}
/**
- * Finds all Servers which belong to the given arrays of groups or members. Does not include locators.
+ * Finds all Servers which belong to the given arrays of groups or members. Does not include
+ * locators.
*/
public static Set<DistributedMember> findMembers(String[] groups, String[] members) {
Cache cache = CacheFactory.getAnyInstance();
@@ -321,7 +324,8 @@ public class CliUtil {
return findMembers(allNormalMembers, groups, members);
}
- private static Set<DistributedMember> findMembers(Set<DistributedMember> membersToConsider, String[] groups, String[] members) {
+ private static Set<DistributedMember> findMembers(Set<DistributedMember> membersToConsider,
+ String[] groups, String[] members) {
if (groups == null) {
groups = new String[] {};
}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
index a135340..13bbff8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandRequest.java
@@ -69,7 +69,7 @@ public class CommandRequest {
this.parseResult = parseResult;
CliMetaData metaData = parseResult.getMethod().getDeclaredAnnotation(CliMetaData.class);
- if(metaData.isFileDownloadOverHttp()){
+ if (metaData.isFileDownloadOverHttp()) {
downloadFile = true;
}
}
@@ -95,7 +95,7 @@ public class CommandRequest {
return customInput;
}
- public boolean isDownloadFile(){
+ public boolean isDownloadFile() {
return downloadFile;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index 1da3d68..dd7e96a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -685,8 +685,7 @@ public class MiscellaneousCommands implements CommandMarker {
}
@CliCommand(value = CliStrings.EXPORT_LOGS, help = CliStrings.EXPORT_LOGS__HELP)
- @CliMetaData(shellOnly = false,
- isFileDownloadOverHttp = true,
+ @CliMetaData(shellOnly = false, isFileDownloadOverHttp = true,
interceptor = "org.apache.geode.management.internal.cli.commands.MiscellaneousCommands$ExportLogsInterceptor",
relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
@@ -773,35 +772,35 @@ public class MiscellaneousCommands implements CommandMarker {
}
/**
- * after the export logs, will need to copy the tempFile to the desired location
- * and delete the temp file.
+ * after the export logs, will need to copy the tempFile to the desired location and delete the
+ * temp file.
*/
public static class ExportLogsInterceptor extends AbstractCliAroundInterceptor {
@Override
public Result postExecution(GfshParseResult parseResult, Result commandResult, Path tempFile) {
// in the command over http case, the command result is in the downloaded temp file
- if(tempFile!=null){
+ if (tempFile != null) {
Path dirPath;
String dirName = parseResult.getParamValueStrings().get("dir");
- if(StringUtils.isBlank(dirName)){
+ if (StringUtils.isBlank(dirName)) {
dirPath = Paths.get(System.getProperty("user.dir"));
- }
- else{
+ } else {
dirPath = Paths.get(dirName);
}
- String fileName = "exportedLogs_"+System.currentTimeMillis()+".zip";
+ String fileName = "exportedLogs_" + System.currentTimeMillis() + ".zip";
File exportedLogFile = dirPath.resolve(fileName).toFile();
try {
FileUtils.copyFile(tempFile.toFile(), exportedLogFile);
FileUtils.deleteQuietly(tempFile.toFile());
- commandResult = ResultBuilder.createInfoResult("Logs exported to: "+exportedLogFile.getAbsolutePath());
+ commandResult = ResultBuilder
+ .createInfoResult("Logs exported to: " + exportedLogFile.getAbsolutePath());
} catch (IOException e) {
logger.error(e.getMessage(), e);
commandResult = ResultBuilder.createGemFireErrorResult(e.getMessage());
}
- }
- else{
- commandResult = ResultBuilder.createInfoResult("Logs exported to the connected locator's file system: " + commandResult.nextLine());
+ } else {
+ commandResult = ResultBuilder.createInfoResult(
+ "Logs exported to the connected locator's file system: " + commandResult.nextLine());
}
return commandResult;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
index 02744e5..1c645d0 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java
@@ -239,10 +239,9 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
} catch (NotAuthorizedException e) {
return ResultBuilder
.createGemFireUnAuthorizedErrorResult("Unauthorized. Reason : " + e.getMessage());
- } catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
- }
- finally {
+ } finally {
env.clear();
}
@@ -256,7 +255,7 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
// the response could be a string which is a json respresentation of the CommandResult object
// it can also be a Path to a temp file downloaded from the rest http request
- if(response instanceof String) {
+ if (response instanceof String) {
CommandResponse commandResponse =
CommandResponseBuilder.prepareCommandResponseFromJson((String) response);
@@ -280,8 +279,8 @@ public class GfshExecutionStrategy implements ExecutionStrategy {
}
Path tempFile = null;
- if(response instanceof Path){
- tempFile = (Path)response;
+ if (response instanceof Path) {
+ tempFile = (Path) response;
}
// 3. Post Remote Execution
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
index 9a79fc0..85ce1ad 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ExportLogsRepository.java
@@ -1,18 +1,16 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.
*
*/
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
index 67d5473..04a649b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/MergeLogs.java
@@ -50,14 +50,13 @@ public class MergeLogs {
// create a new process for merging
LogWrapper.getInstance().fine("Exporting logs merging logs" + logDirectory);
List<String> commandList = new ArrayList<String>();
- commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
- + File.separatorChar + "java");
+ commandList.add(
+ System.getProperty("java.home") + File.separatorChar + "bin" + File.separatorChar + "java");
commandList.add("-classpath");
commandList.add(System.getProperty("java.class.path", "."));
commandList.add(MergeLogs.class.getName());
- commandList
- .add(logDirectory.toAbsolutePath().toString());
+ commandList.add(logDirectory.toAbsolutePath().toString());
ProcessBuilder procBuilder = new ProcessBuilder(commandList);
StringBuilder output = new StringBuilder();
@@ -100,8 +99,8 @@ public class MergeLogs {
}
- protected static List<File> findLogFilesToMerge (File dir) {
- return FileUtils.listFiles(dir, new String[]{"log"}, true).stream().collect(toList());
+ protected static List<File> findLogFilesToMerge(File dir) {
+ return FileUtils.listFiles(dir, new String[] {"log"}, true).stream().collect(toList());
}
static File mergeLogFile(String dirName) throws Exception {
@@ -122,8 +121,8 @@ public class MergeLogs {
PrintWriter mergedLog = null;
File mergedLogFile = null;
try {
- String mergeLog =
- dirName + File.separator + "merge_" + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ".log";
+ String mergeLog = dirName + File.separator + "merge_"
+ + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ".log";
mergedLogFile = new File(mergeLog);
mergedLog = new PrintWriter(mergedLogFile);
boolean flag = MergeLogFiles.mergeLogFiles(logFiles, logFileNames, mergedLog);
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
index 28cc658..e2f5307 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/MiscellaneousCommandsController.java
@@ -53,19 +53,21 @@ import java.io.FileInputStream;
public class MiscellaneousCommandsController extends AbstractCommandsController {
@RequestMapping(method = RequestMethod.GET, value = "/logs")
- public ResponseEntity<InputStreamResource> exportLogs(@RequestParam(value = CliStrings.EXPORT_LOGS__DIR, required = false) final String directory,
- @RequestParam(value = CliStrings.EXPORT_LOGS__GROUP, required = false) final String[] groups,
- @RequestParam(value = CliStrings.EXPORT_LOGS__MEMBER,
+ public ResponseEntity<InputStreamResource> exportLogs(
+ @RequestParam(value = CliStrings.EXPORT_LOGS__DIR, required = false) final String directory,
+ @RequestParam(value = CliStrings.EXPORT_LOGS__GROUP, required = false) final String[] groups,
+ @RequestParam(value = CliStrings.EXPORT_LOGS__MEMBER,
required = false) final String memberNameId,
- @RequestParam(value = CliStrings.EXPORT_LOGS__LOGLEVEL,
+ @RequestParam(value = CliStrings.EXPORT_LOGS__LOGLEVEL,
required = false) final String logLevel,
- @RequestParam(value = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL,
+ @RequestParam(value = CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL,
defaultValue = "false") final Boolean onlyLogLevel,
- @RequestParam(value = CliStrings.EXPORT_LOGS__MERGELOG,
+ @RequestParam(value = CliStrings.EXPORT_LOGS__MERGELOG,
defaultValue = "false") final Boolean mergeLog,
- @RequestParam(value = CliStrings.EXPORT_LOGS__STARTTIME,
+ @RequestParam(value = CliStrings.EXPORT_LOGS__STARTTIME,
required = false) final String startTime,
- @RequestParam(value = CliStrings.EXPORT_LOGS__ENDTIME, required = false) final String endTime) {
+ @RequestParam(value = CliStrings.EXPORT_LOGS__ENDTIME,
+ required = false) final String endTime) {
final CommandStringBuilder command = new CommandStringBuilder(CliStrings.EXPORT_LOGS);
command.addOption(CliStrings.EXPORT_LOGS__DIR, decode(directory));
@@ -97,7 +99,7 @@ public class MiscellaneousCommandsController extends AbstractCommandsController
}
// the result is json string from CommandResult
- String result = processCommand(command.toString());
+ String result = processCommand(command.toString());
// parse the result to get the file path
String filePath = ResultBuilder.fromJson(result).nextLine().trim();
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
index 2a409cc..9dc5c27 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/AbstractHttpOperationInvoker.java
@@ -588,8 +588,7 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
* @see org.apache.geode.management.internal.web.http.ClientHttpRequest
* @see org.springframework.http.ResponseEntity
*/
- protected <T> T send(final ClientHttpRequest request,
- final Class<T> responseType) {
+ protected <T> T send(final ClientHttpRequest request, final Class<T> responseType) {
return send(request, responseType, Collections.<String, Object>emptyMap());
}
@@ -633,21 +632,24 @@ public abstract class AbstractHttpOperationInvoker implements HttpOperationInvok
return response.getBody();
}
- protected Path downloadResponseToTempFile(ClientHttpRequest request, Map<String, ?> uriVariables){
+ protected Path downloadResponseToTempFile(ClientHttpRequest request,
+ Map<String, ?> uriVariables) {
final URI url = request.getURL(uriVariables);
// Optional Accept header
- RequestCallback requestCallback = r -> r.getHeaders().setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
+ RequestCallback requestCallback =
+ r -> r.getHeaders().setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
// Streams the response instead of loading it all in memory
ResponseExtractor<Path> responseExtractor = resp -> {
Path tempFile = Files.createTempFile("fileDownload", "");
- if(tempFile.toFile().exists()){
+ if (tempFile.toFile().exists()) {
FileUtils.deleteQuietly(tempFile.toFile());
}
Files.copy(resp.getBody(), tempFile);
return tempFile;
};
- return getRestTemplate().execute(url, org.springframework.http.HttpMethod.GET, requestCallback, responseExtractor);
+ return getRestTemplate().execute(url, org.springframework.http.HttpMethod.GET, requestCallback,
+ responseExtractor);
}
/**
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
index cb0f082..eeedf40 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvoker.java
@@ -375,7 +375,7 @@ public class RestHttpOperationInvoker extends AbstractHttpOperationInvoker imple
*
* @param command the command requested/entered by the user to be processed.
* @return either a json string of the CommandResult or a Path to a temp file if the response is a
- * InputStream
+ * InputStream
* @see #createHttpRequest(org.apache.geode.management.internal.cli.CommandRequest)
* @see #handleResourceAccessException(org.springframework.web.client.ResourceAccessException)
* @see #isConnected()
@@ -393,10 +393,9 @@ public class RestHttpOperationInvoker extends AbstractHttpOperationInvoker imple
Object result = null;
try {
- if(command.isDownloadFile()){
+ if (command.isDownloadFile()) {
result = downloadResponseToTempFile(createHttpRequest(command), command.getParameters());
- }
- else{
+ } else {
result = send(createHttpRequest(command), String.class, command.getParameters());
}
return result;
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
index 43ee742..a64620a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnit.java
@@ -111,7 +111,7 @@ public class ExportLogsDUnit {
ZonedDateTime yesterday = now.minusDays(1);
ZonedDateTime twoDaysAgo = now.minusDays(2);
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
commandStringBuilder.addOption("start-time", dateTimeFormatter.format(twoDaysAgo));
@@ -131,7 +131,7 @@ public class ExportLogsDUnit {
ZonedDateTime yesterday = now.minusDays(1);
ZonedDateTime tomorrow = now.plusDays(1);
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT);
CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday));
@@ -149,18 +149,20 @@ public class ExportLogsDUnit {
public void testExportWithStartAndEndDateTimeFiltering() throws Exception {
ZonedDateTime cutoffTime = LocalDateTime.now().atZone(ZoneId.systemDefault());
- String messageAfterCutoffTime = "[this message should not show up since it is after cutoffTime]";
- LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true);
+ String messageAfterCutoffTime =
+ "[this message should not show up since it is after cutoffTime]";
+ LogLine logLineAfterCutoffTime = new LogLine(messageAfterCutoffTime, "info", true);
server1.invoke(() -> {
Logger logger = LogService.getLogger();
logLineAfterCutoffTime.writeLog(logger);
});
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT);
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMAT);
String cutoffTimeString = dateTimeFormatter.format(cutoffTime);
CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs");
- commandStringBuilder.addOption("start-time", dateTimeFormatter.format(cutoffTime.minusHours(1)));
+ commandStringBuilder.addOption("start-time",
+ dateTimeFormatter.format(cutoffTime.minusHours(1)));
commandStringBuilder.addOption("end-time", cutoffTimeString);
commandStringBuilder.addOption("log-level", "debug");
commandStringBuilder.addOption("dir", "someDir");
@@ -175,9 +177,9 @@ public class ExportLogsDUnit {
@Test
public void testExportWithThresholdLogLevelFilter() throws Exception {
- CommandResult result = gfshConnector.executeAndVerifyCommand(
- "export logs --log-level=info --only-log-level=false --dir=" + lsRule.getTempFolder()
- .getRoot().getCanonicalPath());
+ CommandResult result = gfshConnector
+ .executeAndVerifyCommand("export logs --log-level=info --only-log-level=false --dir="
+ + lsRule.getTempFolder().getRoot().getCanonicalPath());
Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
@@ -186,9 +188,9 @@ public class ExportLogsDUnit {
@Test
public void testExportWithExactLogLevelFilter() throws Exception {
- CommandResult result = gfshConnector.executeAndVerifyCommand(
- "export logs --log-level=info --only-log-level=true --dir=" + lsRule.getTempFolder()
- .getRoot().getCanonicalPath());
+ CommandResult result = gfshConnector
+ .executeAndVerifyCommand("export logs --log-level=info --only-log-level=true --dir="
+ + lsRule.getTempFolder().getRoot().getCanonicalPath());
Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
@@ -197,8 +199,8 @@ public class ExportLogsDUnit {
@Test
public void testExportWithNoFilters() throws Exception {
- CommandResult result = gfshConnector.executeAndVerifyCommand(
- "export logs --dir=" + "someDir" /* lsRule.getTempFolder().getRoot().getCanonicalPath() */);
+ CommandResult result = gfshConnector.executeAndVerifyCommand("export logs --dir="
+ + "someDir" /* lsRule.getTempFolder().getRoot().getCanonicalPath() */);
Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
@@ -209,8 +211,8 @@ public class ExportLogsDUnit {
locator.invoke(ExportLogsDUnit::verifyExportLogsRegionWasDestroyed);
}
-@Test
-public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
+ @Test
+ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException {
locator.invoke(() -> {
ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
Cache cache = GemFireCacheImpl.getInstance();
@@ -234,11 +236,10 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
Cache cache = GemFireCacheImpl.getInstance();
assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
});
-}
+ }
- public void verifyZipFileContents(Set<String> acceptedLogLevels)
- throws IOException {
+ public void verifyZipFileContents(Set<String> acceptedLogLevels) throws IOException {
File unzippedLogFileDir = unzipExportedLogs();
Set<File> dirsFromZipFile =
@@ -261,9 +262,7 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
String memberName = dirForMember.getName();
Member member = expectedMessages.keySet().stream()
- .filter((Member aMember) -> aMember.getName().equals(memberName))
- .findFirst()
- .get();
+ .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
assertThat(member).isNotNull();
@@ -276,12 +275,12 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
assertThat(logFileForMember).exists();
assertThat(fileNamesInDir).hasSize(1);
- String logFileContents =
- FileUtils.readLines(logFileForMember, Charset.defaultCharset()).stream()
- .collect(joining("\n"));
+ String logFileContents = FileUtils.readLines(logFileForMember, Charset.defaultCharset())
+ .stream().collect(joining("\n"));
for (LogLine logLine : expectedMessages.get(member)) {
- boolean shouldExpectLogLine = acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
+ boolean shouldExpectLogLine =
+ acceptedLogLevels.contains(logLine.level) && !logLine.shouldBeIgnoredDueToTimestamp;
if (shouldExpectLogLine) {
assertThat(logFileContents).contains(logLine.getMessage());
@@ -300,7 +299,9 @@ public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFo
List<File> zipFilesInDir = Stream.of(locatorWorkingDir.listFiles())
.filter(f -> f.getName().endsWith(".zip")).collect(toList());
- assertThat(zipFilesInDir).describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(","))).hasSize(1);
+ assertThat(zipFilesInDir)
+ .describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(",")))
+ .hasSize(1);
File unzippedLogFileDir = lsRule.getTempFolder().newFolder("unzippedLogs");
ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/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 abae1de..6b87a24 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
@@ -99,7 +99,8 @@ public class ExportLogsFunctionIntegrationTest {
}
@Test
- public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember() throws IOException, ClassNotFoundException {
+ public void destroyExportLogsRegionWorksAsExpectedForInitiatingMember()
+ throws IOException, ClassNotFoundException {
ExportLogsFunction.createOrGetExistingExportLogsRegion(true);
Cache cache = GemFireCacheImpl.getInstance();
assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull();
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
index 7f4ffd4..ef1696c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsTest.java
@@ -1,18 +1,16 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.
*
*/
@@ -59,8 +57,8 @@ public class MergeLogsTest {
properties.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
locator = lsRule.startLocatorVM(0, properties);
- properties
- .setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + locator.getPort() + "]");
+ properties.setProperty(DistributionConfig.LOCATORS_NAME,
+ "localhost[" + locator.getPort() + "]");
Server server = lsRule.startServerVM(1, properties);
Server server2 = lsRule.startServerVM(2, properties);
@@ -81,21 +79,23 @@ public class MergeLogsTest {
File result = MergeLogs.mergeLogFile(lsRule.getTempFolder().getRoot().getCanonicalPath());
assertOnLogContents(result);
}
- @Test
+
+ @Test
public void testExportInNewProcess() throws Throwable {
assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
MergeLogs.mergeLogsInNewProcess(lsRule.getTempFolder().getRoot().toPath());
- File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles()).filter((File f) -> f.getName().startsWith("merge"))
- .findFirst().orElseThrow(() -> {throw new AssertionError("No merged log file found");});
+ File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles())
+ .filter((File f) -> f.getName().startsWith("merge")).findFirst().orElseThrow(() -> {
+ throw new AssertionError("No merged log file found");
+ });
assertOnLogContents(result);
}
- private void assertOnLogContents (File mergedLogFile) throws IOException {
- String
- mergedLines =
- FileUtils.readLines(mergedLogFile, Charset.defaultCharset()).stream().collect(joining("\n"));
+ private void assertOnLogContents(File mergedLogFile) throws IOException {
+ String mergedLines = FileUtils.readLines(mergedLogFile, Charset.defaultCharset()).stream()
+ .collect(joining("\n"));
assertThat(mergedLines).contains(MESSAGE_1);
assertThat(mergedLines).contains(MESSAGE_2);
@@ -104,11 +104,11 @@ public class MergeLogsTest {
assertThat(mergedLines).contains(MESSAGE_5);
assertThat(mergedLines).contains(MESSAGE_6);
- //Make sure that our merged log file contains the proper ordering
+ // Make sure that our merged log file contains the proper ordering
assertThat(mergedLines.indexOf(MESSAGE_1)).isLessThan(mergedLines.indexOf(MESSAGE_2));
assertThat(mergedLines.indexOf(MESSAGE_2)).isLessThan(mergedLines.indexOf(MESSAGE_3));
assertThat(mergedLines.indexOf(MESSAGE_3)).isLessThan(mergedLines.indexOf(MESSAGE_4));
assertThat(mergedLines.indexOf(MESSAGE_4)).isLessThan(mergedLines.indexOf(MESSAGE_5));
assertThat(mergedLines.indexOf(MESSAGE_5)).isLessThan(mergedLines.indexOf(MESSAGE_6));
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index c3310d5..dff5759 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -164,17 +164,17 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
public CommandResult executeCommand(String command) throws Exception {
gfsh.executeCommand(command);
CommandResult result = (CommandResult) gfsh.getResult();
- if(StringUtils.isBlank(gfsh.outputString)){
- JSONArray messages = ((JSONArray)result.getContent().get("message"));
- for(int i=0; i< messages.length(); i++){
- gfsh.outputString += messages.getString(i)+"\n";
- }
+ if (StringUtils.isBlank(gfsh.outputString)) {
+ JSONArray messages = ((JSONArray) result.getContent().get("message"));
+ for (int i = 0; i < messages.length(); i++) {
+ gfsh.outputString += messages.getString(i) + "\n";
+ }
}
System.out.println("Command result: \n" + gfsh.outputString);
return result;
}
- public String getGfshOutput(){
+ public String getGfshOutput() {
return gfsh.outputString;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
index 3f3358d..5f4cd74 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
@@ -31,9 +31,9 @@ import org.apache.geode.test.junit.runner.SuiteRunner;
GemfireDataCommandsDUnitTest.class,
GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.class, IndexCommandsDUnitTest.class,
ListAndDescribeDiskStoreCommandsDUnitTest.class, ListIndexCommandDUnitTest.class,
- MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,QueueCommandsDUnitTest.class,
- ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class, ShowMetricsDUnitTest.class,
- ShowStackTraceDUnitTest.class, UserCommandsDUnitTest.class})
+ MemberCommandsDUnitTest.class, MiscellaneousCommandsDUnitTest.class,
+ QueueCommandsDUnitTest.class, ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class,
+ ShowMetricsDUnitTest.class, ShowStackTraceDUnitTest.class, UserCommandsDUnitTest.class})
public class CommandOverHttpDUnitTest {
@ClassRule
public static ProvideSystemProperty provideSystemProperty =
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDunit.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDunit.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDunit.java
index a45d9ef..4445746 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDunit.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOverHttpDunit.java
@@ -93,7 +93,7 @@ public class ExportLogsOverHttpDunit {
public void testExportWithDir() throws Exception {
File dir = temporaryFolder.newFolder();
// export the logs
- gfshConnector.executeCommand("export logs --dir="+dir.getAbsolutePath());
+ gfshConnector.executeCommand("export logs --dir=" + dir.getAbsolutePath());
// verify that the message contains a path to the user.dir
String message = gfshConnector.getGfshOutput();
assertThat(message).contains("Logs exported to: ");
@@ -103,7 +103,7 @@ public class ExportLogsOverHttpDunit {
verifyZipContent(zipPath);
}
- private void verifyZipContent(String zipPath) throws Exception{
+ private void verifyZipContent(String zipPath) throws Exception {
Set<String> actualZipEnries =
new ZipFile(zipPath).stream().map(ZipEntry::getName).collect(Collectors.toSet());
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
index 912e16a..1ebe89a 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/RestHttpOperationInvokerJUnitTest.java
@@ -317,8 +317,8 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
@Override
@SuppressWarnings("unchecked")
- protected <T> T send(final ClientHttpRequest request,
- final Class<T> responseType, final Map<String, ?> uriVariables) {
+ protected <T> T send(final ClientHttpRequest request, final Class<T> responseType,
+ final Map<String, ?> uriVariables) {
return (T) expectedResult;
}
};
@@ -373,8 +373,8 @@ public class RestHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
protected void printWarning(final String message, final Object... args) {}
@Override
- protected <T> T send(final ClientHttpRequest request,
- final Class<T> responseType, final Map<String, ?> uriVariables) {
+ protected <T> T send(final ClientHttpRequest request, final Class<T> responseType,
+ final Map<String, ?> uriVariables) {
throw new ResourceAccessException("test");
}
http://git-wip-us.apache.org/repos/asf/geode/blob/112f2669/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
index ae19afa..a704654 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/shell/SimpleHttpOperationInvokerJUnitTest.java
@@ -128,8 +128,7 @@ public class SimpleHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
@Override
@SuppressWarnings("unchecked")
- protected <T> T send(final ClientHttpRequest request,
- final Class<T> responseType) {
+ protected <T> T send(final ClientHttpRequest request, final Class<T> responseType) {
return (T) expectedResult;
}
};
@@ -151,8 +150,7 @@ public class SimpleHttpOperationInvokerJUnitTest extends AbstractWebTestCase {
}
@Override
- protected <T> T send(final ClientHttpRequest request,
- final Class<T> responseType) {
+ protected <T> T send(final ClientHttpRequest request, final Class<T> responseType) {
throw new ResourceAccessException("test");
}