Skip to content

Commit

Permalink
ISPN-11511 More consistent branding
Browse files Browse the repository at this point in the history
* Introduce an infinispan.brand.version property
* Align all shell tools to print the version in the same way
  • Loading branch information
tristantarrant authored and pruivo committed May 6, 2020
1 parent 90f4862 commit bdf4c7c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cli/cli-client/src/main/java/org/infinispan/cli/CLI.java
Expand Up @@ -284,7 +284,7 @@ private void help(PrintStream out) {
}

private void version(PrintStream out) {
out.printf("%s CLI %s\n", Version.getBrandName(), Version.getVersion());
out.printf("%s CLI %s\n", Version.getBrandName(), Version.getBrandVersion());
out.printf("Copyright (C) Red Hat Inc. and/or its affiliates and other contributors\n");
out.printf("License Apache License, v. 2.0. http://www.apache.org/licenses/LICENSE-2.0\n");
}
Expand Down
21 changes: 14 additions & 7 deletions commons/all/src/main/java/org/infinispan/commons/util/Version.java
Expand Up @@ -25,13 +25,15 @@ public class Version {
private static final Version INSTANCE = new Version();
public static final String INFINISPAN_VERSION = "infinispan.version";
public static final String INFINISPAN_BRAND_NAME = "infinispan.brand.name";
public static final String INFINISPAN_BRAND_VERSION = "infinispan.brand.version";
public static final String INFINISPAN_CODENAME = "infinispan.codename";
public static final String INFINISPAN_CORE_SCHEMA_VERSION = "infinispan.core.schema.version";
public static final String INFINISPAN_MODULE_SLOT_PREFIX = "infinispan.module.slot.prefix";
public static final String INFINISPAN_MODULE_SLOT_VERSION = "infinispan.module.slot.version";

private final String version;
private final String brandname;
private final String brandName;
private final String brandVersion;
private final String codename;
private final String schemaVersion;
private final byte[] versionId;
Expand All @@ -56,7 +58,8 @@ private Version(InputStream is) {
// Ignore errors, we'll use fallbacks
}
version = properties.getProperty(INFINISPAN_VERSION, "0.0.0-SNAPSHOT");
brandname = properties.getProperty(INFINISPAN_BRAND_NAME, "Infinispan");
brandName = properties.getProperty(INFINISPAN_BRAND_NAME, "Infinispan");
brandVersion = properties.getProperty(INFINISPAN_BRAND_VERSION, version);
codename = properties.getProperty(INFINISPAN_CODENAME, "N/A");
schemaVersion = properties.getProperty(INFINISPAN_CORE_SCHEMA_VERSION, "0.0");
String parts[] = getParts(version);
Expand All @@ -83,7 +86,7 @@ public String version() {
}

public String brandName() {
return brandname;
return brandName;
}

/*
Expand All @@ -94,7 +97,11 @@ public static String getVersion() {
}

public static String getBrandName() {
return INSTANCE.brandname;
return INSTANCE.brandName;
}

public static String getBrandVersion() {
return INSTANCE.brandVersion;
}

public static String getCodename() {
Expand Down Expand Up @@ -181,9 +188,9 @@ public static void main(String[] args) {
* Prints full version information to the standard output.
*/
public static void printFullVersionInformation() {
System.out.println(INSTANCE.brandname);
System.out.println(INSTANCE.brandName);
System.out.println();
System.out.printf("Version: \t%s%n", INSTANCE.version);
System.out.printf("Version: \t%s%n", INSTANCE.brandVersion);
System.out.printf("Codename: \t%s%n", INSTANCE.codename);
System.out.println();
}
Expand All @@ -192,7 +199,7 @@ public static void printFullVersionInformation() {
* Returns version information as a string.
*/
public static String printVersion() {
return INSTANCE.brandname + " '" + INSTANCE.codename + "' " + INSTANCE.version;
return INSTANCE.brandName + " '" + INSTANCE.codename + "' " + INSTANCE.brandVersion;
}

private static byte[] readVersionBytes(String major, String minor, String micro, String modifier) {
Expand Down
Expand Up @@ -2,6 +2,7 @@ infinispan.version=${project.version}
infinispan.core.schema.version=${infinispan.core.schema.version}
infinispan.codename=${infinispan.codename}
infinispan.brand.name=${infinispan.brand.name}
infinispan.brand.version=${infinispan.brand.version}
infinispan.module.slot.prefix=${infinispan.module.slot.prefix}
infinispan.module.slot.version=${infinispan.base.version}
infinispan.build.commitid=${buildNumber}
Expand Down
Expand Up @@ -364,7 +364,7 @@ public synchronized CompletableFuture<ExitStatus> run() {
);
// Change status
this.status = ComponentStatus.RUNNING;
log.serverStarted(Version.getBrandName(), Version.getVersion(), timeService.timeDuration(startTime, TimeUnit.MILLISECONDS));
log.serverStarted(Version.getBrandName(), Version.getBrandVersion(), timeService.timeDuration(startTime, TimeUnit.MILLISECONDS));
} catch (Exception e) {
r.completeExceptionally(e);
}
Expand Down
Expand Up @@ -267,7 +267,7 @@ public void help(PrintStream out) {

@Override
public void version(PrintStream out) {
out.printf("%s User Tool %s (%s)\n", Version.getBrandName(), Version.getVersion(), Version.getCodename());
out.printf("%s User Tool %s\n", Version.getBrandName(), Version.getBrandVersion());
out.println("Copyright (C) Red Hat Inc. and/or its affiliates and other contributors");
out.println("License Apache License, v. 2.0. http://www.apache.org/licenses/LICENSE-2.0");
}
Expand Down
Expand Up @@ -4,6 +4,7 @@
import static org.infinispan.tools.store.migrator.Element.SIZE;

import java.io.FileReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
Expand All @@ -18,6 +19,7 @@
import org.infinispan.AdvancedCache;
import org.infinispan.commons.io.ByteBufferImpl;
import org.infinispan.commons.marshall.AdvancedExternalizer;
import org.infinispan.commons.util.Version;
import org.infinispan.container.entries.ImmortalCacheEntry;
import org.infinispan.container.entries.ImmortalCacheValue;
import org.infinispan.container.entries.InternalCacheEntry;
Expand Down Expand Up @@ -91,7 +93,7 @@ public void run() throws Exception {

void run(boolean output) throws Exception {
String batchSizeProp = properties.getProperty(BATCH + "." + SIZE);
int batchLimit = batchSizeProp != null ? new Integer(batchSizeProp) : DEFAULT_BATCH_SIZE;
int batchLimit = batchSizeProp != null ? Integer.parseInt(batchSizeProp) : DEFAULT_BATCH_SIZE;

try (EmbeddedCacheManager manager = TargetStoreFactory.getCacheManager(properties);
StoreIterator sourceReader = StoreIteratorFactory.get(properties)) {
Expand Down Expand Up @@ -127,14 +129,21 @@ void run(boolean output) throws Exception {

public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Usage: StoreMigrator migrator.properties");
version(System.out);
System.out.println("Usage: StoreMigrator migrator.properties");
System.exit(1);
}
Properties properties = new Properties();
properties.load(new FileReader(args[0]));
new StoreMigrator(properties).run(true);
}

private static void version(PrintStream out) {
out.printf("%s Store Migrator %s\n", Version.getBrandName(), Version.getBrandVersion());
out.println("Copyright (C) Red Hat Inc. and/or its affiliates and other contributors");
out.println("License Apache License, v. 2.0. http://www.apache.org/licenses/LICENSE-2.0");
}

private boolean warnAndIgnoreInternalClasses(Object o, Set<Class> extClass, boolean output) {
Class clazz = o.getClass();
boolean isBlackListed = !extClass.contains(clazz) && !clazz.isPrimitive() && INTERNAL_BLACKLIST.stream().anyMatch(c -> c.isAssignableFrom(clazz));
Expand Down

0 comments on commit bdf4c7c

Please sign in to comment.