private static synchronized VersionDescription getDescription() { if (description == null) { String name = GemFireVersion.class.getPackage().getName().replace('.', '/') + "/" + RESOURCE_NAME; description = new VersionDescription(name); } return description; }
public static String getProductName() { return getDescription().getProperty(PRODUCT_NAME); }
public static void print(PrintWriter pw) { getDescription().print(pw); }
void print(PrintWriter pw) { if (error.isPresent()) { pw.println(error.get()); } else { for (Entry<?, ?> props : new TreeMap<>(description).entrySet()) { pw.println(props.getKey() + ": " + props.getValue()); } } // not stored in the description map pw.println(NATIVE_VERSION + ": " + getNativeCodeVersion()); pw.println(getRunningOnInfo()); }
@Test public void testNoFile() { String noFile = "not a property file"; VersionDescription noVersion = new VersionDescription(noFile); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); noVersion.print(pw); String noFileOutput = sw.toString(); assertTrue(noFileOutput.contains( String.format("<Could not find resource org/apache/geode/internal/%s>", noFile))); }
@Test public void testNoFileGetProperty() { String noFile = "not a property file"; VersionDescription noVersion = new VersionDescription(noFile); String err = String.format("<Could not find resource org/apache/geode/internal/%s>", noFile); assertEquals(err, noVersion.getProperty(VersionDescription.PRODUCT_VERSION)); } }
private static String getRunningOnInfo() { String line = getLocalHost() + ", " + Runtime.getRuntime().availableProcessors() + " cpu(s), " + getOsArchitecture() + ' ' + getOsName() + ' ' + getOsVersion() + ' '; return String.format(RUNNING_ON + ": %s", line); }
public VersionDescription(String name) { InputStream is = ClassPathLoader.getLatest().getResourceAsStream(getClass(), name); if (is == null) { error = Optional .of(String.format("<Could not find resource org/apache/geode/internal/%s>", name)); description = null; return; } description = new Properties(); try { description.load(is); } catch (Exception ex) { error = Optional .of(String.format( "<Could not read properties from resource org/apache/geode/internal/%s because: %s>", name, ex)); return; } error = validate(description); }
public static String getSourceDate() { return getDescription().getProperty(SOURCE_DATE); }
public static String getSourceRevision() { return getDescription().getProperty(SOURCE_REVISION); }
public static String getBuildId() { return getDescription().getProperty(BUILD_ID); }
public static String getGemFireVersion() { return getDescription().getProperty(PRODUCT_VERSION); }
public static String getSourceRepository() { return getDescription().getProperty(SOURCE_REPOSITORY); }
public static String getBuildDate() { return getDescription().getProperty(BUILD_DATE); }
public static String getBuildPlatform() { return getDescription().getProperty(BUILD_PLATFORM); }
public static String getBuildJavaVersion() { return getDescription().getProperty(BUILD_JAVA_VERSION); }