http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java index 7a2d33d..b6c11c4 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java @@ -41,6 +41,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARC import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; import static org.apache.geode.management.internal.cli.i18n.CliStrings.START_SERVER__PASSWORD; +import org.apache.commons.lang.ArrayUtils; import org.apache.geode.GemFireException; import org.apache.geode.SystemFailure; import org.apache.geode.cache.server.CacheServer; @@ -188,62 +189,46 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_LOCATOR, CliStrings.TOPIC_GEODE_LIFECYCLE}) public Result startLocator( - @CliOption(key = CliStrings.START_LOCATOR__MEMBER_NAME, mandatory = false, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, + @CliOption(key = CliStrings.START_LOCATOR__MEMBER_NAME, help = CliStrings.START_LOCATOR__MEMBER_NAME__HELP) String memberName, @CliOption(key = CliStrings.START_LOCATOR__BIND_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__BIND_ADDRESS__HELP) final String bindAddress, @CliOption(key = CliStrings.START_LOCATOR__CLASSPATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__CLASSPATH__HELP) final String classpath, @CliOption(key = CliStrings.START_LOCATOR__FORCE, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = CliStrings.START_LOCATOR__FORCE__HELP) final Boolean force, @CliOption(key = CliStrings.START_LOCATOR__GROUP, optionContext = ConverterHint.MEMBERGROUP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__GROUP__HELP) final String group, @CliOption(key = CliStrings.START_LOCATOR__HOSTNAME_FOR_CLIENTS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__HOSTNAME_FOR_CLIENTS__HELP) final String hostnameForClients, @CliOption(key = CliStrings.START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = CliStrings.START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH__HELP) final Boolean includeSystemClasspath, @CliOption(key = CliStrings.START_LOCATOR__LOCATORS, optionContext = ConverterHint.LOCATOR_DISCOVERY_CONFIG, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__LOCATORS__HELP) final String locators, @CliOption(key = CliStrings.START_LOCATOR__LOG_LEVEL, optionContext = ConverterHint.LOG_LEVEL, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__LOG_LEVEL__HELP) final String logLevel, @CliOption(key = CliStrings.START_LOCATOR__MCAST_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__MCAST_ADDRESS__HELP) final String mcastBindAddress, @CliOption(key = CliStrings.START_LOCATOR__MCAST_PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__MCAST_PORT__HELP) final Integer mcastPort, @CliOption(key = CliStrings.START_LOCATOR__PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__PORT__HELP) final Integer port, @CliOption(key = CliStrings.START_LOCATOR__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__DIR__HELP) String workingDirectory, @CliOption(key = CliStrings.START_LOCATOR__PROPERTIES, optionContext = ConverterHint.FILE_PATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__PROPERTIES__HELP) String gemfirePropertiesPathname, @CliOption(key = CliStrings.START_LOCATOR__SECURITY_PROPERTIES, optionContext = ConverterHint.FILE_PATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__SECURITY_PROPERTIES__HELP) String gemfireSecurityPropertiesPathname, @CliOption(key = CliStrings.START_LOCATOR__INITIALHEAP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__INITIALHEAP__HELP) final String initialHeap, @CliOption(key = CliStrings.START_LOCATOR__MAXHEAP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__MAXHEAP__HELP) final String maxHeap, @CliOption(key = CliStrings.START_LOCATOR__J, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__J__HELP) final String[] jvmArgsOpts, @CliOption(key = CliStrings.START_LOCATOR__CONNECT, unspecifiedDefaultValue = "true", specifiedDefaultValue = "true", @@ -257,10 +242,8 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { @CliOption(key = CliStrings.START_LOCATOR__CLUSTER__CONFIG__DIR, unspecifiedDefaultValue = "", help = CliStrings.START_LOCATOR__CLUSTER__CONFIG__DIR__HELP) final String clusterConfigDir, @CliOption(key = CliStrings.START_LOCATOR__HTTP_SERVICE_PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__HTTP_SERVICE_PORT__HELP) final Integer httpServicePort, @CliOption(key = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS__HELP) final String httpServiceBindAddress) { try { if (StringUtils.isBlank(memberName)) { @@ -272,17 +255,17 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { gemfirePropertiesPathname = CliUtil.resolvePathname(gemfirePropertiesPathname); - if (!StringUtils.isBlank(gemfirePropertiesPathname) + if (StringUtils.isNotBlank(gemfirePropertiesPathname) && !IOUtils.isExistingPathname(gemfirePropertiesPathname)) { return ResultBuilder.createUserErrorResult( - CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, - StringUtils.EMPTY_STRING, gemfirePropertiesPathname)); + CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY, + gemfirePropertiesPathname)); } gemfireSecurityPropertiesPathname = CliUtil.resolvePathname(gemfireSecurityPropertiesPathname); - if (!StringUtils.isBlank(gemfireSecurityPropertiesPathname) + if (StringUtils.isNotBlank(gemfireSecurityPropertiesPathname) && !IOUtils.isExistingPathname(gemfireSecurityPropertiesPathname)) { return ResultBuilder.createUserErrorResult( CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ", @@ -295,42 +278,41 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { Properties gemfireProperties = new Properties(); - gemfireProperties.setProperty(GROUPS, StringUtils.valueOf(group, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(LOCATORS, - StringUtils.valueOf(locators, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(LOG_LEVEL, - StringUtils.valueOf(logLevel, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(MCAST_ADDRESS, - StringUtils.valueOf(mcastBindAddress, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(MCAST_PORT, - StringUtils.valueOf(mcastPort, StringUtils.EMPTY_STRING)); + gemfireProperties.setProperty(GROUPS, StringUtils.defaultString(group)); + gemfireProperties.setProperty(LOCATORS, StringUtils.defaultString(locators)); + gemfireProperties.setProperty(LOG_LEVEL, StringUtils.defaultString(logLevel)); + gemfireProperties.setProperty(MCAST_ADDRESS, StringUtils.defaultString(mcastBindAddress)); + gemfireProperties.setProperty(MCAST_PORT, StringUtils.defaultString(mcastPort)); gemfireProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION, - StringUtils.valueOf(enableSharedConfiguration, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(enableSharedConfiguration)); gemfireProperties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, - StringUtils.valueOf(loadSharedConfigurationFromDirectory, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(loadSharedConfigurationFromDirectory)); gemfireProperties.setProperty(CLUSTER_CONFIGURATION_DIR, - StringUtils.valueOf(clusterConfigDir, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(HTTP_SERVICE_PORT, - StringUtils.valueOf(httpServicePort, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(clusterConfigDir)); + gemfireProperties.setProperty(HTTP_SERVICE_PORT, StringUtils.defaultString(httpServicePort)); gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, - StringUtils.valueOf(httpServiceBindAddress, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(httpServiceBindAddress)); // read the OSProcess enable redirect system property here -- TODO: replace with new GFSH // argument final boolean redirectOutput = Boolean.getBoolean(OSProcess.ENABLE_OUTPUT_REDIRECTION_PROPERTY); - LocatorLauncher locatorLauncher = - new LocatorLauncher.Builder().setBindAddress(bindAddress).setForce(force) - .setHostnameForClients(hostnameForClients).setMemberName(memberName).setPort(port) - .setRedirectOutput(redirectOutput).setWorkingDirectory(workingDirectory).build(); + LocatorLauncher.Builder locatorLauncherBuilder = + new LocatorLauncher.Builder().setBindAddress(bindAddress).setForce(force).setPort(port) + .setRedirectOutput(redirectOutput).setWorkingDirectory(workingDirectory); + if (hostnameForClients != null) { + locatorLauncherBuilder.setHostnameForClients(hostnameForClients); + } + if (memberName != null) { + locatorLauncherBuilder.setMemberName(memberName); + } + LocatorLauncher locatorLauncher = locatorLauncherBuilder.build(); String[] locatorCommandLine = createStartLocatorCommandLine(locatorLauncher, gemfirePropertiesPathname, gemfireSecurityPropertiesPathname, gemfireProperties, classpath, includeSystemClasspath, jvmArgsOpts, initialHeap, maxHeap); - // getGfsh().logInfo(StringUtils.concat(locatorCommandLine, " "), null); - final Process locatorProcess = new ProcessBuilder(locatorCommandLine) .directory(new File(locatorLauncher.getWorkingDirectory())).start(); @@ -502,7 +484,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { commandLine.add(LocatorLauncher.class.getName()); commandLine.add(LocatorLauncher.Command.START.getName()); - if (!StringUtils.isBlank(launcher.getMemberName())) { + if (StringUtils.isNotBlank(launcher.getMemberName())) { commandLine.add(launcher.getMemberName()); } @@ -518,7 +500,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { commandLine.add("--force"); } - if (!StringUtils.isBlank(launcher.getHostnameForClients())) { + if (StringUtils.isNotBlank(launcher.getHostnameForClients())) { commandLine.add("--hostname-for-clients=" + launcher.getHostnameForClients()); } @@ -615,7 +597,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { jmxManagerSslEnabled, infoResultData); } - if (!StringUtils.isBlank(responseFailureMessage)) { + if (StringUtils.isNotBlank(responseFailureMessage)) { infoResultData.addLine("\n"); infoResultData.addLine(responseFailureMessage); } @@ -639,7 +621,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { message.append("Authentication"); } if (jmxManagerSslEnabled) { - message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY_STRING) + message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY) .append("SSL configuration"); } if (jmxManagerAuthEnabled || jmxManagerSslEnabled) { @@ -657,7 +639,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { private Map<String, String> loadConfigurationProperties( final String configurationPropertiesPathname, Map<String, String> configurationProperties) { configurationProperties = - (configurationProperties != null ? configurationProperties : new HashMap<String, String>()); + (configurationProperties != null ? configurationProperties : new HashMap<>()); if (IOUtils.isExistingPathname(configurationPropertiesPathname)) { try { @@ -763,22 +745,17 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { public Result statusLocator( @CliOption(key = CliStrings.STATUS_LOCATOR__MEMBER, optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_LOCATOR__MEMBER__HELP) final String member, @CliOption(key = CliStrings.STATUS_LOCATOR__HOST, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_LOCATOR__HOST__HELP) final String locatorHost, @CliOption(key = CliStrings.STATUS_LOCATOR__PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_LOCATOR__PORT__HELP) final Integer locatorPort, @CliOption(key = CliStrings.STATUS_LOCATOR__PID, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_LOCATOR__PID__HELP) final Integer pid, @CliOption(key = CliStrings.STATUS_LOCATOR__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_LOCATOR__DIR__HELP) final String workingDirectory) { try { - if (!StringUtils.isBlank(member)) { + if (StringUtils.isNotBlank(member)) { if (isConnectedAndReady()) { final MemberMXBean locatorProxy = getMemberMXBean(member); @@ -802,9 +779,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { final LocatorState state = locatorLauncher.status(); return createStatusLocatorResult(state); } - } catch (IllegalArgumentException e) { - return ResultBuilder.createUserErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException | IllegalStateException e) { return ResultBuilder.createUserErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); @@ -824,18 +799,15 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { public Result stopLocator( @CliOption(key = CliStrings.STOP_LOCATOR__MEMBER, optionContext = ConverterHint.LOCATOR_MEMBER_IDNAME, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STOP_LOCATOR__MEMBER__HELP) final String member, @CliOption(key = CliStrings.STOP_LOCATOR__PID, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STOP_LOCATOR__PID__HELP) final Integer pid, @CliOption(key = CliStrings.STOP_LOCATOR__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STOP_LOCATOR__DIR__HELP) final String workingDirectory) { LocatorState locatorState; try { - if (!StringUtils.isBlank(member)) { + if (StringUtils.isNotBlank(member)) { if (isConnectedAndReady()) { final MemberMXBean locatorProxy = getMemberMXBean(member); @@ -887,13 +859,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { } } - return ResultBuilder.createInfoResult(StringUtils.EMPTY_STRING); + return ResultBuilder.createInfoResult(StringUtils.EMPTY); } else { return ResultBuilder.createUserErrorResult(locatorState.toString()); } - } catch (IllegalArgumentException e) { - return ResultBuilder.createUserErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException | IllegalStateException e) { return ResultBuilder.createUserErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); @@ -917,7 +887,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { if (StringUtils.isBlank(gemfireProperties.getProperty(LOCATORS))) { String currentLocators = getCurrentLocators(); - if (!StringUtils.isBlank(currentLocators)) { + if (StringUtils.isNotBlank(currentLocators)) { commandLine.add("-D".concat(ProcessLauncherContext.OVERRIDDEN_DEFAULTS_PREFIX) .concat(LOCATORS).concat("=").concat(currentLocators)); } @@ -934,14 +904,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { protected void addGemFirePropertyFile(final List<String> commandLine, final String gemfirePropertiesPathname) { - if (!StringUtils.isBlank(gemfirePropertiesPathname)) { + if (StringUtils.isNotBlank(gemfirePropertiesPathname)) { commandLine.add("-DgemfirePropertyFile=" + gemfirePropertiesPathname); } } protected void addGemFireSecurityPropertyFile(final List<String> commandLine, final String gemfireSecurityPropertiesPathname) { - if (!StringUtils.isBlank(gemfireSecurityPropertiesPathname)) { + if (StringUtils.isNotBlank(gemfireSecurityPropertiesPathname)) { commandLine.add("-DgemfireSecurityPropertyFile=" + gemfireSecurityPropertiesPathname); } } @@ -951,7 +921,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { for (final Object property : gemfireProperties.keySet()) { final String propertyName = property.toString(); final String propertyValue = gemfireProperties.getProperty(propertyName); - if (!StringUtils.isBlank(propertyValue)) { + if (StringUtils.isNotBlank(propertyValue)) { commandLine.add( "-D" + DistributionConfig.GEMFIRE_PREFIX + "" + propertyName + "=" + propertyValue); } @@ -959,7 +929,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { } protected void addInitialHeap(final List<String> commandLine, final String initialHeap) { - if (!StringUtils.isBlank(initialHeap)) { + if (StringUtils.isNotBlank(initialHeap)) { commandLine.add("-Xms" + initialHeap); } } @@ -997,7 +967,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { } protected void addMaxHeap(final List<String> commandLine, final String maxHeap) { - if (!StringUtils.isBlank(maxHeap)) { + if (StringUtils.isNotBlank(maxHeap)) { commandLine.add("-Xmx" + maxHeap); commandLine.add("-XX:+UseConcMarkSweepGC"); commandLine.add("-XX:CMSInitiatingOccupancyFraction=" + CMS_INITIAL_OCCUPANCY_FRACTION); @@ -1053,8 +1023,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { try { fileReader = new BufferedReader(new FileReader(pidFile)); return Integer.parseInt(fileReader.readLine()); - } catch (IOException ignore) { - } catch (NumberFormatException ignore) { + } catch (IOException | NumberFormatException ignore) { } finally { IOUtils.close(fileReader); } @@ -1094,7 +1063,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { protected String getClasspath(final String userClasspath) { String classpath = getSystemClasspath(); - if (!StringUtils.isBlank(userClasspath)) { + if (StringUtils.isNotBlank(userClasspath)) { classpath += (File.pathSeparator + userClasspath); } @@ -1124,9 +1093,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { String toClasspath(final boolean includeSystemClasspath, String[] jarFilePathnames, String... userClasspaths) { // gemfire jar must absolutely be the first JAR file on the CLASSPATH!!! - String classpath = getGemFireJarPath(); + StringBuilder classpath = new StringBuilder(getGemFireJarPath()); - userClasspaths = (userClasspaths != null ? userClasspaths : StringUtils.EMPTY_STRING_ARRAY); + userClasspaths = (userClasspaths != null ? userClasspaths : ArrayUtils.EMPTY_STRING_ARRAY); // Then, include user-specified classes on CLASSPATH to enable the user to override GemFire JAR // dependencies @@ -1137,30 +1106,30 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { // System CLASSPATH environment variable setting, which is consistent with the Java platform // behavior... for (String userClasspath : userClasspaths) { - if (!StringUtils.isBlank(userClasspath)) { - classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator); - classpath += userClasspath; + if (StringUtils.isNotBlank(userClasspath)) { + classpath.append((classpath.length() == 0) ? StringUtils.EMPTY : File.pathSeparator); + classpath.append(userClasspath); } } // Now, include any System-specified CLASSPATH environment variable setting... if (includeSystemClasspath) { - classpath += File.pathSeparator; - classpath += getSystemClasspath(); + classpath.append(File.pathSeparator); + classpath.append(getSystemClasspath()); } jarFilePathnames = - (jarFilePathnames != null ? jarFilePathnames : StringUtils.EMPTY_STRING_ARRAY); + (jarFilePathnames != null ? jarFilePathnames : ArrayUtils.EMPTY_STRING_ARRAY); // And finally, include all GemFire dependencies on the CLASSPATH... for (String jarFilePathname : jarFilePathnames) { - if (!StringUtils.isBlank(jarFilePathname)) { - classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator); - classpath += jarFilePathname; + if (StringUtils.isNotBlank(jarFilePathname)) { + classpath.append((classpath.length() == 0) ? StringUtils.EMPTY : File.pathSeparator); + classpath.append(jarFilePathname); } } - return classpath; + return classpath.toString(); } protected String getGemFireJarPath() { @@ -1194,7 +1163,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { protected String getLocatorId(final String host, final Integer port) { final String locatorHost = (host != null ? host : getLocalHost()); final String locatorPort = - StringUtils.valueOf(port, String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT)); + StringUtils.defaultString(port, String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT)); return locatorHost.concat("[").concat(locatorPort).concat("]"); } @@ -1238,7 +1207,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { try { String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX; - objectNamePattern += (StringUtils.isBlank(serviceName) ? StringUtils.EMPTY_STRING + objectNamePattern += (StringUtils.isBlank(serviceName) ? StringUtils.EMPTY : "service=" + serviceName + StringUtils.COMMA_DELIMITER); objectNamePattern += "type=Member,*"; @@ -1266,7 +1235,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { protected String getServerId(final String host, final Integer port) { String serverHost = (host != null ? host : getLocalHost()); - String serverPort = StringUtils.valueOf(port, String.valueOf(CacheServer.DEFAULT_PORT)); + String serverPort = StringUtils.defaultString(port, String.valueOf(CacheServer.DEFAULT_PORT)); return serverHost.concat("[").concat(serverPort).concat("]"); } @@ -1287,31 +1256,24 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE}) public Result startServer( - @CliOption(key = CliStrings.START_SERVER__NAME, mandatory = false, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, + @CliOption(key = CliStrings.START_SERVER__NAME, help = CliStrings.START_SERVER__NAME__HELP) String memberName, @CliOption(key = CliStrings.START_SERVER__ASSIGN_BUCKETS, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = CliStrings.START_SERVER__ASSIGN_BUCKETS__HELP) final Boolean assignBuckets, @CliOption(key = CliStrings.START_SERVER__BIND_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__BIND_ADDRESS__HELP) final String bindAddress, @CliOption(key = CliStrings.START_SERVER__CACHE_XML_FILE, optionContext = ConverterHint.FILE_PATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__CACHE_XML_FILE__HELP) String cacheXmlPathname, @CliOption(key = CliStrings.START_SERVER__CLASSPATH, /* optionContext = ConverterHint.FILE_PATH, // there's an issue with TAB here */ - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__CLASSPATH__HELP) final String classpath, @CliOption(key = CliStrings.START_SERVER__CRITICAL__HEAP__PERCENTAGE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__CRITICAL__HEAP__HELP) final Float criticalHeapPercentage, @CliOption(key = CliStrings.START_SERVER__CRITICAL_OFF_HEAP_PERCENTAGE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__CRITICAL_OFF_HEAP__HELP) final Float criticalOffHeapPercentage, @CliOption(key = CliStrings.START_SERVER__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__DIR__HELP) String workingDirectory, @CliOption(key = CliStrings.START_SERVER__DISABLE_DEFAULT_SERVER, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", @@ -1320,98 +1282,70 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = CliStrings.START_SERVER__DISABLE_EXIT_WHEN_OUT_OF_MEMORY_HELP) final Boolean disableExitWhenOutOfMemory, @CliOption(key = CliStrings.START_SERVER__ENABLE_TIME_STATISTICS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "true", help = CliStrings.START_SERVER__ENABLE_TIME_STATISTICS__HELP) final Boolean enableTimeStatistics, @CliOption(key = CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE__HELP) final Float evictionHeapPercentage, @CliOption(key = CliStrings.START_SERVER__EVICTION_OFF_HEAP_PERCENTAGE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__EVICTION_OFF_HEAP_PERCENTAGE__HELP) final Float evictionOffHeapPercentage, @CliOption(key = CliStrings.START_SERVER__FORCE, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = CliStrings.START_SERVER__FORCE__HELP) final Boolean force, @CliOption(key = CliStrings.START_SERVER__GROUP, optionContext = ConverterHint.MEMBERGROUP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__GROUP__HELP) final String group, @CliOption(key = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS__HELP) final String hostNameForClients, @CliOption(key = CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH__HELP) final Boolean includeSystemClasspath, @CliOption(key = CliStrings.START_SERVER__INITIAL_HEAP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__INITIAL_HEAP__HELP) final String initialHeap, @CliOption(key = CliStrings.START_SERVER__J, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__J__HELP) final String[] jvmArgsOpts, @CliOption(key = CliStrings.START_SERVER__LOCATORS, optionContext = ConverterHint.LOCATOR_DISCOVERY_CONFIG, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__LOCATORS__HELP) final String locators, @CliOption(key = CliStrings.START_SERVER__LOCATOR_WAIT_TIME, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__LOCATOR_WAIT_TIME_HELP) final Integer locatorWaitTime, - @CliOption(key = CliStrings.START_SERVER__LOCK_MEMORY, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, - specifiedDefaultValue = "true", + @CliOption(key = CliStrings.START_SERVER__LOCK_MEMORY, specifiedDefaultValue = "true", help = CliStrings.START_SERVER__LOCK_MEMORY__HELP) final Boolean lockMemory, @CliOption(key = CliStrings.START_SERVER__LOG_LEVEL, optionContext = ConverterHint.LOG_LEVEL, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__LOG_LEVEL__HELP) final String logLevel, @CliOption(key = CliStrings.START_SERVER__MAX__CONNECTIONS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MAX__CONNECTIONS__HELP) final Integer maxConnections, @CliOption(key = CliStrings.START_SERVER__MAXHEAP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MAXHEAP__HELP) final String maxHeap, @CliOption(key = CliStrings.START_SERVER__MAX__MESSAGE__COUNT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MAX__MESSAGE__COUNT__HELP) final Integer maxMessageCount, @CliOption(key = CliStrings.START_SERVER__MAX__THREADS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MAX__THREADS__HELP) final Integer maxThreads, @CliOption(key = CliStrings.START_SERVER__MCAST_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MCAST_ADDRESS__HELP) final String mcastBindAddress, @CliOption(key = CliStrings.START_SERVER__MCAST_PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MCAST_PORT__HELP) final Integer mcastPort, @CliOption(key = CliStrings.START_SERVER__MEMCACHED_PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MEMCACHED_PORT__HELP) final Integer memcachedPort, @CliOption(key = CliStrings.START_SERVER__MEMCACHED_PROTOCOL, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MEMCACHED_PROTOCOL__HELP) final String memcachedProtocol, @CliOption(key = CliStrings.START_SERVER__MEMCACHED_BIND_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MEMCACHED_BIND_ADDRESS__HELP) final String memcachedBindAddress, @CliOption(key = CliStrings.START_SERVER__REDIS_PORT, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__REDIS_PORT__HELP) final Integer redisPort, @CliOption(key = CliStrings.START_SERVER__REDIS_BIND_ADDRESS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__REDIS_BIND_ADDRESS__HELP) final String redisBindAddress, @CliOption(key = CliStrings.START_SERVER__REDIS_PASSWORD, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__REDIS_PASSWORD__HELP) final String redisPassword, @CliOption(key = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE__HELP) final Integer messageTimeToLive, @CliOption(key = CliStrings.START_SERVER__OFF_HEAP_MEMORY_SIZE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__OFF_HEAP_MEMORY_SIZE__HELP) final String offHeapMemorySize, @CliOption(key = CliStrings.START_SERVER__PROPERTIES, optionContext = ConverterHint.FILE_PATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__PROPERTIES__HELP) String gemfirePropertiesPathname, @CliOption(key = CliStrings.START_SERVER__REBALANCE, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = CliStrings.START_SERVER__REBALANCE__HELP) final Boolean rebalance, @CliOption(key = CliStrings.START_SERVER__SECURITY_PROPERTIES, optionContext = ConverterHint.FILE_PATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__SECURITY_PROPERTIES__HELP) String gemfireSecurityPropertiesPathname, @CliOption(key = CliStrings.START_SERVER__SERVER_BIND_ADDRESS, unspecifiedDefaultValue = CacheServer.DEFAULT_BIND_ADDRESS, @@ -1420,13 +1354,10 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { unspecifiedDefaultValue = ("" + CacheServer.DEFAULT_PORT), help = CliStrings.START_SERVER__SERVER_PORT__HELP) final Integer serverPort, @CliOption(key = CliStrings.START_SERVER__SOCKET__BUFFER__SIZE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__SOCKET__BUFFER__SIZE__HELP) final Integer socketBufferSize, @CliOption(key = CliStrings.START_SERVER__SPRING_XML_LOCATION, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__SPRING_XML_LOCATION_HELP) final String springXmlLocation, @CliOption(key = CliStrings.START_SERVER__STATISTIC_ARCHIVE_FILE, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_SERVER__STATISTIC_ARCHIVE_FILE__HELP) final String statisticsArchivePathname, @CliOption(key = CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION, unspecifiedDefaultValue = "true", specifiedDefaultValue = "true", @@ -1452,7 +1383,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { } // prompt for password is username is specified in the command - if (!StringUtils.isBlank(userName)) { + if (StringUtils.isNotBlank(userName)) { if (StringUtils.isBlank(passwordToUse)) { passwordToUse = getGfsh().readPassword(START_SERVER__PASSWORD + ": "); } @@ -1466,24 +1397,25 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { cacheXmlPathname = CliUtil.resolvePathname(cacheXmlPathname); - if (!StringUtils.isBlank(cacheXmlPathname) && !IOUtils.isExistingPathname(cacheXmlPathname)) { + if (StringUtils.isNotBlank(cacheXmlPathname) + && !IOUtils.isExistingPathname(cacheXmlPathname)) { return ResultBuilder.createUserErrorResult( CliStrings.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname)); } gemfirePropertiesPathname = CliUtil.resolvePathname(gemfirePropertiesPathname); - if (!StringUtils.isBlank(gemfirePropertiesPathname) + if (StringUtils.isNotBlank(gemfirePropertiesPathname) && !IOUtils.isExistingPathname(gemfirePropertiesPathname)) { return ResultBuilder.createUserErrorResult( - CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, - StringUtils.EMPTY_STRING, gemfirePropertiesPathname)); + CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY, + gemfirePropertiesPathname)); } gemfireSecurityPropertiesPathname = CliUtil.resolvePathname(gemfireSecurityPropertiesPathname); - if (!StringUtils.isBlank(gemfireSecurityPropertiesPathname) + if (StringUtils.isNotBlank(gemfireSecurityPropertiesPathname) && !IOUtils.isExistingPathname(gemfireSecurityPropertiesPathname)) { return ResultBuilder.createUserErrorResult( CliStrings.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ", @@ -1496,52 +1428,39 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { Properties gemfireProperties = new Properties(); - gemfireProperties.setProperty(BIND_ADDRESS, - StringUtils.valueOf(bindAddress, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(CACHE_XML_FILE, - StringUtils.valueOf(cacheXmlPathname, StringUtils.EMPTY_STRING)); + gemfireProperties.setProperty(BIND_ADDRESS, StringUtils.defaultString(bindAddress)); + gemfireProperties.setProperty(CACHE_XML_FILE, StringUtils.defaultString(cacheXmlPathname)); gemfireProperties.setProperty(ENABLE_TIME_STATISTICS, - StringUtils.valueOf(enableTimeStatistics, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(GROUPS, StringUtils.valueOf(group, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(LOCATORS, - StringUtils.valueOf(locators, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(LOCATOR_WAIT_TIME, - StringUtils.valueOf(locatorWaitTime, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(LOG_LEVEL, - StringUtils.valueOf(logLevel, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(MCAST_ADDRESS, - StringUtils.valueOf(mcastBindAddress, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(MCAST_PORT, - StringUtils.valueOf(mcastPort, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(MEMCACHED_PORT, - StringUtils.valueOf(memcachedPort, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(enableTimeStatistics)); + gemfireProperties.setProperty(GROUPS, StringUtils.defaultString(group)); + gemfireProperties.setProperty(LOCATORS, StringUtils.defaultString(locators)); + gemfireProperties.setProperty(LOCATOR_WAIT_TIME, StringUtils.defaultString(locatorWaitTime)); + gemfireProperties.setProperty(LOG_LEVEL, StringUtils.defaultString(logLevel)); + gemfireProperties.setProperty(MCAST_ADDRESS, StringUtils.defaultString(mcastBindAddress)); + gemfireProperties.setProperty(MCAST_PORT, StringUtils.defaultString(mcastPort)); + gemfireProperties.setProperty(MEMCACHED_PORT, StringUtils.defaultString(memcachedPort)); gemfireProperties.setProperty(MEMCACHED_PROTOCOL, - StringUtils.valueOf(memcachedProtocol, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(memcachedProtocol)); gemfireProperties.setProperty(MEMCACHED_BIND_ADDRESS, - StringUtils.valueOf(memcachedBindAddress, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(REDIS_PORT, - StringUtils.valueOf(redisPort, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(memcachedBindAddress)); + gemfireProperties.setProperty(REDIS_PORT, StringUtils.defaultString(redisPort)); gemfireProperties.setProperty(REDIS_BIND_ADDRESS, - StringUtils.valueOf(redisBindAddress, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(REDIS_PASSWORD, - StringUtils.valueOf(redisPassword, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(redisBindAddress)); + gemfireProperties.setProperty(REDIS_PASSWORD, StringUtils.defaultString(redisPassword)); gemfireProperties.setProperty(STATISTIC_ARCHIVE_FILE, - StringUtils.valueOf(statisticsArchivePathname, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(statisticsArchivePathname)); gemfireProperties.setProperty(USE_CLUSTER_CONFIGURATION, - StringUtils.valueOf(requestSharedConfiguration, Boolean.TRUE.toString())); - gemfireProperties.setProperty(LOCK_MEMORY, - StringUtils.valueOf(lockMemory, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(requestSharedConfiguration, Boolean.TRUE.toString())); + gemfireProperties.setProperty(LOCK_MEMORY, StringUtils.defaultString(lockMemory)); gemfireProperties.setProperty(OFF_HEAP_MEMORY_SIZE, - StringUtils.valueOf(offHeapMemorySize, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(START_DEV_REST_API, - StringUtils.valueOf(startRestApi, StringUtils.EMPTY_STRING)); - gemfireProperties.setProperty(HTTP_SERVICE_PORT, - StringUtils.valueOf(httpServicePort, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(offHeapMemorySize)); + gemfireProperties.setProperty(START_DEV_REST_API, StringUtils.defaultString(startRestApi)); + gemfireProperties.setProperty(HTTP_SERVICE_PORT, StringUtils.defaultString(httpServicePort)); gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, - StringUtils.valueOf(httpServiceBindAddress, StringUtils.EMPTY_STRING)); + StringUtils.defaultString(httpServiceBindAddress)); // if username is specified in the command line, it will overwrite what's set in the // properties file - if (!StringUtils.isBlank(userName)) { + if (StringUtils.isNotBlank(userName)) { gemfireProperties.setProperty(ResourceConstants.USER_NAME, userName); gemfireProperties.setProperty(ResourceConstants.PASSWORD, passwordToUse); } @@ -1552,9 +1471,9 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { final boolean redirectOutput = Boolean.getBoolean(OSProcess.ENABLE_OUTPUT_REDIRECTION_PROPERTY); - ServerLauncher serverLauncher = new ServerLauncher.Builder().setAssignBuckets(assignBuckets) - .setDisableDefaultServer(disableDefaultServer).setForce(force).setMemberName(memberName) - .setRebalance(rebalance).setRedirectOutput(redirectOutput) + ServerLauncher.Builder serverLauncherBuilder = new ServerLauncher.Builder() + .setAssignBuckets(assignBuckets).setDisableDefaultServer(disableDefaultServer) + .setForce(force).setRebalance(rebalance).setRedirectOutput(redirectOutput) .setServerBindAddress(serverBindAddress).setServerPort(serverPort) .setSpringXmlLocation(springXmlLocation).setWorkingDirectory(workingDirectory) .setCriticalHeapPercentage(criticalHeapPercentage) @@ -1562,8 +1481,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { .setCriticalOffHeapPercentage(criticalOffHeapPercentage) .setEvictionOffHeapPercentage(evictionOffHeapPercentage).setMaxConnections(maxConnections) .setMaxMessageCount(maxMessageCount).setMaxThreads(maxThreads) - .setMessageTimeToLive(messageTimeToLive).setSocketBufferSize(socketBufferSize) - .setHostNameForClients(hostNameForClients).build(); + .setMessageTimeToLive(messageTimeToLive).setSocketBufferSize(socketBufferSize); + if (hostNameForClients != null) { + serverLauncherBuilder.setHostNameForClients(hostNameForClients); + } + if (memberName != null) { + serverLauncherBuilder.setMemberName(memberName); + } + ServerLauncher serverLauncher = serverLauncherBuilder.build(); String[] serverCommandLine = createStartServerCommandLine(serverLauncher, gemfirePropertiesPathname, gemfireSecurityPropertiesPathname, gemfireProperties, @@ -1571,7 +1496,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { maxHeap); if (getGfsh().getDebug()) { - getGfsh().logInfo(StringUtils.concat(serverCommandLine, " "), null); + getGfsh().logInfo(StringUtils.join(serverCommandLine, StringUtils.SPACE), null); } Process serverProcess = new ProcessBuilder(serverCommandLine) @@ -1722,7 +1647,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { commandLine.add(ServerLauncher.class.getName()); commandLine.add(ServerLauncher.Command.START.getName()); - if (!StringUtils.isBlank(launcher.getMemberName())) { + if (StringUtils.isNotBlank(launcher.getMemberName())) { commandLine.add(launcher.getMemberName()); } @@ -1847,16 +1772,13 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE}) public Result statusServer( @CliOption(key = CliStrings.STATUS_SERVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_SERVER__MEMBER__HELP) final String member, @CliOption(key = CliStrings.STATUS_SERVER__PID, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_SERVER__PID__HELP) final Integer pid, @CliOption(key = CliStrings.STATUS_SERVER__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STATUS_SERVER__DIR__HELP) final String workingDirectory) { try { - if (!StringUtils.isBlank(member)) { + if (StringUtils.isNotBlank(member)) { if (isConnectedAndReady()) { final MemberMXBean serverProxy = getMemberMXBean(member); @@ -1886,9 +1808,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { return ResultBuilder.createInfoResult(status.toString()); } - } catch (IllegalArgumentException e) { - return ResultBuilder.createUserErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException | IllegalStateException e) { return ResultBuilder.createUserErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); @@ -1905,18 +1825,15 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { relatedTopic = {CliStrings.TOPIC_GEODE_SERVER, CliStrings.TOPIC_GEODE_LIFECYCLE}) public Result stopServer( @CliOption(key = CliStrings.STOP_SERVER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STOP_SERVER__MEMBER__HELP) final String member, @CliOption(key = CliStrings.STOP_SERVER__PID, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STOP_SERVER__PID__HELP) final Integer pid, @CliOption(key = CliStrings.STOP_SERVER__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.STOP_SERVER__DIR__HELP) final String workingDirectory) { ServerState serverState; try { - if (!StringUtils.isBlank(member)) { + if (StringUtils.isNotBlank(member)) { if (isConnectedAndReady()) { final MemberMXBean serverProxy = getMemberMXBean(member); @@ -1963,13 +1880,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { } } - return ResultBuilder.createInfoResult(StringUtils.EMPTY_STRING); + return ResultBuilder.createInfoResult(StringUtils.EMPTY); } else { return ResultBuilder.createUserErrorResult(serverState.toString()); } - } catch (IllegalArgumentException e) { - return ResultBuilder.createUserErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException | IllegalStateException e) { return ResultBuilder.createUserErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); @@ -1988,10 +1903,8 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { // CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_LIFECYCLE}) public Result startManager( @CliOption(key = CliStrings.START_MANAGER__MEMBERNAME, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__MEMBERNAME__HELP) String memberName, @CliOption(key = CliStrings.START_MANAGER__DIR, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__DIR__HELP) String dir, @CliOption(key = CliStrings.START_MANAGER__PORT, unspecifiedDefaultValue = "1099", help = CliStrings.START_MANAGER__PORT__HELP) int cacheServerPort, @@ -1999,19 +1912,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { unspecifiedDefaultValue = "localhost", help = CliStrings.START_MANAGER__BIND_ADDRESS__HELP) String cacheServerHost, @CliOption(key = CliStrings.START_MANAGER__CLASSPATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__CLASSPATH__HELP) String classpath, @CliOption(key = CliStrings.START_MANAGER__MAXHEAP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__MAXHEAP__HELP) String maxHeap, @CliOption(key = CliStrings.START_MANAGER__INITIALHEAP, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__INITIALHEAP__HELP) String initialHeap, @CliOption(key = CliStrings.START_MANAGER__J, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__J__HELP) Map<String, String> systepProps, @CliOption(key = CliStrings.START_MANAGER__GEODEPROPS, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_MANAGER__GEODEPROPS__HELP) Map<String, String> gemfireProps) { return ResultBuilder.createInfoResult("Not-implemented"); } @@ -2026,13 +1934,11 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { unspecifiedDefaultValue = "false", help = CliStrings.START_JCONSOLE__NOTILE__HELP) final boolean notile, @CliOption(key = CliStrings.START_JCONSOLE__PLUGINPATH, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_JCONSOLE__PLUGINPATH__HELP) final String pluginpath, @CliOption(key = CliStrings.START_JCONSOLE__VERSION, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = CliStrings.START_JCONSOLE__VERSION__HELP) final boolean version, @CliOption(key = CliStrings.START_JCONSOLE__J, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_JCONSOLE__J__HELP) final List<String> jvmArgs) { try { String[] jconsoleCommandLine = @@ -2064,18 +1970,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { String jconsoleProcessOutput = waitAndCaptureProcessStandardErrorStream(jconsoleProcess); - if (!StringUtils.isBlank(jconsoleProcessOutput)) { + if (StringUtils.isNotBlank(jconsoleProcessOutput)) { message.append(StringUtils.LINE_SEPARATOR); message.append(jconsoleProcessOutput); } } return ResultBuilder.createInfoResult(message.toString()); - } catch (GemFireException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (IllegalArgumentException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (GemFireException | IllegalStateException | IllegalArgumentException e) { return ResultBuilder.createShellClientErrorResult(e.getMessage()); } catch (IOException e) { return ResultBuilder @@ -2106,7 +2008,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { commandLine.add("-notile"); } - if (!StringUtils.isBlank(pluginpath)) { + if (StringUtils.isNotBlank(pluginpath)) { commandLine.add("-pluginpath " + pluginpath); } @@ -2118,7 +2020,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { String jmxServiceUrl = getJmxServiceUrlAsString(member); - if (!StringUtils.isBlank(jmxServiceUrl)) { + if (StringUtils.isNotBlank(jmxServiceUrl)) { commandLine.add(jmxServiceUrl); } } @@ -2166,20 +2068,18 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { } protected static String getExecutableSuffix() { - return SystemUtils.isWindows() ? ".exe" : StringUtils.EMPTY_STRING; + return SystemUtils.isWindows() ? ".exe" : StringUtils.EMPTY; } protected String getJmxServiceUrlAsString(final String member) { - if (!StringUtils.isBlank(member)) { + if (StringUtils.isNotBlank(member)) { ConnectionEndpointConverter converter = new ConnectionEndpointConverter(); try { ConnectionEndpoint connectionEndpoint = converter.convertFromText(member, ConnectionEndpoint.class, null); - - return StringUtils.concat("service:jmx:rmi://", connectionEndpoint.getHost(), ":", - connectionEndpoint.getPort(), "/jndi/rmi://", connectionEndpoint.getHost(), ":", - connectionEndpoint.getPort(), "/jmxrmi"); + String hostAndPort = connectionEndpoint.getHost() + ":" + connectionEndpoint.getPort(); + return String.format("service:jmx:rmi://%s/jndi/rmi://%s/jmxrmi", hostAndPort, hostAndPort); } catch (Exception e) { throw new IllegalArgumentException( CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE); @@ -2201,7 +2101,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_MANAGER, CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M}) public Result startJVisualVM(@CliOption(key = CliStrings.START_JCONSOLE__J, - unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.START_JCONSOLE__J__HELP) final List<String> jvmArgs) { try { String[] jvisualvmCommandLine = createJVisualVMCommandLine(jvmArgs); @@ -2219,17 +2118,13 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { InfoResultData infoResultData = ResultBuilder.createInfoResultData(); - if (!StringUtils.isBlank(jvisualvmProcessOutput)) { + if (StringUtils.isNotBlank(jvisualvmProcessOutput)) { infoResultData.addLine(StringUtils.LINE_SEPARATOR); infoResultData.addLine(jvisualvmProcessOutput); } return ResultBuilder.buildResult(infoResultData); - } catch (GemFireException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (IllegalArgumentException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (GemFireException | IllegalStateException | IllegalArgumentException e) { return ResultBuilder.createShellClientErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); @@ -2285,7 +2180,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { unspecifiedDefaultValue = "http://localhost:7070/pulse", help = CliStrings.START_PULSE__URL__HELP) final String url) { try { - if (!StringUtils.isBlank(url)) { + if (StringUtils.isNotBlank(url)) { browse(URI.create(url)); return ResultBuilder.createInfoResult(CliStrings.START_PULSE__RUN); } else { @@ -2298,14 +2193,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { String pulseURL = (String) operationInvoker.getAttribute(managerObjectName.toString(), "PulseURL"); - if (!StringUtils.isBlank(pulseURL)) { + if (StringUtils.isNotBlank(pulseURL)) { browse(URI.create(pulseURL)); return ResultBuilder .createInfoResult(CliStrings.START_PULSE__RUN + " with URL: " + pulseURL); } else { String pulseMessage = (String) operationInvoker .getAttribute(managerObjectName.toString(), "StatusMessage"); - return (!StringUtils.isBlank(pulseMessage) + return (StringUtils.isNotBlank(pulseMessage) ? ResultBuilder.createGemFireErrorResult(pulseMessage) : ResultBuilder.createGemFireErrorResult(CliStrings.START_PULSE__URL__NOTFOUND)); } @@ -2314,8 +2209,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { .format(CliStrings.GFSH_MUST_BE_CONNECTED_FOR_LAUNCHING_0, "GemFire Pulse")); } } - } catch (GemFireException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); } catch (Exception e) { return ResultBuilder.createShellClientErrorResult(e.getMessage()); } catch (VirtualMachineError e) { @@ -2373,7 +2266,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { try { String geodeHome = System.getenv("GEODE_HOME"); - assertState(!StringUtils.isBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE); + assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE); assertState(IOUtils.isExistingPathname(getPathToVsd()), String.format(CliStrings.START_VSD__NOT_FOUND_ERROR_MESSAGE, geodeHome)); @@ -2393,19 +2286,14 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { InfoResultData infoResultData = ResultBuilder.createInfoResultData(); - if (!StringUtils.isBlank(vsdProcessOutput)) { + if (StringUtils.isNotBlank(vsdProcessOutput)) { infoResultData.addLine(StringUtils.LINE_SEPARATOR); infoResultData.addLine(vsdProcessOutput); } return ResultBuilder.buildResult(infoResultData); - } catch (GemFireException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (FileNotFoundException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (IllegalArgumentException e) { - return ResultBuilder.createShellClientErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (GemFireException | IllegalStateException | IllegalArgumentException + | FileNotFoundException e) { return ResultBuilder.createShellClientErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); @@ -2489,7 +2377,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { try { String geodeHome = System.getenv("GEODE_HOME"); - assertState(!StringUtils.isBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE); + assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE); if (isConnectedAndReady() && (getGfsh().getOperationInvoker() instanceof JmxOperationInvoker)) { @@ -2518,7 +2406,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { InfoResultData infoResultData = ResultBuilder.createInfoResultData(); - if (!StringUtils.isBlank(dataBrowserProcessOutput)) { + if (StringUtils.isNotBlank(dataBrowserProcessOutput)) { infoResultData.addLine(StringUtils.LINE_SEPARATOR); infoResultData.addLine(dataBrowserProcessOutput); } @@ -2528,9 +2416,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { return ResultBuilder.createUserErrorResult(CliStrings.format( CliStrings.GFSH_MUST_BE_CONNECTED_VIA_JMX_FOR_LAUNCHING_0, "GemFire DataBrowser")); } - } catch (IllegalArgumentException e) { - return ResultBuilder.createUserErrorResult(e.getMessage()); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException | IllegalStateException e) { return ResultBuilder.createUserErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e);
http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java index c9e79b0..ad344ff 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java @@ -20,11 +20,11 @@ import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_P import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import org.apache.commons.lang.StringUtils; import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.internal.ClassPathLoader; import org.apache.geode.internal.DSFIDFactory; import org.apache.geode.internal.lang.Initializer; -import org.apache.geode.internal.lang.StringUtils; import org.apache.geode.internal.lang.SystemUtils; import org.apache.geode.internal.util.IOUtils; import org.apache.geode.internal.util.PasswordUtil; @@ -181,7 +181,7 @@ public class ShellCommands implements CommandMarker { if (locatorResponseException != null) { String locatorResponseExceptionMessage = locatorResponseException.getMessage(); - locatorResponseExceptionMessage = (!StringUtils.isBlank(locatorResponseExceptionMessage) + locatorResponseExceptionMessage = (StringUtils.isNotBlank(locatorResponseExceptionMessage) ? locatorResponseExceptionMessage : locatorResponseException.toString()); exceptionMessage = "Exception caused JMX Manager startup to fail because: '" .concat(locatorResponseExceptionMessage).concat("'"); @@ -560,7 +560,7 @@ public class ShellCommands implements CommandMarker { try { KeyManagerFactory keyManagerFactory = null; - if (!StringUtils.isBlank(keystoreToUse)) { + if (StringUtils.isNotBlank(keystoreToUse)) { KeyStore clientKeys = KeyStore.getInstance("JKS"); keyStoreStream = new FileInputStream(keystoreToUse); clientKeys.load(keyStoreStream, keystorePasswordToUse.toCharArray()); @@ -572,7 +572,7 @@ public class ShellCommands implements CommandMarker { // load server public key TrustManagerFactory trustManagerFactory = null; - if (!StringUtils.isBlank(truststoreToUse)) { + if (StringUtils.isNotBlank(truststoreToUse)) { KeyStore serverPub = KeyStore.getInstance("JKS"); trustStoreStream = new FileInputStream(truststoreToUse); serverPub.load(trustStoreStream, truststorePasswordToUse.toCharArray()); @@ -622,7 +622,7 @@ public class ShellCommands implements CommandMarker { URL gfSecurityPropertiesUrl = null; // Case 1: User has specified gfSecurity properties file - if (!StringUtils.isBlank(gfSecurityPropertiesPathToUse)) { + if (StringUtils.isNotBlank(gfSecurityPropertiesPathToUse)) { // User specified gfSecurity properties doesn't exist if (!IOUtils.isExistingPathname(gfSecurityPropertiesPathToUse)) { gfshInstance http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java index 3fadd96..d1e3f9e 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/FilePathStringConverter.java @@ -14,7 +14,7 @@ */ package org.apache.geode.management.internal.cli.converters; -import org.apache.geode.internal.lang.StringUtils; +import org.apache.commons.lang.StringUtils; import org.apache.geode.management.cli.ConverterHint; import org.springframework.shell.core.Completion; import org.springframework.shell.core.Converter; http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java index 59851da..20b37b3 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/GatewaySenderIdConverter.java @@ -14,20 +14,19 @@ */ package org.apache.geode.management.internal.cli.converters; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - import org.apache.geode.management.cli.ConverterHint; import org.apache.geode.management.internal.ManagementConstants; import org.apache.geode.management.internal.cli.shell.Gfsh; - import org.springframework.shell.core.Completion; import org.springframework.shell.core.Converter; import org.springframework.shell.core.MethodTarget; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + /** * * @since GemFire 7.0 @@ -64,7 +63,7 @@ public class GatewaySenderIdConverter implements Converter<String> { Gfsh gfsh = Gfsh.getCurrentInstance(); if (gfsh != null && gfsh.isConnectedAndReady()) { final String[] gatewaySenderIdArray = (String[]) gfsh.getOperationInvoker().invoke( - ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN, "listGatwaySenders", + ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN, "listGatewaySenders", new Object[0], new String[0]); if (gatewaySenderIdArray != null && gatewaySenderIdArray.length != 0) { gatewaySenderIds = new TreeSet<String>(Arrays.asList(gatewaySenderIdArray)); http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java index b5d1b0c..d1a1107 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/DiskStoreDetails.java @@ -15,6 +15,11 @@ package org.apache.geode.management.internal.cli.domain; +import org.apache.commons.lang.StringUtils; +import org.apache.geode.cache.DiskStoreFactory; +import org.apache.geode.internal.lang.MutableIdentifiable; +import org.apache.geode.internal.lang.ObjectUtils; + import java.io.Serializable; import java.util.Collection; import java.util.Collections; @@ -23,11 +28,6 @@ import java.util.Set; import java.util.TreeSet; import java.util.UUID; -import org.apache.geode.cache.DiskStoreFactory; -import org.apache.geode.internal.lang.MutableIdentifiable; -import org.apache.geode.internal.lang.ObjectUtils; -import org.apache.geode.internal.lang.StringUtils; - /** * The DiskStoreDetails class captures information about a particular disk store for a GemFire * distributed system member. Each disk store for a member should be captured in separate instance http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java index 64bb512..335302e 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/IndexDetails.java @@ -15,13 +15,13 @@ package org.apache.geode.management.internal.cli.domain; -import java.io.Serializable; - +import org.apache.commons.lang.StringUtils; import org.apache.geode.cache.query.Index; import org.apache.geode.cache.query.IndexStatistics; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.internal.lang.ObjectUtils; -import org.apache.geode.internal.lang.StringUtils; + +import java.io.Serializable; /** * The IndexDetails class encapsulates information for an Index on a Region in the GemFire Cache. @@ -91,11 +91,11 @@ public class IndexDetails implements Comparable<IndexDetails>, Serializable { } public IndexDetails(final String memberId, final String regionPath, final String indexName) { - assertValidArgument(!StringUtils.isBlank(memberId), + assertValidArgument(StringUtils.isNotBlank(memberId), "The member having a region with an index must be specified!"); - assertValidArgument(!StringUtils.isBlank(regionPath), + assertValidArgument(StringUtils.isNotBlank(regionPath), "The region in member (%1$s) with an index must be specified!", memberId); - assertValidArgument(!StringUtils.isBlank(indexName), + assertValidArgument(StringUtils.isNotBlank(indexName), "The name of the index on region (%1$s) of member (%2$s) must be specified!", regionPath, memberId); this.memberId = memberId; @@ -307,7 +307,7 @@ public class IndexDetails implements Comparable<IndexDetails>, Serializable { } IndexType(final String description) { - assertValidArgument(!StringUtils.isBlank(description), + assertValidArgument(StringUtils.isNotBlank(description), "The description for the IndexType must be specified!"); this.description = description; } http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java index 4c241d0..68cc2e0 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DescribeDiskStoreFunction.java @@ -15,11 +15,7 @@ package org.apache.geode.management.internal.cli.functions; -import java.io.File; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - +import org.apache.commons.lang.StringUtils; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.DataPolicy; @@ -35,14 +31,17 @@ import org.apache.geode.distributed.DistributedMember; import org.apache.geode.internal.InternalEntity; import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.lang.ObjectUtils; -import org.apache.geode.internal.lang.StringUtils; import org.apache.geode.internal.logging.LogService; import org.apache.geode.internal.util.ArrayUtils; import org.apache.geode.management.internal.cli.domain.DiskStoreDetails; import org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException; - import org.apache.logging.log4j.Logger; +import java.io.File; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + /** * The DescribeDiskStoreFunction class is an implementation of a GemFire Function used to collect * information and details about a particular disk store for a particular GemFire distributed system http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java index 57d209b..c688d7a 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction.java @@ -14,6 +14,7 @@ */ package org.apache.geode.management.internal.cli.functions; +import org.apache.commons.lang.StringUtils; import org.apache.geode.cache.execute.FunctionAdapter; import org.apache.geode.cache.execute.FunctionContext; import org.apache.geode.distributed.DistributedMember; @@ -21,7 +22,6 @@ import org.apache.geode.distributed.internal.InternalLocator; import org.apache.geode.internal.InternalEntity; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.internal.cache.InternalCache; -import org.apache.geode.internal.lang.StringUtils; import org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus; public class FetchSharedConfigurationStatusFunction extends FunctionAdapter http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java index c99f84a..0811931 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java @@ -14,12 +14,7 @@ */ package org.apache.geode.management.internal.cli.functions; -import java.util.Set; - -import org.apache.geode.internal.ClassPathLoader; -import org.apache.geode.internal.lang.StringUtils; -import org.apache.logging.log4j.Logger; - +import org.apache.commons.lang.StringUtils; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.CacheListener; @@ -38,6 +33,7 @@ import org.apache.geode.cache.execute.FunctionAdapter; import org.apache.geode.cache.execute.FunctionContext; import org.apache.geode.cache.execute.ResultSender; import org.apache.geode.compression.Compressor; +import org.apache.geode.internal.ClassPathLoader; import org.apache.geode.internal.InternalEntity; import org.apache.geode.internal.cache.xmlcache.CacheXml; import org.apache.geode.internal.i18n.LocalizedStrings; @@ -48,6 +44,9 @@ import org.apache.geode.management.internal.cli.exceptions.CreateSubregionExcept import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.util.RegionPath; import org.apache.geode.management.internal.configuration.domain.XmlEntity; +import org.apache.logging.log4j.Logger; + +import java.util.Set; /** * http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java index 4383044..78879d3 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/HelpBlock.java @@ -14,7 +14,7 @@ */ package org.apache.geode.management.internal.cli.help; -import org.apache.geode.internal.lang.StringUtils; +import org.apache.commons.lang.StringUtils; import org.apache.geode.management.internal.cli.GfshParser; import org.apache.geode.management.internal.cli.shell.Gfsh; @@ -33,7 +33,7 @@ public class HelpBlock { public HelpBlock() {} public HelpBlock(String data) { - if (!StringUtils.isBlank(data)) { + if (StringUtils.isNotBlank(data)) { this.data = data; this.level = 0; } http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java index 9dbf59c..3525013 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/help/Helper.java @@ -231,7 +231,7 @@ public class Helper { } // Now comes the turn to display synopsis if any - if (!StringUtils.isBlank(cliCommand.help())) { + if (StringUtils.isNotBlank(cliCommand.help())) { HelpBlock synopsis = new HelpBlock(SYNOPSIS_NAME); synopsis.addChild(new HelpBlock(cliCommand.help())); root.addChild(synopsis); @@ -259,7 +259,7 @@ public class Helper { HelpBlock getOptionDetail(CliOption cliOption) { HelpBlock optionNode = new HelpBlock(getPrimaryKey(cliOption)); String help = cliOption.help(); - optionNode.addChild(new HelpBlock((!StringUtils.isBlank(help) ? help : ""))); + optionNode.addChild(new HelpBlock((StringUtils.isNotBlank(help) ? help : ""))); if (getSynonyms(cliOption).size() > 0) { StringBuilder builder = new StringBuilder(); for (String string : getSynonyms(cliOption)) { http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java index 9bd2bf9..6332540 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/ResultBuilder.java @@ -14,15 +14,13 @@ */ package org.apache.geode.management.internal.cli.result; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - import org.apache.geode.management.cli.Result; import org.apache.geode.management.internal.cli.json.GfJsonException; import org.apache.geode.management.internal.cli.json.GfJsonObject; +import java.util.Collection; +import java.util.List; + /** * * @@ -170,7 +168,7 @@ public class ResultBuilder { } public static <T extends CliJsonSerializable> ObjectResultData<T> createObjectResultData() { - return new ObjectResultData<T>(); + return new ObjectResultData<>(); } // public static CatalogedResultData createCatalogedResultData() { @@ -228,13 +226,13 @@ public class ResultBuilder { * Bad Response. */ public static Result fromJson(String json) { - Result result = null; + Result result; try { GfJsonObject jsonObject = new GfJsonObject(json); String contentType = jsonObject.getString("contentType"); GfJsonObject data = jsonObject.getJSONObject("data"); - AbstractResultData resultData = null; + AbstractResultData resultData; if (ResultData.TYPE_TABULAR.equals(contentType)) { resultData = new TabularResultData(data); } /* @@ -247,7 +245,7 @@ public class ResultBuilder { } else if (ResultData.TYPE_COMPOSITE.equals(contentType)) { resultData = new CompositeResultData(data); } else if (ResultData.TYPE_OBJECT.equals(contentType)) { - resultData = new ObjectResultData<CliJsonSerializable>(data); + resultData = new ObjectResultData<>(data); } else { ErrorResultData errorResultData = new ErrorResultData(); errorResultData.addLine("Can not detect result type, unknown response format: " + json); @@ -284,7 +282,7 @@ public class ResultBuilder { * @return Read only ResultData of the same type */ static ResultData getReadOnlyResultData(ResultData resultData) { - ResultData wrapperResultData = null; + ResultData wrapperResultData; String contentType = resultData.getType(); if (ResultData.TYPE_TABULAR.equals(contentType)) { wrapperResultData = new TabularResultData(resultData.getGfJsonObject()) { http://git-wip-us.apache.org/repos/asf/geode/blob/d16d192b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java index da3c4ae..ff23512 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/TableBuilder.java @@ -53,12 +53,12 @@ package org.apache.geode.management.internal.cli.result; * * @since GemFire 7.0 */ +import org.apache.commons.lang.StringUtils; +import org.apache.geode.management.internal.cli.GfshParser; + import java.util.ArrayList; import java.util.List; -import org.apache.geode.management.internal.cli.GfshParser; -import org.apache.geode.management.internal.cli.shell.Gfsh; - public class TableBuilder { public static Table newTable() { @@ -66,7 +66,7 @@ public class TableBuilder { } public static class Table { - private final List<RowGroup> rowGroups = new ArrayList<RowGroup>(); + private final List<RowGroup> rowGroups = new ArrayList<>(); private String columnSeparator = " "; private boolean isTabularResult = false; @@ -138,7 +138,7 @@ public class TableBuilder { } public String buildTable() { - StringBuffer stringBuffer = new StringBuffer(); + StringBuilder stringBuffer = new StringBuilder(); for (RowGroup rowGroup : this.rowGroups) { stringBuffer.append(rowGroup.buildRowGroup(isTabularResult)); } @@ -147,7 +147,7 @@ public class TableBuilder { } public List<String> buildTableList() { - List<String> list = new ArrayList<String>(); + List<String> list = new ArrayList<>(); for (RowGroup rowGroup : this.rowGroups) { list.add(rowGroup.buildRowGroup(isTabularResult)); } @@ -169,7 +169,7 @@ public class TableBuilder { */ public static class RowGroup { private final Table table; - private final List<Row> rows = new ArrayList<Row>(); + private final List<Row> rows = new ArrayList<>(); private int[] colSizes; private String columnSeparator; @@ -202,11 +202,11 @@ public class TableBuilder { public String buildRowGroup(boolean isTabularResult) { this.colSizes = computeColSizes(isTabularResult); - StringBuffer stringBuffer = new StringBuffer(); + StringBuilder stringBuffer = new StringBuilder(); for (Row row : rows) { String builtRow = row.buildRow(isTabularResult); stringBuffer.append(builtRow); - if (!builtRow.trim().isEmpty() || row.isBlank) { + if (StringUtils.isNotBlank(builtRow) || row.isBlank) { stringBuffer.append(GfshParser.LINE_SEPARATOR); } } @@ -275,7 +275,7 @@ public class TableBuilder { public static class Row { private final RowGroup rowGroup; private final Character rowSeparator; - private final List<Column> columns = new ArrayList<Column>(); + private final List<Column> columns = new ArrayList<>(); boolean isBlank; private boolean isTablewideSeparator; @@ -335,7 +335,7 @@ public class TableBuilder { } private String buildRow(boolean isTabularResult) { - StringBuffer stringBuffer = new StringBuffer(); + StringBuilder stringBuffer = new StringBuilder(); if (this.rowSeparator != null) { if (isTablewideSeparator) { int maxColLength = this.rowGroup.getTable().getMaxLength(); @@ -383,8 +383,8 @@ public class TableBuilder { } private static enum Align { - LEFT, RIGHT, CENTER; - }; + LEFT, RIGHT, CENTER + } private static class Column { @@ -411,7 +411,7 @@ public class TableBuilder { // This can happen because colSizes are re-computed // to fit the screen width if (this.stringValue.length() > colWidth) { - StringBuffer stringBuffer = new StringBuffer(); + StringBuilder stringBuffer = new StringBuilder(); int endIndex = colWidth - 2; if (endIndex < 0) return ""; @@ -422,7 +422,7 @@ public class TableBuilder { if (trimIt) numSpaces = 0; - StringBuffer stringBuffer = new StringBuffer(); + StringBuilder stringBuffer = new StringBuilder(); switch (align) { case LEFT:
