You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2016/08/30 02:21:29 UTC
[1/5] incubator-geode git commit: GEODE-1809: Refactor GemFireVersion
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-420 a455526b8 -> 7272c6444
GEODE-1809: Refactor GemFireVersion
Clean up dead / broken / unused code and reduce the visible
API methods. Store the version info as a Map to allow it to be
extended more easily. Move scm info into utilities.gradle.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/93985f96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/93985f96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/93985f96
Branch: refs/heads/feature/GEODE-420
Commit: 93985f96fe5eca16ad301aa09f1719bc213b6034
Parents: 98531a1
Author: Anthony Baker <ab...@apache.org>
Authored: Tue Aug 23 14:32:16 2016 -0700
Committer: Anthony Baker <ab...@apache.org>
Committed: Thu Aug 25 10:00:52 2016 -0700
----------------------------------------------------------------------
build.gradle | 1 -
geode-core/build.gradle | 33 -
.../distributed/internal/StartupMessage.java | 14 -
.../gemfire/internal/GemFireVersion.java | 726 +++++--------------
.../gemstone/gemfire/internal/SystemAdmin.java | 10 +-
.../internal/GemFireVersionJUnitTest.java | 75 +-
.../gemfire/internal/VersionJUnitTest.java | 50 ++
gradle/utilities.gradle | 43 ++
8 files changed, 275 insertions(+), 677 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index eac68d0..e112eb7 100755
--- a/build.gradle
+++ b/build.gradle
@@ -22,7 +22,6 @@ buildscript {
dependencies {
classpath "gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.0"
- classpath "org.ajoberstar:gradle-git:1.3.2"
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1'
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/geode-core/build.gradle
----------------------------------------------------------------------
diff --git a/geode-core/build.gradle b/geode-core/build.gradle
index 1d5ad4a..ea1fce2 100755
--- a/geode-core/build.gradle
+++ b/geode-core/build.gradle
@@ -133,39 +133,6 @@ sourceSets {
}
}
-ext.readScmInfo = {
- try {
- def git = org.ajoberstar.grgit.Grgit.open(currentDir: projectDir)
- try {
- return [
- 'Source-Repository': git.branch.getCurrent().name,
- 'Source-Revision' : git.head().id,
- 'Source-Date' : git.head().getDate().format('yyyy-MM-dd HH:mm:ss Z')
- ] as Properties
- } finally {
- git.close()
- }
- } catch (IllegalArgumentException e) {
- // if we're building from the source distribution, we don't have git so
- // use cached info written during the assembly process
- def buildInfo = file "$rootDir/.buildinfo"
- if (buildInfo.exists()) {
- def props = new Properties()
- new FileInputStream(buildInfo).withStream { fis ->
- props.load(fis)
- }
- return props
- }
-
- logger.warn( '***** Unable to find Git workspace. Using default version information *****' )
- return [
- 'Source-Repository': 'UNKNOWN',
- 'Source-Revision' : 'UNKNOWN',
- 'Source-Date' : new Date().format('yyyy-MM-dd HH:mm:ss Z')
- ] as Properties
- }
-}
-
// Creates the version properties file and writes it to the classes dir
task createVersionPropertiesFile {
def propertiesFile = file(generatedResources + "/com/gemstone/gemfire/internal/GemFireVersion.properties");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/StartupMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/StartupMessage.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/StartupMessage.java
index 82f5c88..7b6d853 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/StartupMessage.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/StartupMessage.java
@@ -178,20 +178,6 @@ public final class StartupMessage extends HighPriorityDistributionMessage implem
String myVersion = GemFireVersion.getGemFireVersion();
String theirVersion = this.version;
- int myMajorVersion = GemFireVersion.getMajorVersion(myVersion);
- int theirMajorVersion = GemFireVersion.getMajorVersion(theirVersion);
- int myMinorVersion = GemFireVersion.getMinorVersion(myVersion);
- int theirMinorVersion = GemFireVersion.getMinorVersion(theirVersion);
- // fix for bug 43608
- if (myMajorVersion != theirMajorVersion || myMinorVersion != theirMinorVersion) {
- // now don't reject at this level since it will be handled at
- // JGroups/Connection handshake level
- /*
- rejectionMessage =
- LocalizedStrings.StartupMessage_REJECTED_NEW_SYSTEM_NODE_0_WITH_PRODUCT_VERSION_1_BECAUSE_THE_EXISTING_DISTRIBUTED_SYSTEM_NODE_2_HAS_A_PRODUCT_VERSION_OF_3
- .toLocalizedString(new Object[] {getSender(), this.version, dm.getId(), GemFireVersion.getGemFireVersion()});
- */
- }
if (dm.getTransport().isMcastEnabled() != isMcastEnabled) {
rejectionMessage =
LocalizedStrings.StartupMessage_REJECTED_NEW_SYSTEM_NODE_0_BECAUSE_ISMCASTENABLED_1_DOES_NOT_MATCH_THE_DISTRIBUTED_SYSTEM_IT_IS_ATTEMPTING_TO_JOIN
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
index baf03b1..9bd3d4f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
@@ -16,335 +16,101 @@
*/
package com.gemstone.gemfire.internal;
+import java.io.File;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import com.gemstone.gemfire.InternalGemFireError;
import com.gemstone.gemfire.SystemFailure;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
/**
* This class provides build and version information about GemFire.
* It gathers this information from the resource property file
* for this class.
*/
public class GemFireVersion {
-
private static String RESOURCE_NAME = "GemFireVersion.properties";
-
- /** The singleton instance */
- private static GemFireVersion instance;
-
- /** Constant for the GemFire version Resource Property entry */
- private static final String PRODUCT_NAME = "Product-Name";
-
- /** Constant for the GemFire version Resource Property entry */
- private static final String GEMFIRE_VERSION = "Product-Version";
-
- /** Constant for the source code date Resource Property entry */
- private static final String SOURCE_DATE = "Source-Date";
-
- /** Constant for the source code revision Resource Property entry */
- private static final String SOURCE_REVISION = "Source-Revision";
-
- /** Constant for the source code repository Resource Property entry */
- private static final String SOURCE_REPOSITORY = "Source-Repository";
-
- /** Constant for the build date Resource Property entry */
- private static final String BUILD_DATE = "Build-Date";
-
- /** Constant for the build id Resource Property entry */
- private static final String BUILD_ID = "Build-Id";
-
- /** Constant for the build Java version Resource Property entry */
- private static final String BUILD_PLATFORM = "Build-Platform";
-
- /** Constant for the build Java version Resource Property entry */
- private static final String BUILD_JAVA_VERSION = "Build-Java-Version";
-
- //////////////////// Instance Fields ////////////////////
-
- /** Error message to display instead of the version information */
- private String error = null;
-
- /** The name of this product */
- private String productName;
-
- /** This product's version */
- private String gemfireVersion;
-
- /** The version of GemFire native code library */
- private String nativeVersion;
-
- /** The date that the source code for GemFire was last updated */
- private String sourceDate;
- /** The revision of the source code used to build GemFire */
- private String sourceRevision;
-
- /** The repository in which the source code for GemFire resides */
- private String sourceRepository;
-
- /** The date on which GemFire was built */
- private String buildDate;
-
- /** The ID of the GemFire build */
- private String buildId;
-
- /** The platform on which GemFire was built */
- private String buildPlatform;
-
- /** The version of Java that was used to build GemFire */
- private String buildJavaVersion;
+ /** The singleton instance */
+ private static VersionDescription description;
- //////////////////// Static Methods ////////////////////
+ private GemFireVersion() {
+ }
- /**
- * Returns (or creates) the singleton instance of this class
- */
- private static GemFireVersion getInstance() {
- if (instance == null) {
- instance = new GemFireVersion();
+ private static synchronized VersionDescription getDescription() {
+ if (description == null) {
+ String name = GemFireVersion.class.getPackage().getName()
+ .replace('.', '/') + "/" + RESOURCE_NAME;
+ description = new VersionDescription(name);
}
-
- return instance;
+ return description;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(asString());
}
- /**
- * Returns the name of this product
- */
public static String getProductName() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.productName;
- }
+ return getDescription().getProperty(VersionDescription.PRODUCT_NAME);
}
- /**
- * Returns the version of GemFire being used
- */
public static String getGemFireVersion() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.gemfireVersion;
- }
- }
-
- private static String stripSpaces(String s) {
- StringBuffer result = new StringBuffer(s);
- while (result.charAt(0) == ' ') {
- result.deleteCharAt(0);
- }
- while (result.charAt(result.length()-1) == ' ') {
- result.deleteCharAt(result.length()-1);
- }
- return result.toString();
- }
-
- /**
- * Returns the version of GemFire native code library being used
- */
- public static String getNativeCodeVersion() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.nativeVersion;
- }
- }
- public static String getJavaCodeVersion() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- StringBuffer result = new StringBuffer(80);
- result.append(GemFireVersion.getGemFireVersion())
- .append(' ')
- .append(GemFireVersion.getBuildId())
- .append(' ')
- .append(GemFireVersion.getBuildDate())
- .append(" javac ")
- .append(GemFireVersion.getBuildJavaVersion());
- return result.toString();
- }
+ return getDescription().getProperty(VersionDescription.GEMFIRE_VERSION);
}
- /**
- * Returns the date of the source code from which GemFire was built
- */
public static String getSourceDate() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.sourceDate;
- }
+ return getDescription().getProperty(VersionDescription.SOURCE_DATE);
}
- /**
- * Returns the revision of the source code on which GemFire was
- * built.
- *
- * @since GemFire 4.0
- */
- public static String getSourceRevision() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.sourceRevision;
- }
- }
-
- /**
- * Returns the source code repository from which GemFire was built.
- *
- * @since GemFire 4.0
- */
public static String getSourceRepository() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.sourceRepository;
- }
+ return getDescription().getProperty(VersionDescription.SOURCE_REPOSITORY);
}
- /**
- * Returns the date on which GemFire was built
- */
- public static String getBuildDate() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.buildDate;
- }
+ public static String getSourceRevision() {
+ return getDescription().getProperty(VersionDescription.SOURCE_REVISION);
}
- /**
- * Returns the id of the GemFire build
- */
public static String getBuildId() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
+ return getDescription().getProperty(VersionDescription.BUILD_ID);
+ }
- } else {
- return v.buildId;
- }
+ public static String getBuildDate() {
+ return getDescription().getProperty(VersionDescription.BUILD_DATE);
}
- /**
- * Returns the platform on which GemFire was built
- */
public static String getBuildPlatform() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.buildPlatform;
- }
+ return getDescription().getProperty(VersionDescription.BUILD_PLATFORM);
}
- /**
- * Returns the version of Java used to build GemFire
- */
public static String getBuildJavaVersion() {
- GemFireVersion v = getInstance();
- if (v.error != null) {
- return v.error;
-
- } else {
- return v.buildJavaVersion;
- }
+ return getDescription().getProperty(VersionDescription.BUILD_JAVA_VERSION);
}
- //////////////////// Constructors ////////////////////
+ public static String getGemFireJarFileName() {
+ return "geode-core-" + GemFireVersion.getGemFireVersion() +".jar";
+ }
- /**
- * Private constructor that read the resource properties
- * and extracts interesting pieces of information from it
- */
- private GemFireVersion() {
- String name =
- GemFireVersion.class.getPackage().getName().replace('.', '/');
- name = name + "/" + RESOURCE_NAME;
-
- InputStream is = ClassPathLoader.getLatest().getResourceAsStream(getClass(), name);
- if (is == null) {
- error = LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0.toLocalizedString(RESOURCE_NAME);
- return;
- }
- Properties props = new Properties();
- try {
- props.load(is);
- } catch (Exception ex) {
- error = LocalizedStrings.GemFireVersion_COULD_NOT_READ_PROPERTIES_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0_BECAUSE_1.toLocalizedString(new Object[] {RESOURCE_NAME, ex});
- return;
- }
+ public static void print(PrintWriter pw) {
+ getDescription().print(pw);
+ }
+
+ public static void print(PrintStream ps) {
+ print(new PrintWriter(ps, true));
+ }
- this.nativeVersion = SmHelper.getNativeVersion();
- this.productName = props.getProperty(PRODUCT_NAME);
- if (this.productName == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {PRODUCT_NAME, RESOURCE_NAME});
- return;
- }
- this.gemfireVersion = props.getProperty(GEMFIRE_VERSION);
- if (this.gemfireVersion == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {GEMFIRE_VERSION, RESOURCE_NAME});
- return;
- }
- this.sourceDate = props.getProperty(SOURCE_DATE);
- if (this.sourceDate == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {SOURCE_DATE, RESOURCE_NAME});
- return;
- }
- this.sourceRevision = props.getProperty(SOURCE_REVISION);
- if (this.sourceRevision == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {SOURCE_REVISION, RESOURCE_NAME});
- return;
- }
- this.sourceRepository = props.getProperty(SOURCE_REPOSITORY);
- if (this.sourceRepository == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {SOURCE_REPOSITORY, RESOURCE_NAME});
- return;
- }
- this.buildDate = props.getProperty(BUILD_DATE);
- if (this.buildDate == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_DATE, RESOURCE_NAME});
- return;
- }
- this.buildId = props.getProperty(BUILD_ID);
- if (this.buildId == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_ID, RESOURCE_NAME});
- return;
- }
- this.buildPlatform = props.getProperty(BUILD_PLATFORM);
- if (this.buildPlatform == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_PLATFORM, RESOURCE_NAME});
- return;
- }
- this.buildJavaVersion = props.getProperty(BUILD_JAVA_VERSION);
- if (this.buildJavaVersion == null) {
- error = LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_JAVA_VERSION, RESOURCE_NAME});
- return;
- }
+ public static String asString() {
+ StringWriter sw = new StringWriter(256);
+ PrintWriter pw = new PrintWriter(sw);
+ print(pw);
+ pw.flush();
+ return sw.toString();
}
/** Public method that returns the URL of the gemfire jar file */
@@ -385,293 +151,141 @@ public class GemFireVersion {
return csLoc;
}
- public static String getGemFireJarFileName() {
- return "geode-core-" + GemFireVersion.getGemFireVersion() +".jar";
- }
+ static class VersionDescription {
+ /** Constant for the GemFire version Resource Property entry */
+ static final String PRODUCT_NAME = "Product-Name";
- private final static String VER_FILE_NAME = "GemFireVersion.properties";
- private final static String JAR_VER_NAME = "gemfire-core-jar";
-
- public static void createVersionFile() {
- String jarVersion = stripSpaces(GemFireVersion.getJavaCodeVersion());
- File libDir = SystemAdmin.findGemFireLibDir();
- if (libDir == null) {
- throw new RuntimeException(LocalizedStrings.GemFireVersion_COULD_NOT_DETERMINE_PRODUCT_LIB_DIRECTORY.toLocalizedString());
- }
- File versionPropFile = new File(libDir, VER_FILE_NAME);
- Properties props = new Properties();
- props.setProperty(JAR_VER_NAME, jarVersion);
- try {
- FileOutputStream out = new FileOutputStream(versionPropFile);
- props.store(out, "Expected versions for this product build as of");
- out.close();
- } catch (IOException ex) {
- throw new RuntimeException(LocalizedStrings.GemFireVersion_COULD_NOT_WRITE_0_BECAUSE_1.toLocalizedString(new Object[] {versionPropFile, ex.toString()}));
- }
- System.out.println("Created \"" + versionPropFile + "\"");
- }
- /**
- * Encodes all available version information into a string and then
- * returns that string.
- */
- public static String asString() {
- StringWriter sw = new StringWriter(256);
- PrintWriter pw = new PrintWriter(sw);
- print(pw);
- pw.flush();
- return sw.toString();
- }
- /**
- * Prints all available version information (excluding source code
- * information) to the given <code>PrintWriter</code> in a
- * standard format.
- */
- public static void print(PrintWriter pw) {
- print(pw, true);
+ /** Constant for the GemFire version Resource Property entry */
+ static final String GEMFIRE_VERSION = "Product-Version";
+
+ /** Constant for the source code date Resource Property entry */
+ static final String SOURCE_DATE = "Source-Date";
+
+ /** Constant for the source code revision Resource Property entry */
+ static final String SOURCE_REVISION = "Source-Revision";
+
+ /** Constant for the source code repository Resource Property entry */
+ static final String SOURCE_REPOSITORY = "Source-Repository";
+
+ /** Constant for the build date Resource Property entry */
+ static final String BUILD_DATE = "Build-Date";
+
+ /** Constant for the build id Resource Property entry */
+ static final String BUILD_ID = "Build-Id";
+
+ /** Constant for the build Java version Resource Property entry */
+ static final String BUILD_PLATFORM = "Build-Platform";
+
+ /** Constant for the build Java version Resource Property entry */
+ static final String BUILD_JAVA_VERSION = "Build-Java-Version";
+
+ /** the version properties */
+ private final Properties description;
+
+ /** Error message to display instead of the version information */
+ private final String error;
+
+ public VersionDescription(String name) {
+ InputStream is = ClassPathLoader.getLatest().getResourceAsStream(getClass(), name);
+ if (is == null) {
+ error = LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0.toLocalizedString(RESOURCE_NAME);
+ description = null;
+ return;
+ }
+
+ description = new Properties();
+ try {
+ description.load(is);
+ } catch (Exception ex) {
+ error = LocalizedStrings.GemFireVersion_COULD_NOT_READ_PROPERTIES_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0_BECAUSE_1.toLocalizedString(new Object[] {RESOURCE_NAME, ex});
+ return;
+ }
+ error = validate();
}
- /**
- * Prints all available version information to the given
- * <code>PrintWriter</code> in a standard format.
- *
- * @param printSourceInfo
- * Should information about the source code be printed?
- */
- public static void print(PrintWriter pw,
- boolean printSourceInfo) {
- String jarVersion = stripSpaces(GemFireVersion.getJavaCodeVersion());
- pw.println("Java version: " + jarVersion);
- String libVersion = stripSpaces(GemFireVersion.getNativeCodeVersion());
- pw.println("Native version: " + libVersion);
- File libDir = SystemAdmin.findGemFireLibDir();
- if (libDir != null) {
- File versionPropFile = new File(libDir, VER_FILE_NAME);
- if (versionPropFile.exists()) {
- try {
- Properties props = new Properties();
- FileInputStream inStream = new FileInputStream(versionPropFile);
- try {
- props.load(inStream);
- }
- finally {
- inStream.close();
- }
- String expectedJarVersion = props.getProperty(JAR_VER_NAME);
- if (expectedJarVersion != null) {
- if (!expectedJarVersion.equals(jarVersion)) {
- pw.println(LocalizedStrings.GemFireVersion_WARNING_EXPECTED_JAVA_VERSION_0.toLocalizedString(expectedJarVersion));
- }
- }
- } catch (IOException ex) {
- pw.println(LocalizedStrings.GemFireVersion_WARNING_FAILED_TO_READ_0_BECAUSE_1.toLocalizedString(new Object[] {versionPropFile, ex}));
- }
-// } else {
-// pw.println(LocalizedStrings.GemFireVersion_WARNING_COULD_NOT_FIND_0.toLocalizedString(versionPropFile));
- }
-// } else {
-// pw.println(LocalizedStrings.GemFireVersion_WARNING_COULD_NOT_DETERMINE_THE_PRODUCTS_LIB_DIRECTORY.toLocalizedString());
- }
-
- if (printSourceInfo) {
- String sourceRevision = GemFireVersion.getSourceRevision();
- pw.println("Source revision: " + sourceRevision);
-
- String sourceRepository =
- GemFireVersion.getSourceRepository();
- pw.println("Source repository: " + sourceRepository);
- }
-
- InetAddress host = null;
- try {
- host = SocketCreator.getLocalHost();
- }
- catch (VirtualMachineError err) {
- SystemFailure.initiateFailure(err);
- // If this ever returns, rethrow the error. We're poisoned
- // now, so don't let this thread continue.
- throw err;
- }
- catch (Throwable t) {
- // Whenever you catch Error or Throwable, you must also
- // catch VirtualMachineError (see above). However, there is
- // _still_ a possibility that you are dealing with a cascading
- // error condition, so you also need to check to see if the JVM
- // is still usable:
- SystemFailure.checkFailure();
- }
- int cpuCount = Runtime.getRuntime().availableProcessors();
- pw.println(LocalizedStrings.GemFireVersion_RUNNING_ON_0.toLocalizedString(
- host
- + ", " + cpuCount + " cpu(s)"
- + ", " + System.getProperty("os.arch")
- + " " + System.getProperty("os.name")
- + " " + System.getProperty("os.version")
- ));
+ public String getProperty(String key) {
+ if (error != null) {
+ return error;
+ }
+ return description.getProperty(key);
}
-
- /**
- * Prints all available version information (excluding information
- * about the source code) to the given <code>PrintStream</code> in
- * a standard format.
- */
- public static void print(PrintStream ps) {
- print(ps, true);
+
+ public String getNativeCodeVersion() {
+ return SmHelper.getNativeVersion();
}
+
+ private void print(PrintWriter pw) {
+ for (Entry<?,?> props : description.entrySet()) {
+ pw.println(props.getKey() + ": " + props.getValue());
+ }
- /**
- * Prints all available version information to the given
- * <code>PrintStream</code> in a standard format.
- *
- * @param printSourceInfo
- * Should information about the source code be printed?
- */
- public static void print(PrintStream ps,
- boolean printSourceInfo) {
- PrintWriter pw = new PrintWriter(ps);
- print(pw, printSourceInfo);
- pw.flush();
+ // not stored in the description map
+ pw.println("Native version: " + getNativeCodeVersion());
+ printHostInfo(pw);
+ }
+
+ private void printHostInfo(PrintWriter pw)
+ throws InternalGemFireError, Error, VirtualMachineError {
+ try {
+ StringBuffer sb = new StringBuffer(SocketCreator.getLocalHost().toString())
+ .append(", ")
+ .append(Runtime.getRuntime().availableProcessors()).append(" cpu(s), ")
+ .append(System.getProperty("os.arch")).append(' ')
+ .append(System.getProperty("os.name")).append(' ')
+ .append(System.getProperty("os.version")).append(' ');
+ pw.println(LocalizedStrings.GemFireVersion_RUNNING_ON_0.toLocalizedString(sb.toString()));
+ } catch (VirtualMachineError err) {
+ SystemFailure.initiateFailure(err);
+ // If this ever returns, rethrow the error. We're poisoned
+ // now, so don't let this thread continue.
+ throw err;
+ } catch (Throwable t) {
+ // Whenever you catch Error or Throwable, you must also
+ // catch VirtualMachineError (see above). However, there is
+ // _still_ a possibility that you are dealing with a cascading
+ // error condition, so you also need to check to see if the JVM
+ // is still usable:
+ SystemFailure.checkFailure();
+ }
}
-
- /////////////////////// Main Program ////////////////////
-// private static final PrintStream out = System.out;
-// private static final PrintStream err = System.err;
+ private String validate() {
+ if (getProperty(PRODUCT_NAME) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {PRODUCT_NAME, RESOURCE_NAME});
+ }
- /**
- * Populates the gemfireVersion.properties file
- */
- public static void main(String[] args) {
- print(System.out);
- }
+ if (getProperty(GEMFIRE_VERSION) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {GEMFIRE_VERSION, RESOURCE_NAME});
+ }
- private static final Pattern MAJOR_MINOR = Pattern.compile("(\\d+)\\.(\\d*)(.*)");
- private static final Pattern RELEASE = Pattern.compile("\\.(\\d*)(.*)");
- private static final Pattern MAJOR_MINOR_RELEASE = Pattern.compile("(\\d+)\\.(\\d*)\\.(\\d*)(.*)");
-
- public static int getMajorVersion(String v) {
- int majorVersion = 0;
- Matcher m = MAJOR_MINOR.matcher(v);
- if (m.matches()) {
- String digits = m.group(1);
- if (digits != null && digits.length() > 0) {
- majorVersion = Integer.decode(digits).intValue();
+ if (getProperty(SOURCE_DATE) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {SOURCE_DATE, RESOURCE_NAME});
}
- }
- return majorVersion;
- }
- public static int getMinorVersion(String v) {
- int minorVersion = 0;
- Matcher m = MAJOR_MINOR.matcher(v);
- if (m.matches()) {
- String digits = m.group(2);
- if (digits != null && digits.length() > 0) {
- minorVersion = Integer.decode(digits).intValue();
+ if (getProperty(SOURCE_REVISION) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {SOURCE_REVISION, RESOURCE_NAME});
}
- }
- return minorVersion;
- }
- public static int getRelease(String v) {
- int release = 0;
- Matcher m = MAJOR_MINOR.matcher(v);
- if (m.matches()) {
- String others = m.group(3);
- Matcher r = RELEASE.matcher(others);
- if (r.matches()) {
- String digits = r.group(1);
- if (digits != null && digits.length() > 0) {
- try {
- release = Integer.decode(digits).intValue();
- } catch (NumberFormatException e) {
- release = 0;
- }
- }
+ if (getProperty(SOURCE_REPOSITORY) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {SOURCE_REPOSITORY, RESOURCE_NAME});
}
- }
- return release;
- }
-
- public static int getBuild(String v) {
- int build = 0;
- Matcher m = MAJOR_MINOR_RELEASE.matcher(v);
- if (m.matches()) {
- String buildStr = m.group(4);
- Matcher b = RELEASE.matcher(buildStr);
- if (b.matches()) {
- String digits = b.group(1);
- if (digits != null && digits.length() > 0) {
- try {
- build = Integer.decode(digits).intValue();
- } catch (NumberFormatException e) {
- build = 0;
- }
- }
+
+ if (getProperty(BUILD_DATE) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_DATE, RESOURCE_NAME});
}
- }
- return build;
- }
-
- /**
- * Compare version's sections major, minor, release one by one
- *
- * @return >0: v1 is newer than v2
- * 0: same
- * <0: v1 is older than v2
- * @deprecated please use the {@link Version} class to read the version
- * of the local member and compare versions for backwards compatibility
- * purposes. see also {@link SerializationVersions} for how to make backwards
- * compatible messages.
- */
- public static int compareVersions(String v1, String v2) {
- return compareVersions(v1, v2, true);
- }
-
- /*
- * Compare version's sections major, minor, release one by one
- *
- * @param v1 the first version
- * @param v2 the second version
- * @param includeBuild whether to also compare the build numbers
- *
- * @return: >0: v1 is newer than v2
- * 0: same
- * <0: v1 is older than v2
- */
- public static int compareVersions(String v1, String v2, boolean includeBuild) {
- int major1, minor1, release1, build1;
- int major2, minor2, release2, build2;
-
- if (v1 == null && v2 != null) return -1;
- if (v1 != null && v2 == null) return 1;
- if (v1 == null && v2 == null) return 0;
-
- major1 = getMajorVersion(v1);
- major2 = getMajorVersion(v2);
-
- minor1 = getMinorVersion(v1);
- minor2 = getMinorVersion(v2);
-
- release1 = getRelease(v1);
- release2 = getRelease(v2);
- if (major1 > major2) return 1;
- if (major1 < major2) return -1;
-
- if (minor1 > minor2) return 1;
- if (minor1 < minor2) return -1;
+ if (getProperty(BUILD_ID) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_ID, RESOURCE_NAME});
+ }
- if (release1 > release2) return 1;
- if (release1 < release2) return -1;
-
- if (includeBuild) {
- build1 = getBuild(v1);
- build2 = getBuild(v2);
-
- if (build1 > build2) return 1;
- if (build1 < build2) return -1;
- }
+ if (getProperty(BUILD_PLATFORM) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_PLATFORM, RESOURCE_NAME});
+ }
- return 0;
+ if (getProperty(BUILD_JAVA_VERSION) == null) {
+ return LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1.toLocalizedString(new Object[] {BUILD_JAVA_VERSION, RESOURCE_NAME});
+ }
+ return null;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java
index e52950f..1757d5c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java
@@ -2080,16 +2080,8 @@ public class SystemAdmin {
LocalizedStrings.SystemAdmin_GEMFIRE_PRODUCT_DIRECTORY_0
.toLocalizedString(getProductDir()));
- if (cmdLine.size() == 1 && "CREATE".equals(cmdLine.get(0))) {
- GemFireVersion.createVersionFile();
+ GemFireVersion.print(System.out);
- } else if (cmdLine.size() == 1 &&
- "FULL".equalsIgnoreCase(String.valueOf(cmdLine.get(0)))) {
- GemFireVersion.print(System.out, true);
-
- } else {
- GemFireVersion.print(System.out, false);
- }
} else if (cmd.equalsIgnoreCase("help")) {
if (cmdLine.size() > 1) {
System.err.println( LocalizedStrings.SystemAdmin_ERROR_UNEXPECTED_COMMAND_LINE_ARGUMENTS_0.toLocalizedString(join(cmdLine)));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
index fc4ab1b..8369d1f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireVersionJUnitTest.java
@@ -16,10 +16,7 @@
*/
package com.gemstone.gemfire.internal;
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -40,67 +37,17 @@ public class GemFireVersionJUnitTest {
*/
@Test
public void testPrintInfo() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- GemFireVersion.print(ps);
- final String versionOutput = baos.toString();
+ final String versionOutput = GemFireVersion.asString();
System.out.println(versionOutput);
- assertTrue(versionOutput.contains("Java version:"));
- assertTrue(versionOutput.contains("Native version:"));
- assertTrue(versionOutput.contains("Source revision:"));
- assertTrue(versionOutput.contains("Source repository:"));
- assertTrue(versionOutput.contains("Running on:"));
- }
-
- @Test
- public void testMajorMinorVersions() {
- assertEquals(1, GemFireVersion.getMajorVersion("1.0.3"));
- assertEquals(33, GemFireVersion.getMajorVersion("33.0.3"));
- assertEquals(7, GemFireVersion.getMinorVersion("1.7.3"));
- assertEquals(79, GemFireVersion.getMinorVersion("1.79.3"));
- assertEquals(0, GemFireVersion.getMinorVersion("1.RC1"));
- assertEquals(5, GemFireVersion.getMinorVersion("1.5Beta2"));
-
- assertEquals(13, GemFireVersion.getBuild("7.0.2.13"));
- assertEquals(0, GemFireVersion.getBuild("1.7.3"));
- assertEquals(0, GemFireVersion.getBuild("1.79.3"));
- assertEquals(0, GemFireVersion.getBuild("1.RC1"));
- assertEquals(0, GemFireVersion.getBuild("1.5Beta2"));
-
- assertTrue("7.0 should be < 7.0.2.14", GemFireVersion.compareVersions("7.0", "7.0.2.14", true) < 0);
- assertTrue("7.0.0 should be < 7.0.2.14", GemFireVersion.compareVersions("7.0.0", "7.0.2.14", true) < 0);
- assertTrue("7.0.2 should be < 7.0.2.14", GemFireVersion.compareVersions("7.0.2", "7.0.2.14", true) < 0);
- assertTrue("7.0.3 should be > 7.0.2.14", GemFireVersion.compareVersions("7.0.3", "7.0.2.14", true) > 0);
- assertTrue("7.0.1.15 should be < 7.0.2.14", GemFireVersion.compareVersions("7.0.1.15", "7.0.2.14", true) < 0);
- assertTrue("7.0.2.13 should be < 7.0.2.14", GemFireVersion.compareVersions("7.0.2.13", "7.0.2.14", true) < 0);
- assertTrue("7.0.2.14 should be > 7.0.2.13", GemFireVersion.compareVersions("7.0.2.14", "7.0.2.13", true) > 0);
- assertTrue("7.0.2.14 should be == 7.0.2.14", GemFireVersion.compareVersions("7.0.2.14", "7.0.2.14", true) == 0);
- assertTrue("7.0.2.12 should be < 7.0.2.13", GemFireVersion.compareVersions("7.0.2.12", "7.0.2.13", true) < 0);
- assertTrue("7.0.2.13 should be == 7.0.2.13", GemFireVersion.compareVersions("7.0.2.13", "7.0.2.13", true) == 0);
- assertTrue("7.0.2.15 should be > 7.0.2.13", GemFireVersion.compareVersions("7.0.2.14", "7.0.2.13", true) > 0);
- }
-
- @Test
- public void testVersionClass() throws Exception {
- compare(Version.GFE_662, Version.GFE_66);
- compare(Version.GFE_6622, Version.GFE_662);
- compare(Version.GFE_71, Version.GFE_70);
- compare(Version.GFE_80, Version.GFE_70);
- compare(Version.GFE_80, Version.GFE_71);
- compare(Version.GFE_81, Version.GFE_70);
- compare(Version.GFE_81, Version.GFE_71);
- compare(Version.GFE_81, Version.GFE_80);
- }
-
- private void compare(Version later, Version earlier) {
- assertTrue(later.compareTo(earlier) > 0);
- assertTrue(later.equals(later));
- assertTrue(later.compareTo(later) == 0);
- assertTrue(earlier.compareTo(later) < 0);
-
- assertTrue(later.compareTo(earlier.ordinal()) > 0);
- assertTrue(later.compareTo(later.ordinal()) == 0);
- assertTrue(earlier.compareTo(later.ordinal()) < 0);
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.PRODUCT_NAME));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.GEMFIRE_VERSION));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.SOURCE_DATE));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.SOURCE_REVISION));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.SOURCE_REPOSITORY));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_DATE));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_ID));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_PLATFORM));
+ assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_JAVA_VERSION));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/geode-core/src/test/java/com/gemstone/gemfire/internal/VersionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/VersionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/VersionJUnitTest.java
new file mode 100644
index 0000000..dcc7049
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/VersionJUnitTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class VersionJUnitTest {
+ @Test
+ public void testVersionClass() throws Exception {
+ compare(Version.GFE_662, Version.GFE_66);
+ compare(Version.GFE_6622, Version.GFE_662);
+ compare(Version.GFE_71, Version.GFE_70);
+ compare(Version.GFE_80, Version.GFE_70);
+ compare(Version.GFE_80, Version.GFE_71);
+ compare(Version.GFE_81, Version.GFE_70);
+ compare(Version.GFE_81, Version.GFE_71);
+ compare(Version.GFE_81, Version.GFE_80);
+ }
+
+ private void compare(Version later, Version earlier) {
+ assertTrue(later.compareTo(earlier) > 0);
+ assertTrue(later.equals(later));
+ assertTrue(later.compareTo(later) == 0);
+ assertTrue(earlier.compareTo(later) < 0);
+
+ assertTrue(later.compareTo(earlier.ordinal()) > 0);
+ assertTrue(later.compareTo(later.ordinal()) == 0);
+ assertTrue(earlier.compareTo(later.ordinal()) < 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/93985f96/gradle/utilities.gradle
----------------------------------------------------------------------
diff --git a/gradle/utilities.gradle b/gradle/utilities.gradle
index 5f597f6..d4d616f 100644
--- a/gradle/utilities.gradle
+++ b/gradle/utilities.gradle
@@ -14,6 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+buildscript {
+ repositories {
+ maven { url "https://plugins.gradle.org/m2/" }
+ }
+
+ dependencies {
+ classpath "org.ajoberstar:gradle-git:1.3.2"
+ }
+}
+
allprojects {
//These methods will be added to each individual project.
//Use this for methods that access project variables (like project.name)
@@ -41,5 +51,38 @@ allprojects {
signArchives.enabled = false
}
}
+
+ readScmInfo = {
+ try {
+ def git = org.ajoberstar.grgit.Grgit.open(currentDir: projectDir)
+ try {
+ return [
+ 'Source-Repository': git.branch.getCurrent().name,
+ 'Source-Revision' : git.head().id,
+ 'Source-Date' : git.head().getDate().format('yyyy-MM-dd HH:mm:ss Z')
+ ] as Properties
+ } finally {
+ git.close()
+ }
+ } catch (IllegalArgumentException e) {
+ // if we're building from the source distribution, we don't have git so
+ // use cached info written during the assembly process
+ def buildInfo = file "$rootDir/.buildinfo"
+ if (buildInfo.exists()) {
+ def props = new Properties()
+ new FileInputStream(buildInfo).withStream { fis ->
+ props.load(fis)
+ }
+ return props
+ }
+
+ logger.warn( '***** Unable to find Git workspace. Using default version information *****' )
+ return [
+ 'Source-Repository': 'UNKNOWN',
+ 'Source-Revision' : 'UNKNOWN',
+ 'Source-Date' : new Date().format('yyyy-MM-dd HH:mm:ss Z')
+ ] as Properties
+ }
+ }
}
}
[2/5] incubator-geode git commit: GEODE-1569: add post authorization
processing in JMX and CLI commands
Posted by ud...@apache.org.
GEODE-1569: add post authorization processing in JMX and CLI commands
changed the Principal to be an Object to be consistent with how
other projects incuding spring-security and Apache shiro use Principal.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/44b528d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/44b528d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/44b528d1
Branch: refs/heads/feature/GEODE-420
Commit: 44b528d10f23c7eb1435d2103a877fb97c1ba91e
Parents: 93985f9
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Tue Aug 23 15:14:26 2016 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Thu Aug 25 11:59:37 2016 -0700
----------------------------------------------------------------------
.../gemfire/internal/security/shiro/CustomAuthRealm.java | 2 +-
.../main/java/org/apache/geode/security/SecurityManager.java | 5 ++---
.../apache/geode/security/templates/SampleSecurityManager.java | 5 ++---
.../java/com/gemstone/gemfire/security/SpySecurityManager.java | 3 +--
4 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44b528d1/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
index b9dd8c0..09b8d5f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
@@ -71,7 +71,7 @@ public class CustomAuthRealm extends AuthorizingRealm {
credentialProps.put(ResourceConstants.USER_NAME, username);
credentialProps.put(ResourceConstants.PASSWORD, password);
- Serializable principal = securityManager.authenticate(credentialProps);
+ Object principal = securityManager.authenticate(credentialProps);
try {
return new SimpleAuthenticationInfo(principal, authToken.getPassword(), REALM_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44b528d1/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java b/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
index 9db4734..16b35f1 100644
--- a/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
+++ b/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
@@ -16,7 +16,6 @@
*/
package org.apache.geode.security;
-import java.io.Serializable;
import java.util.Properties;
import com.gemstone.gemfire.distributed.DistributedSystem;
@@ -49,7 +48,7 @@ public interface SecurityManager {
* a serializable principal object
* @throws AuthenticationFailedException
*/
- Serializable authenticate(Properties credentials) throws AuthenticationFailedException;
+ Object authenticate(Properties credentials) throws AuthenticationFailedException;
/**
* Authorize the ResourcePermission for a given Principal
@@ -60,7 +59,7 @@ public interface SecurityManager {
* @return
* true if authorized, false if not
*/
- default boolean authorize(Serializable principal, ResourcePermission permission) {
+ default boolean authorize(Object principal, ResourcePermission permission) {
return true;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44b528d1/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java b/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
index 5948527..b806c9f 100644
--- a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
+++ b/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
@@ -18,7 +18,6 @@ package org.apache.geode.security.templates;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
@@ -97,7 +96,7 @@ public class SampleSecurityManager implements SecurityManager {
private Map<String, User> userNameToUser;
@Override
- public boolean authorize(final Serializable principal, final ResourcePermission context) {
+ public boolean authorize(final Object principal, final ResourcePermission context) {
if (principal == null) return false;
User user = this.userNameToUser.get(principal.toString());
@@ -128,7 +127,7 @@ public class SampleSecurityManager implements SecurityManager {
}
@Override
- public Serializable authenticate(final Properties credentials) throws AuthenticationFailedException {
+ public Object authenticate(final Properties credentials) throws AuthenticationFailedException {
String user = credentials.getProperty(ResourceConstants.USER_NAME);
String password = credentials.getProperty(ResourceConstants.PASSWORD);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44b528d1/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
index 31ebde5..91d25f0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
@@ -16,7 +16,6 @@
*/
package com.gemstone.gemfire.security;
-import java.io.Serializable;
import java.util.Properties;
import org.apache.geode.security.SecurityManager;
@@ -32,7 +31,7 @@ public class SpySecurityManager implements SecurityManager {
}
@Override
- public Serializable authenticate(final Properties props) throws AuthenticationFailedException {
+ public Object authenticate(final Properties props) throws AuthenticationFailedException {
return null;
}
[4/5] incubator-geode git commit: Merge branch 'develop' into
feature/GEODE-420
Posted by ud...@apache.org.
Merge branch 'develop' into feature/GEODE-420
# Conflicts:
# geode-core/src/main/java/com/gemstone/gemfire/internal/GemFireVersion.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/59adbcc0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/59adbcc0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/59adbcc0
Branch: refs/heads/feature/GEODE-420
Commit: 59adbcc0341f1e54f546ce180a89c059cbf8e1a1
Parents: a455526 7f4992c
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Aug 26 09:27:13 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Aug 26 09:27:13 2016 +1000
----------------------------------------------------------------------
build.gradle | 1 -
.../SessionExpirationCacheListener.java | 6 +-
geode-core/build.gradle | 33 -
.../distributed/internal/StartupMessage.java | 14 -
.../gemfire/internal/GemFireVersion.java | 726 +++++--------------
.../gemstone/gemfire/internal/SystemAdmin.java | 10 +-
.../security/shiro/CustomAuthRealm.java | 2 +-
.../apache/geode/security/SecurityManager.java | 5 +-
.../templates/SampleSecurityManager.java | 5 +-
.../internal/GemFireVersionJUnitTest.java | 75 +-
.../gemfire/internal/VersionJUnitTest.java | 50 ++
.../gemfire/security/SpySecurityManager.java | 3 +-
gradle/utilities.gradle | 43 ++
13 files changed, 283 insertions(+), 690 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/59adbcc0/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/StartupMessage.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/59adbcc0/geode-core/src/main/java/com/gemstone/gemfire/internal/SystemAdmin.java
----------------------------------------------------------------------
[3/5] incubator-geode git commit: GEODE-1675: Cast to
DeltaSessionInterface instead of DeltaSession
Posted by ud...@apache.org.
GEODE-1675: Cast to DeltaSessionInterface instead of DeltaSession
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7f4992c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7f4992c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7f4992c2
Branch: refs/heads/feature/GEODE-420
Commit: 7f4992c29c1b778a3b7196268084164558c4913f
Parents: 44b528d
Author: Jason Huynh <hu...@gmail.com>
Authored: Thu Aug 25 08:23:06 2016 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Aug 25 14:18:48 2016 -0700
----------------------------------------------------------------------
.../catalina/callback/SessionExpirationCacheListener.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7f4992c2/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java b/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
index 4fd1136..da9fffc 100644
--- a/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
+++ b/extensions/geode-modules/src/main/java/com/gemstone/gemfire/modules/session/catalina/callback/SessionExpirationCacheListener.java
@@ -20,9 +20,7 @@ import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.EntryEvent;
import com.gemstone.gemfire.cache.Operation;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-import com.gemstone.gemfire.modules.session.catalina.DeltaSession;
import com.gemstone.gemfire.modules.session.catalina.DeltaSessionInterface;
-import com.gemstone.gemfire.modules.session.catalina.DeltaSessionManager;
import com.gemstone.gemfire.modules.util.ContextMapper;
import javax.servlet.http.HttpSession;
@@ -48,8 +46,8 @@ public class SessionExpirationCacheListener extends CacheListenerAdapter<String,
* gemfire.EXPIRE_SENDS_ENTRY_AS_CALLBACK.
*/
Object callback = event.getCallbackArgument();
- if (callback != null && callback instanceof DeltaSession) {
- session = (DeltaSession) callback;
+ if (callback != null && callback instanceof DeltaSessionInterface) {
+ session = (DeltaSessionInterface) callback;
ManagerBase m = ContextMapper.getContext(session.getContextName());
if (m != null) {
session.setOwner(m);
[5/5] incubator-geode git commit: GEODE-420: Fixing last few tests
for LauncherLifecycleCommandsDUnitTest.java
Posted by ud...@apache.org.
GEODE-420: Fixing last few tests for LauncherLifecycleCommandsDUnitTest.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7272c644
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7272c644
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7272c644
Branch: refs/heads/feature/GEODE-420
Commit: 7272c644493f04b5c8451c9fee5a9d09599e13c9
Parents: 59adbcc
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Tue Aug 30 12:21:11 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Tue Aug 30 12:21:11 2016 +1000
----------------------------------------------------------------------
.../LauncherLifecycleCommandsDUnitTest.java | 476 ++++++++++---------
.../gemfire/distributed/LocatorLauncher.java | 3 +-
.../internal/tcpserver/TcpClient.java | 5 +
.../internal/net/SocketCreatorFactory.java | 6 +-
.../gemfire/management/JMXMBeanDUnitTest.java | 25 -
5 files changed, 253 insertions(+), 262 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7272c644/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
index 1d91834..1610b8e 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
@@ -16,8 +16,51 @@
*/
package com.gemstone.gemfire.management.internal.cli.commands;
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.nio.charset.Charset;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.TimeUnit;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.Query;
+import javax.management.QueryExp;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.*;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.Pool;
+import com.gemstone.gemfire.cache.client.PoolFactory;
+import com.gemstone.gemfire.cache.client.PoolManager;
import com.gemstone.gemfire.distributed.AbstractLauncher.ServiceState;
import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
import com.gemstone.gemfire.distributed.LocatorLauncher;
@@ -39,39 +82,10 @@ import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runners.MethodSorters;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import java.io.*;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.TimeUnit;
-
-import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static com.gemstone.gemfire.test.dunit.Assert.*;
-import static com.gemstone.gemfire.test.dunit.Wait.waitForCriterion;
/**
* The LauncherLifecycleCommandsDUnitTest class is a test suite of integration tests testing the contract and
* functionality of the GemFire launcher lifecycle commands inside Gfsh.
- *
* @see javax.management.MBeanServerConnection
* @see javax.management.remote.JMXConnector
* @see com.gemstone.gemfire.distributed.AbstractLauncher
@@ -88,8 +102,6 @@ import static com.gemstone.gemfire.test.dunit.Wait.waitForCriterion;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
- protected static final long COMMAND_EXECUTION_TIMEOUT = TimeUnit.MINUTES.toSeconds(2);
-
protected static final DateFormat TIMESTAMP = new SimpleDateFormat("yyyyMMddHHmmssSSS");
private final Queue<Integer> processIds = new ConcurrentLinkedDeque<>();
@@ -98,13 +110,11 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
return getMemberId(InetAddress.getLocalHost().getHostName(), jmxManagerPort, memberName);
}
- protected static String getMemberId(final String jmxManagerHost, final int jmxManagerPort,
- final String memberName) throws Exception {
+ protected static String getMemberId(final String jmxManagerHost, final int jmxManagerPort, final String memberName) throws Exception {
JMXConnector connector = null;
try {
- connector = JMXConnectorFactory.connect(new JMXServiceURL(
- String.format("service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi", jmxManagerHost, jmxManagerPort)));
+ connector = JMXConnectorFactory.connect(new JMXServiceURL(String.format("service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi", jmxManagerHost, jmxManagerPort)));
MBeanServerConnection connection = connector.getMBeanServerConnection();
@@ -137,8 +147,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
while ((pid = processIds.poll()) != null) {
if (launcherLifecycleCommands.isVmWithProcessIdRunning(pid)) {
try {
- String killCommand = String.format("%1$s %2$d", SystemUtils.isWindows() ? "taskkill /F /PID" : "kill -9",
- pid);
+ String killCommand = String.format("%1$s %2$d", SystemUtils.isWindows() ? "taskkill /F /PID" : "kill -9", pid);
Runtime.getRuntime().exec(killCommand);
} catch (Throwable ignore) {
}
@@ -161,15 +170,9 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
}
protected Integer readPid(final File workingDirectory) throws IOException {
- assertTrue(String.format("The working directory (%1$s) must exist!", workingDirectory),
- workingDirectory != null && workingDirectory.isDirectory());
+ assertTrue(String.format("The working directory (%1$s) must exist!", workingDirectory), workingDirectory != null && workingDirectory.isDirectory());
- File[] files = workingDirectory.listFiles(new FileFilter() {
- @Override
- public boolean accept(final File pathname) {
- return (pathname != null && pathname.isFile() && pathname.getAbsolutePath().endsWith(".pid"));
- }
- });
+ File[] files = workingDirectory.listFiles(pathname -> (pathname != null && pathname.isFile() && pathname.getAbsolutePath().endsWith(".pid")));
assertNotNull(files);
assertTrue(files.length > 0);
@@ -195,11 +198,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
protected String serviceStateStatusStringNormalized(final String serviceStateStatus) {
assertNotNull(serviceStateStatus);
assertTrue("serviceStateStatus is missing 'Uptime': " + serviceStateStatus, serviceStateStatus.contains("Uptime"));
- assertTrue("serviceStateStatus is missing 'JVM Arguments': " + serviceStateStatus,
- serviceStateStatus.contains("JVM Arguments"));
+ assertTrue("serviceStateStatus is missing 'JVM Arguments': " + serviceStateStatus, serviceStateStatus.contains("JVM Arguments"));
- return serviceStateStatus.substring(0, serviceStateStatus.indexOf("Uptime")).concat(
- serviceStateStatus.substring(serviceStateStatus.indexOf("JVM Arguments")));
+ return serviceStateStatus.substring(0, serviceStateStatus.indexOf("Uptime"))
+ .concat(serviceStateStatus.substring(serviceStateStatus.indexOf("JVM Arguments")));
}
protected Status stopLocator(final File workingDirectory) {
@@ -207,18 +209,14 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
}
protected Status stopLocator(final String workingDirectory) {
- return waitForGemFireProcessToStop(
- new Builder().setCommand(Command.STOP).setWorkingDirectory(workingDirectory).build().stop(), workingDirectory);
- }
-
- protected Status stopServer(final File workingDirectory) {
- return stopServer(IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory));
+ return waitForGemFireProcessToStop(new Builder().setCommand(Command.STOP).setWorkingDirectory(workingDirectory).build().stop(), workingDirectory);
}
protected Status stopServer(final String workingDirectory) {
- return waitForGemFireProcessToStop(
- new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STOP).setWorkingDirectory(
- workingDirectory).build().stop(), workingDirectory);
+ return waitForGemFireProcessToStop(new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STOP)
+ .setWorkingDirectory(workingDirectory)
+ .build()
+ .stop(), workingDirectory);
}
protected String toString(final Result result) {
@@ -287,7 +285,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
- File workingDirectory = new File(pathname);
+ File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
@@ -303,12 +301,11 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
- command.addOption(CliStrings.START_LOCATOR__DIR, pathname);
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
- command.addOption(CliStrings.START_LOCATOR__J,
- "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
+ command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
CommandResult result = executeCommand(command.toString());
@@ -317,12 +314,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String resultString = toString(result);
- assertTrue(resultString, resultString.contains(
- "Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(
- workingDirectory)));
- assertTrue(resultString, resultString.contains(
- "Caused by: com.gemstone.gemfire.internal.process.FileAlreadyExistsException: Pid file already exists: " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(
- pidFile)));
+ assertTrue(resultString, resultString.contains("Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + IOUtils
+ .tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
+ assertTrue(resultString, resultString.contains("Caused by: com.gemstone.gemfire.internal.process.FileAlreadyExistsException: Pid file already exists: " + IOUtils
+ .tryGetCanonicalFileElseGetAbsoluteFile(pidFile)));
}
/*
@@ -344,12 +339,15 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
}
@Test
- public void test001StartLocatorFailsFastOnMissingGemFirePropertiesFile() {
+ public void test001StartLocatorFailsFastOnMissingGemFirePropertiesFile() throws IOException {
String gemfirePropertiesPathname = "/path/to/missing/gemfire.properties";
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
+ String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName());
+ final File workingDirectory = temporaryFolder.newFolder(pathName);
- command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName()));
+ command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathName);
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, "0");
command.addOption(CliStrings.START_LOCATOR__PROPERTIES, gemfirePropertiesPathname);
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
@@ -364,18 +362,19 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String resultString = toString(result);
- assertTrue(resultString, resultString.contains(
- MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY_STRING,
- gemfirePropertiesPathname)));
+ assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY_STRING, gemfirePropertiesPathname)));
}
@Test
- public void test002StartLocatorFailsFastOnMissingGemFireSecurityPropertiesFile() {
+ public void test002StartLocatorFailsFastOnMissingGemFireSecurityPropertiesFile() throws IOException {
String gemfireSecurityPropertiesPathname = "/path/to/missing/gemfire-security.properties";
+ String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName());
+ final File workingDirectory = temporaryFolder.newFolder(pathName);
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
- command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName()));
+ command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathName);
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, "0");
command.addOption(CliStrings.START_LOCATOR__SECURITY_PROPERTIES, gemfireSecurityPropertiesPathname);
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
@@ -390,18 +389,19 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String resultString = toString(result);
- assertTrue(resultString, resultString.contains(
- MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ",
- gemfireSecurityPropertiesPathname)));
+ assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ", gemfireSecurityPropertiesPathname)));
}
@Test
- public void test003StartServerFailsFastOnMissingCacheXmlFile() {
+ public void test003StartServerFailsFastOnMissingCacheXmlFile() throws IOException {
String cacheXmlPathname = "/path/to/missing/cache.xml";
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER);
+ String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName());
+ final File workingDirectory = temporaryFolder.newFolder(pathName);
- command.addOption(CliStrings.START_SERVER__NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName()));
+ command.addOption(CliStrings.START_SERVER__NAME, pathName);
+ command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_SERVER__CACHE_XML_FILE, cacheXmlPathname);
CommandResult result = executeCommand(command.toString());
@@ -411,17 +411,20 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String resultString = toString(result);
- assertTrue(resultString,
- resultString.contains(MessageFormat.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname)));
+ assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname)));
}
@Test
- public void test004StartServerFailsFastOnMissingGemFirePropertiesFile() {
+ public void test004StartServerFailsFastOnMissingGemFirePropertiesFile() throws IOException {
String gemfirePropertiesFile = "/path/to/missing/gemfire.properties";
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER);
- command.addOption(CliStrings.START_SERVER__NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName()));
+ String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName());
+ final File workingDirectory = temporaryFolder.newFolder(pathName);
+
+ command.addOption(CliStrings.START_SERVER__NAME, pathName);
+ command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_SERVER__PROPERTIES, gemfirePropertiesFile);
CommandResult result = executeCommand(command.toString());
@@ -431,18 +434,20 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String resultString = toString(result);
- assertTrue(resultString, resultString.contains(
- MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY_STRING,
- gemfirePropertiesFile)));
+ assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, StringUtils.EMPTY_STRING, gemfirePropertiesFile)));
}
@Test
- public void test005StartServerFailsFastOnMissingGemFireSecurityPropertiesFile() {
+ public void test005StartServerFailsFastOnMissingGemFireSecurityPropertiesFile() throws IOException {
String gemfireSecuritiesPropertiesFile = "/path/to/missing/gemfire-securities.properties";
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER);
- command.addOption(CliStrings.START_SERVER__NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName()));
+ String pathName = getClass().getSimpleName().concat("_").concat(getTestMethodName());
+ final File workingDirectory = temporaryFolder.newFolder(pathName);
+
+ command.addOption(CliStrings.START_SERVER__NAME, pathName);
+ command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_SERVER__SECURITY_PROPERTIES, gemfireSecuritiesPropertiesFile);
CommandResult result = executeCommand(command.toString());
@@ -452,9 +457,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String resultString = toString(result);
- assertTrue(resultString, resultString.contains(
- MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ",
- gemfireSecuritiesPropertiesFile)));
+ assertTrue(resultString, resultString.contains(MessageFormat.format(CliStrings.GEODE_0_PROPERTIES_1_NOT_FOUND_MESSAGE, "Security ", gemfireSecuritiesPropertiesFile)));
}
@Test
@@ -475,8 +478,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
- command.addOption(CliStrings.START_LOCATOR__J,
- "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
+ command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort());
CommandResult result = executeCommand(command.toString());
@@ -486,8 +488,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
String locatorOutput = toString(result);
assertNotNull(locatorOutput);
- assertTrue("Locator output was: " + locatorOutput,
- locatorOutput.contains("Locator in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
+ assertTrue("Locator output was: " + locatorOutput, locatorOutput.contains("Locator in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory)));
} finally {
stopLocator(workingDirectory);
}
@@ -499,19 +500,18 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
- assertEquals(CliStrings.format(CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"),
- StringUtils.trim(toString(result)));
+ assertEquals(CliStrings.format(CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), StringUtils.trim(toString(result)));
}
@Test
- public void test008StatusLocatorUsingMemberName() {
+ public void test008StatusLocatorUsingMemberName() throws IOException {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
final int jmxManagerPort = ports[0];
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
- File workingDirectory = new File(pathname);
+ File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
@@ -520,7 +520,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
- command.addOption(CliStrings.START_LOCATOR__DIR, pathname);
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
@@ -532,9 +532,11 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
- LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(
- LocatorLauncher.Command.STATUS).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(
- workingDirectory.getPath()).build();
+ LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS)
+ .setBindAddress(null)
+ .setPort(locatorPort)
+ .setWorkingDirectory(workingDirectory.getPath())
+ .build();
assertNotNull(locatorLauncher);
@@ -552,17 +554,16 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
- assertEquals(CliStrings.format(CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE,
- "invalidLocatorMemberName"), StringUtils.trim(toString(result)));
+ assertEquals(CliStrings.format(CliStrings.STATUS_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, "invalidLocatorMemberName"), StringUtils.trim(toString(result)));
result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, pathname));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
- assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(
- serviceStateStatusStringNormalized(expectedLocatorState)));
+ assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(serviceStateStatusStringNormalized(expectedLocatorState)));
} finally {
stopLocator(workingDirectory);
+ FileUtils.copyDirectory(workingDirectory.getCanonicalFile(), new File("/tmp"));
}
}
@@ -574,7 +575,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
- File workingDirectory = new File(pathname);
+ File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
@@ -583,7 +584,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
- command.addOption(CliStrings.START_LOCATOR__DIR, pathname);
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
@@ -595,9 +596,11 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
- LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(
- LocatorLauncher.Command.STATUS).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(
- workingDirectory.getPath()).build();
+ LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.STATUS)
+ .setBindAddress(null)
+ .setPort(locatorPort)
+ .setWorkingDirectory(workingDirectory.getPath())
+ .build();
assertNotNull(locatorLauncher);
@@ -611,15 +614,14 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
- result = executeCommand(
- String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, getMemberId(jmxManagerPort, pathname)));
+ result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STATUS_LOCATOR, getMemberId(jmxManagerPort, pathname)));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
- assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(
- serviceStateStatusStringNormalized(expectedLocatorState)));
+ assertTrue(serviceStateStatusStringNormalized(toString(result)).contains(serviceStateStatusStringNormalized(expectedLocatorState)));
} finally {
stopLocator(workingDirectory);
+ FileUtils.copyDirectory(workingDirectory.getCanonicalFile(), new File("/tmp"));
}
}
@@ -629,95 +631,100 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
- assertEquals(CliStrings.format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"),
- StringUtils.trim(toString(result)));
+ assertEquals(CliStrings.format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), StringUtils.trim(toString(result)));
}
@Test
- public void test011StopLocatorUsingMemberName() {
+ public void test011StopLocatorUsingMemberName() throws IOException {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
final int jmxManagerPort = ports[0];
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
- File workingDirectory = new File(pathname);
+ File workingDirectory = temporaryFolder.newFolder(pathname);
- assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
+ try {
+ assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
- CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
+ CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
- command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
- command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
- command.addOption(CliStrings.START_LOCATOR__DIR, pathname);
- command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
- command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
- command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
- command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
- command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
+ command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
+ command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
+ command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
+ command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
+ command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
+ command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
+ command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
- CommandResult result = executeCommand(command.toString());
+ CommandResult result = executeCommand(command.toString());
- assertNotNull(result);
- assertEquals(Result.Status.OK, result.getStatus());
+ assertNotNull(result);
+ assertEquals(Result.Status.OK, result.getStatus());
- final LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(
- LocatorLauncher.Command.STOP).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(
- workingDirectory.getPath()).build();
+ final LocatorLauncher locatorLauncher = new Builder().setCommand(Command.STOP)
+ .setBindAddress(null)
+ .setPort(locatorPort)
+ .setWorkingDirectory(workingDirectory.getPath())
+ .build();
- assertNotNull(locatorLauncher);
+ assertNotNull(locatorLauncher);
- LocatorState locatorStatus = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
+ LocatorState locatorStatus = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
- assertNotNull(locatorStatus);
- assertEquals(Status.ONLINE, locatorStatus.getStatus());
+ assertNotNull(locatorStatus);
+ assertEquals(Status.ONLINE, locatorStatus.getStatus());
- result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
+ result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
- assertNotNull(result);
- assertEquals(Result.Status.OK, result.getStatus());
+ assertNotNull(result);
+ assertEquals(Result.Status.OK, result.getStatus());
- result = executeCommand(String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STOP_LOCATOR));
+ result = executeCommand(String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STOP_LOCATOR));
- assertNotNull(result);
- assertEquals(Result.Status.ERROR, result.getStatus());
- assertEquals(CliStrings.format(CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE,
- "invalidLocatorMemberName"), StringUtils.trim(toString(result)));
+ assertNotNull(result);
+ assertEquals(Result.Status.ERROR, result.getStatus());
+ assertEquals(CliStrings.format(CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, "invalidLocatorMemberName"), StringUtils.trim(toString(result)));
- locatorStatus = locatorLauncher.status();
+ locatorStatus = locatorLauncher.status();
- assertNotNull(locatorStatus);
- assertEquals(Status.ONLINE, locatorStatus.getStatus());
+ assertNotNull(locatorStatus);
+ assertEquals(Status.ONLINE, locatorStatus.getStatus());
- result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STOP_LOCATOR, pathname));
+ result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STOP_LOCATOR, pathname));
- assertNotNull(result);
- assertEquals(Result.Status.OK, result.getStatus());
+ assertNotNull(result);
+ assertEquals(Result.Status.OK, result.getStatus());
- // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's logger
- // and standard err/out...
- //assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, pathname),
- // StringUtils.trim(toString(result)));
+ // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's logger
+ // and standard err/out...
+ //assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, pathname),
+ // StringUtils.trim(toString(result)));
- WaitCriterion waitCriteria = new WaitCriterion() {
- @Override
- public boolean done() {
- final LocatorState locatorStatus = locatorLauncher.status();
- return (locatorStatus != null && Status.NOT_RESPONDING.equals(locatorStatus.getStatus()));
- }
+ WaitCriterion waitCriteria = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ final LocatorState locatorStatus = locatorLauncher.status();
+ return (locatorStatus != null && Status.NOT_RESPONDING.equals(locatorStatus.getStatus()));
+ }
- @Override
- public String description() {
- return "wait for the Locator to stop; the Locator will no longer respond after it stops";
- }
- };
+ @Override
+ public String description() {
+ return "wait for the Locator to stop; the Locator will no longer respond after it stops";
+ }
+ };
- waitForCriterion(waitCriteria, 15 * 1000, 5000, true);
+ waitForCriterion(waitCriteria, 15 * 1000, 5000, true);
- locatorStatus = locatorLauncher.status();
+ locatorStatus = locatorLauncher.status();
+
+ assertNotNull(locatorStatus);
+ assertEquals(Status.NOT_RESPONDING, locatorStatus.getStatus());
+ } finally {
+ FileUtils.copyDirectory(workingDirectory.getCanonicalFile(), new File("/tmp"));
+ }
- assertNotNull(locatorStatus);
- assertEquals(Status.NOT_RESPONDING, locatorStatus.getStatus());
}
// @see Trac Bug # 46760
@@ -729,73 +736,79 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
- File workingDirectory = new File(pathname);
+ File workingDirectory = temporaryFolder.newFolder(pathname);
- assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
+ try {
+ assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
- CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
+ CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
- command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
- command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
- command.addOption(CliStrings.START_LOCATOR__DIR, pathname);
- command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
- command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
- command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
- command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
- command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
+ command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
+ command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
+ command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
+ command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
+ command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
+ command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
+ command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
+ command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
- CommandResult result = executeCommand(command.toString());
+ CommandResult result = executeCommand(command.toString());
- assertNotNull(result);
- assertEquals(Result.Status.OK, result.getStatus());
+ assertNotNull(result);
+ assertEquals(Result.Status.OK, result.getStatus());
- final LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setCommand(
- LocatorLauncher.Command.STOP).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(
- workingDirectory.getPath()).build();
+ final LocatorLauncher locatorLauncher = new Builder().setCommand(Command.STOP)
+ .setBindAddress(null)
+ .setPort(locatorPort)
+ .setWorkingDirectory(workingDirectory.getPath())
+ .build();
- assertNotNull(locatorLauncher);
+ assertNotNull(locatorLauncher);
- LocatorState locatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
+ LocatorState locatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
- assertNotNull(locatorState);
- assertEquals(Status.ONLINE, locatorState.getStatus());
+ assertNotNull(locatorState);
+ assertEquals(Status.ONLINE, locatorState.getStatus());
- result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
+ result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
- assertNotNull(result);
- assertEquals(Result.Status.OK, result.getStatus());
+ assertNotNull(result);
+ assertEquals(Result.Status.OK, result.getStatus());
- String memberId = getMemberId(jmxManagerPort, pathname);
+ String memberId = getMemberId(jmxManagerPort, pathname);
- result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STOP_LOCATOR, memberId));
+ result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STOP_LOCATOR, memberId));
- assertNotNull(result);
- assertEquals(Result.Status.OK, result.getStatus());
+ assertNotNull(result);
+ assertEquals(Result.Status.OK, result.getStatus());
- // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's logger
- // and standard err/out...
- //assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, memberId),
- // StringUtils.trim(toString(result)));
+ // TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's logger
+ // and standard err/out...
+ //assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE, memberId),
+ // StringUtils.trim(toString(result)));
- WaitCriterion waitCriteria = new WaitCriterion() {
- @Override
- public boolean done() {
- LocatorState locatorState = locatorLauncher.status();
- return (locatorState != null && Status.NOT_RESPONDING.equals(locatorState.getStatus()));
- }
+ WaitCriterion waitCriteria = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ LocatorState locatorState = locatorLauncher.status();
+ return (locatorState != null && Status.NOT_RESPONDING.equals(locatorState.getStatus()));
+ }
- @Override
- public String description() {
- return "wait for the Locator to stop; the Locator will no longer respond after it stops";
- }
- };
+ @Override
+ public String description() {
+ return "wait for the Locator to stop; the Locator will no longer respond after it stops";
+ }
+ };
- waitForCriterion(waitCriteria, 15 * 1000, 5000, true);
+ waitForCriterion(waitCriteria, 15 * 1000, 5000, true);
- locatorState = locatorLauncher.status();
+ locatorState = locatorLauncher.status();
- assertNotNull(locatorState);
- assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
+ assertNotNull(locatorState);
+ assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
+ } finally {
+ FileUtils.copyDirectory(workingDirectory.getCanonicalFile(),new File("/tmp"));
+ }
}
@Test
@@ -805,7 +818,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
final int locatorPort = ports[1];
String pathname = getClass().getSimpleName().concat("_").concat(getTestMethodName());
- File workingDirectory = new File(pathname);
+ File workingDirectory = temporaryFolder.newFolder(pathname);
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
@@ -816,12 +829,10 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
command.addOption(CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_SERVER__MAXHEAP, "10M");
command.addOption(CliStrings.START_SERVER__LOG_LEVEL, "config");
- command.addOption(CliStrings.START_SERVER__DIR, pathname);
- command.addOption(CliStrings.START_SERVER__CACHE_XML_FILE,
- IOUtils.tryGetCanonicalPathElseGetAbsolutePath(writeAndGetCacheXmlFile(workingDirectory)));
+ command.addOption(CliStrings.START_SERVER__DIR, workingDirectory.getCanonicalPath());
+ command.addOption(CliStrings.START_SERVER__CACHE_XML_FILE, IOUtils.tryGetCanonicalPathElseGetAbsolutePath(writeAndGetCacheXmlFile(workingDirectory)));
command.addOption(CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH);
- command.addOption(CliStrings.START_SERVER__J,
- "-D" + DistributionConfig.GEMFIRE_PREFIX + "" + START_LOCATOR + "=localhost[" + locatorPort + "]");
+ command.addOption(CliStrings.START_SERVER__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "" + START_LOCATOR + "=localhost[" + locatorPort + "]");
CommandResult result = executeCommand(command.toString());
@@ -830,9 +841,9 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
- ServerLauncher serverLauncher = new ServerLauncher.Builder().setCommand(
- ServerLauncher.Command.STATUS).setWorkingDirectory(
- IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory)).build();
+ ServerLauncher serverLauncher = new ServerLauncher.Builder().setCommand(ServerLauncher.Command.STATUS)
+ .setWorkingDirectory(IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory))
+ .build();
assertNotNull(serverLauncher);
@@ -905,8 +916,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
BufferedWriter fileWriter = null;
try {
- fileWriter = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(cacheXml, false), Charset.forName("UTF-8").newEncoder()));
+ fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cacheXml, false), Charset.forName("UTF-8").newEncoder()));
fileWriter.write(buffer.toString());
fileWriter.flush();
} finally {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7272c644/geode-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
index 0b1efd3..2f16c59 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
@@ -21,6 +21,7 @@ import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import com.gemstone.gemfire.cache.client.internal.locator.*;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
import com.gemstone.gemfire.distributed.internal.InternalLocator;
import com.gemstone.gemfire.distributed.internal.tcpserver.*;
import com.gemstone.gemfire.internal.DistributionLocator;
@@ -249,7 +250,7 @@ public final class LocatorLauncher extends AbstractLauncher<String> {
final int timeout = Integer.MAX_VALUE; // 2 minutes
try {
- TcpClient client = new TcpClient();
+ TcpClient client = new TcpClient(new DistributionConfigImpl(new Properties()));
return (LocatorStatusResponse) client.requestToServer(bindAddress, port,
new LocatorStatusRequest(), timeout, true);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7272c644/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
index 78c6d95..9aaee9f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
@@ -33,6 +33,7 @@ import org.apache.logging.log4j.Logger;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.UnsupportedVersionException;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.internal.Version;
import com.gemstone.gemfire.internal.VersionedDataInputStream;
import com.gemstone.gemfire.internal.VersionedDataOutputStream;
@@ -56,6 +57,10 @@ public class TcpClient {
private final SocketCreator socketCreator;
+ public TcpClient(DistributionConfig distributionConfig) {
+ this(SocketCreatorFactory.setDistributionConfig(distributionConfig).getSocketCreatorForComponent(SecurableComponent.LOCATOR));
+ }
+
/**
* Constructs a new TcpClient using the default (Locator) SocketCreator.
* SocketCreatorFactory should be initialized before invoking this method.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7272c644/geode-core/src/main/java/com/gemstone/gemfire/internal/net/SocketCreatorFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/net/SocketCreatorFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/net/SocketCreatorFactory.java
index 6e39381..337ca9c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/net/SocketCreatorFactory.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/net/SocketCreatorFactory.java
@@ -79,7 +79,7 @@ public class SocketCreatorFactory {
return createSSLSocketCreator(sslComponent, sslConfig);
}
}
- return createSSLSocketCreator(SecurableComponent.NONE, sslConfig);
+ return createSSLSocketCreator(sslComponent, sslConfig);
}
@@ -98,10 +98,10 @@ public class SocketCreatorFactory {
socketCreator = new SocketCreator(sslConfig);
registerSocketCreatorForComponent(sslEnableComponent, socketCreator);
} else {
- socketCreator = getRegisteredSocketCreatorForComponent(SecurableComponent.NONE);
+ socketCreator = getRegisteredSocketCreatorForComponent(sslEnableComponent);
if (socketCreator == null) {
socketCreator = new SocketCreator(sslConfig);
- registerSocketCreatorForComponent(SecurableComponent.NONE, socketCreator);
+ registerSocketCreatorForComponent(sslEnableComponent, socketCreator);
}
}
return socketCreator;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7272c644/geode-core/src/test/java/com/gemstone/gemfire/management/JMXMBeanDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/JMXMBeanDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/JMXMBeanDUnitTest.java
index bc90ee0..f08c172 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/JMXMBeanDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/JMXMBeanDUnitTest.java
@@ -176,9 +176,6 @@ public class JMXMBeanDUnitTest extends DistributedTestCase {
System.setProperty("javax.net.ssl.trustStore", useMulti ? getMultiKeyTruststore() : getSimpleSingleKeyKeystore());
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
-// System.setProperty("com.sun.management.jmxremote.ssl.need.client.auth", "true");
-// System.setProperty("com.sun.management.jmxremote.ssl", "true");
-// System.setProperty("com.sun.management.jmxremote.registry.ssl", "true");
environment.put("com.sun.jndi.rmi.factory.socket", new SslRMIClientSocketFactory());
}
@@ -227,12 +224,6 @@ public class JMXMBeanDUnitTest extends DistributedTestCase {
}
- private Properties configureServerProperties(final Properties properties, final String locators) {
- configureCommonProperties(properties);
- properties.setProperty(LOCATORS, locators);
- return properties;
- }
-
private Properties configureJMXSSLProperties(final Properties properties, final boolean isLegacy, final boolean useMultiKey) {
if (isLegacy) {
properties.setProperty(JMX_MANAGER_SSL_CIPHERS, "any");
@@ -299,20 +290,4 @@ public class JMXMBeanDUnitTest extends DistributedTestCase {
properties.setProperty(USE_CLUSTER_CONFIGURATION, "false");
return properties;
}
-
- private static class GemFireRMIClientSocketFactory implements RMIClientSocketFactory, Serializable {
-
- private static final long serialVersionUID = -7604285019188827617L;
-
- private/* final hack to prevent serialization */ transient SocketCreator sc;
-
- public GemFireRMIClientSocketFactory(SocketCreator sc) {
- this.sc = sc;
- }
-
- @Override
- public Socket createSocket(String host, int port) throws IOException {
- return this.sc.connectForClient(host, port, 0/* no timeout */);
- }
- }
}