diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java index c0de571226c..b4d8828eb7e 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java @@ -42,6 +42,8 @@ public class PingAndInfoIT extends ESRestHighLevelClientTestCase { // only check node name existence, might be a different one from what was hit by low level client in multi-node cluster assertNotNull(info.getNodeName()); Map versionMap = (Map) infoAsMap.get("version"); + assertEquals(versionMap.get("build_flavor"), info.getBuild().flavor().displayName()); + assertEquals(versionMap.get("build_type"), info.getBuild().type().displayName()); assertEquals(versionMap.get("build_hash"), info.getBuild().shortHash()); assertEquals(versionMap.get("build_date"), info.getBuild().date()); assertEquals(versionMap.get("build_snapshot"), info.getBuild().isSnapshot()); diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index f631bc7558d..b5bf2aaf5a2 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -42,23 +42,23 @@ task createPluginsDir(type: EmptyDirTask) { dirMode 0755 } -CopySpec archiveFiles(CopySpec modulesFiles, boolean oss) { +CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, boolean oss) { return copySpec { into("elasticsearch-${version}") { with libFiles into('config') { dirMode 0750 fileMode 0660 - with configFiles('def', oss) + with configFiles(distributionType, oss) } into('bin') { - with binFiles('def', oss) + with binFiles(distributionType, oss) with copySpec { from('../src/bin') { include '*.bat' filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf')) } - MavenFilteringHack.filter(it, expansionsForDistribution('def', oss)) + MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss)) } } into('') { @@ -101,15 +101,15 @@ tasks.withType(AbstractArchiveTask) { } task buildIntegTestZip(type: Zip) { - with archiveFiles(transportModulesFiles, false) + with archiveFiles(transportModulesFiles, 'zip', false) } task buildZip(type: Zip) { - with archiveFiles(modulesFiles(false), false) + with archiveFiles(modulesFiles(false), 'zip', false) } task buildOssZip(type: Zip) { - with archiveFiles(modulesFiles(true), true) + with archiveFiles(modulesFiles(true), 'zip', true) } Closure commonTarConfig = { @@ -121,12 +121,12 @@ Closure commonTarConfig = { task buildTar(type: Tar) { configure(commonTarConfig) - with archiveFiles(modulesFiles(false), false) + with archiveFiles(modulesFiles(false), 'tar', false) } task buildOssTar(type: Tar) { configure(commonTarConfig) - with archiveFiles(modulesFiles(true), true) + with archiveFiles(modulesFiles(true), 'tar', true) } // This configures the default artifact for the distribution specific diff --git a/distribution/build.gradle b/distribution/build.gradle index 3dfb30dabee..e528cacbd77 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -434,6 +434,14 @@ subprojects { 'def': oss ? 'oss' : 'default' ], + + 'es.distribution.type': [ + 'deb': 'deb', + 'rpm': 'rpm', + 'tar': 'tar', + 'zip': 'zip' + ], + 'license.name': [ 'deb': oss ? 'ASL-2.0' : 'Elastic-License' ], diff --git a/distribution/src/bin/elasticsearch b/distribution/src/bin/elasticsearch index 9eff8c95e5d..84e14eea3f6 100755 --- a/distribution/src/bin/elasticsearch +++ b/distribution/src/bin/elasticsearch @@ -29,6 +29,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.bootstrap.Elasticsearch \ "$@" @@ -39,6 +40,7 @@ else -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.bootstrap.Elasticsearch \ "$@" \ diff --git a/distribution/src/bin/elasticsearch-env b/distribution/src/bin/elasticsearch-env index e43ec78872b..9d58d88e7aa 100644 --- a/distribution/src/bin/elasticsearch-env +++ b/distribution/src/bin/elasticsearch-env @@ -78,6 +78,7 @@ fi ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd` ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor} +ES_DISTRIBUTION_TYPE=${es.distribution.type} if [ -z "$ES_TMPDIR" ]; then set +e diff --git a/distribution/src/bin/elasticsearch-env.bat b/distribution/src/bin/elasticsearch-env.bat index 0b80b463844..b0d015924b4 100644 --- a/distribution/src/bin/elasticsearch-env.bat +++ b/distribution/src/bin/elasticsearch-env.bat @@ -54,6 +54,7 @@ rem now make ES_PATH_CONF absolute for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI set ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor} +set ES_DISTRIBUTION_TYPE=${es.distribution.type} if not defined ES_TMPDIR ( set ES_TMPDIR=!TMP!\elasticsearch diff --git a/distribution/src/bin/elasticsearch-keystore b/distribution/src/bin/elasticsearch-keystore index 9f40effe871..aee62dfde50 100755 --- a/distribution/src/bin/elasticsearch-keystore +++ b/distribution/src/bin/elasticsearch-keystore @@ -8,6 +8,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.common.settings.KeyStoreCli \ "$@" diff --git a/distribution/src/bin/elasticsearch-keystore.bat b/distribution/src/bin/elasticsearch-keystore.bat index b9d0370be76..1d6616983d8 100644 --- a/distribution/src/bin/elasticsearch-keystore.bat +++ b/distribution/src/bin/elasticsearch-keystore.bat @@ -10,6 +10,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.common.settings.KeyStoreCli ^ %* diff --git a/distribution/src/bin/elasticsearch-plugin b/distribution/src/bin/elasticsearch-plugin index 8a7ad422752..500fd710c1a 100755 --- a/distribution/src/bin/elasticsearch-plugin +++ b/distribution/src/bin/elasticsearch-plugin @@ -8,6 +8,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.plugins.PluginCli \ "$@" diff --git a/distribution/src/bin/elasticsearch-plugin.bat b/distribution/src/bin/elasticsearch-plugin.bat index dc0e1de0804..b3b94a31863 100644 --- a/distribution/src/bin/elasticsearch-plugin.bat +++ b/distribution/src/bin/elasticsearch-plugin.bat @@ -10,6 +10,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.plugins.PluginCli ^ %* diff --git a/distribution/src/bin/elasticsearch-service.bat b/distribution/src/bin/elasticsearch-service.bat index 91e897586fa..a1d0f04560e 100644 --- a/distribution/src/bin/elasticsearch-service.bat +++ b/distribution/src/bin/elasticsearch-service.bat @@ -159,7 +159,7 @@ if "%JVM_SS%" == "" ( goto:eof ) -set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%";-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" +set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%";-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%";-Des.distribution.type="%ES_DISTRIBUTION_TYPE%" if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0 diff --git a/distribution/src/bin/elasticsearch-translog b/distribution/src/bin/elasticsearch-translog index 140df7db56e..e176231c6f4 100755 --- a/distribution/src/bin/elasticsearch-translog +++ b/distribution/src/bin/elasticsearch-translog @@ -8,6 +8,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.index.translog.TranslogToolCli \ "$@" diff --git a/distribution/src/bin/elasticsearch-translog.bat b/distribution/src/bin/elasticsearch-translog.bat index 91c6a650947..492c1f08312 100644 --- a/distribution/src/bin/elasticsearch-translog.bat +++ b/distribution/src/bin/elasticsearch-translog.bat @@ -10,6 +10,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.index.translog.TranslogToolCli ^ %* diff --git a/distribution/src/bin/elasticsearch.bat b/distribution/src/bin/elasticsearch.bat index 7bb00114c4d..6e268c9b133 100644 --- a/distribution/src/bin/elasticsearch.bat +++ b/distribution/src/bin/elasticsearch.bat @@ -51,7 +51,7 @@ if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" ( ) cd /d "%ES_HOME%" -%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams! +%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams! endlocal endlocal diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index 76eead7ed05..c56991b8f50 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -373,6 +373,7 @@ This command should give you a JSON result: "version" : { "number" : "{version}", "build_flavor" : "oss", + "build_type" : "zip", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, diff --git a/docs/reference/cluster/nodes-info.asciidoc b/docs/reference/cluster/nodes-info.asciidoc index 2b91310da3a..6522d0f5ad6 100644 --- a/docs/reference/cluster/nodes-info.asciidoc +++ b/docs/reference/cluster/nodes-info.asciidoc @@ -142,6 +142,8 @@ The result will look similar to: "host": "node-0.elastic.co", "ip": "192.168.17", "version": "{version}", + "build_flavor": "oss", + "build_type": "zip", "build_hash": "587409e", "roles": [ "master", @@ -235,6 +237,8 @@ The result will look similar to: "host": "node-0.elastic.co", "ip": "192.168.17", "version": "{version}", + "build_flavor": "oss", + "build_type": "zip", "build_hash": "587409e", "roles": [], "attributes": {}, diff --git a/docs/reference/setup/install/check-running.asciidoc b/docs/reference/setup/install/check-running.asciidoc index 96fcbbe331a..0cfc4b329ec 100644 --- a/docs/reference/setup/install/check-running.asciidoc +++ b/docs/reference/setup/install/check-running.asciidoc @@ -20,6 +20,7 @@ which should give you a response something like this: "version" : { "number" : "{version}", "build_flavor" : "oss", + "build_type" : "zip", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, diff --git a/server/src/main/java/org/elasticsearch/Build.java b/server/src/main/java/org/elasticsearch/Build.java index d4779b78a5b..9021e2d4c1f 100644 --- a/server/src/main/java/org/elasticsearch/Build.java +++ b/server/src/main/java/org/elasticsearch/Build.java @@ -72,13 +72,51 @@ public class Build { } + public enum Type { + + DEB("deb"), + RPM("rpm"), + TAR("tar"), + ZIP("zip"), + UNKNOWN("unknown"); + + final String displayName; + + public String displayName() { + return displayName; + } + + Type(final String displayName) { + this.displayName = displayName; + } + + public static Type fromDisplayName(final String displayName) { + switch (displayName) { + case "deb": + return Type.DEB; + case "rpm": + return Type.RPM; + case "tar": + return Type.TAR; + case "zip": + return Type.ZIP; + case "unknown": + return Type.UNKNOWN; + default: + throw new IllegalStateException("unexpected distribution type [" + displayName + "]; your distribution is broken"); + } + } + } + static { final Flavor flavor; + final Type type; final String shortHash; final String date; final boolean isSnapshot; flavor = Flavor.fromDisplayName(System.getProperty("es.distribution.flavor", "unknown")); + type = Type.fromDisplayName(System.getProperty("es.distribution.type", "unknown")); final String esPrefix = "elasticsearch-" + Version.CURRENT; final URL url = getElasticsearchCodeSourceLocation(); @@ -118,7 +156,7 @@ public class Build { "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug."); } - CURRENT = new Build(flavor, shortHash, date, isSnapshot); + CURRENT = new Build(flavor, type, shortHash, date, isSnapshot); } private final boolean isSnapshot; @@ -134,11 +172,13 @@ public class Build { } private final Flavor flavor; + private final Type type; private final String shortHash; private final String date; - public Build(Flavor flavor, String shortHash, String date, boolean isSnapshot) { + public Build(final Flavor flavor, final Type type, final String shortHash, final String date, boolean isSnapshot) { this.flavor = flavor; + this.type = type; this.shortHash = shortHash; this.date = date; this.isSnapshot = isSnapshot; @@ -154,21 +194,30 @@ public class Build { public static Build readBuild(StreamInput in) throws IOException { final Flavor flavor; + final Type type; if (in.getVersion().onOrAfter(Version.V_6_3_0)) { flavor = Flavor.fromDisplayName(in.readString()); } else { flavor = Flavor.OSS; } + if (in.getVersion().onOrAfter(Version.V_6_3_0)) { + type = Type.fromDisplayName(in.readString()); + } else { + type = Type.UNKNOWN; + } String hash = in.readString(); String date = in.readString(); boolean snapshot = in.readBoolean(); - return new Build(flavor, hash, date, snapshot); + return new Build(flavor, type, hash, date, snapshot); } public static void writeBuild(Build build, StreamOutput out) throws IOException { if (out.getVersion().onOrAfter(Version.V_6_3_0)) { out.writeString(build.flavor().displayName()); } + if (out.getVersion().onOrAfter(Version.V_6_3_0)) { + out.writeString(build.type().displayName()); + } out.writeString(build.shortHash()); out.writeString(build.date()); out.writeBoolean(build.isSnapshot()); @@ -178,13 +227,17 @@ public class Build { return flavor; } + public Type type() { + return type; + } + public boolean isSnapshot() { return isSnapshot; } @Override public String toString() { - return "[" + flavor.displayName() + "][" + shortHash + "][" + date + "]"; + return "[" + flavor.displayName() + "][" + type.displayName + "][" + shortHash + "][" + date + "]"; } @Override @@ -202,6 +255,10 @@ public class Build { return false; } + if (!type.equals(build.type)) { + return false; + } + if (isSnapshot != build.isSnapshot) { return false; } @@ -214,7 +271,7 @@ public class Build { @Override public int hashCode() { - return Objects.hash(flavor, isSnapshot, shortHash, date); + return Objects.hash(flavor, type, isSnapshot, shortHash, date); } } diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index d8ef145a4a5..7e5a46c7d4e 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -35,6 +35,7 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; public class Version implements Comparable, ToXContentFragment { /* @@ -502,8 +503,16 @@ public class Version implements Comparable, ToXContentFragment { @SuppressForbidden(reason = "System.out.*") public static void main(String[] args) { - System.out.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date() + ", JVM: " - + JvmInfo.jvmInfo().version()); + final String versionOutput = String.format( + Locale.ROOT, + "Version: %s, Build: %s/%s/%s/%s, JVM: %s", + Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), + Build.CURRENT.flavor().displayName(), + Build.CURRENT.type().displayName(), + Build.CURRENT.shortHash(), + Build.CURRENT.date(), + JvmInfo.jvmInfo().version()); + System.out.println(versionOutput); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index 09ac7e6aa13..3bee722a472 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -66,6 +66,8 @@ public class NodesInfoResponse extends BaseNodesResponse implements To builder.field("ip", nodeInfo.getNode().getHostAddress()); builder.field("version", nodeInfo.getVersion()); + builder.field("build_flavor", nodeInfo.getBuild().flavor().displayName()); + builder.field("build_type", nodeInfo.getBuild().type().displayName()); builder.field("build_hash", nodeInfo.getBuild().shortHash()); if (nodeInfo.getTotalIndexingBuffer() != null) { builder.humanReadableField("total_indexing_buffer", "total_indexing_buffer_in_bytes", nodeInfo.getTotalIndexingBuffer()); diff --git a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java index 1130c1c408e..6cae1056a4b 100644 --- a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java +++ b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java @@ -108,6 +108,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject { builder.startObject("version") .field("number", version.toString()) .field("build_flavor", build.flavor().displayName()) + .field("build_type", build.type().displayName()) .field("build_hash", build.shortHash()) .field("build_date", build.date()) .field("build_snapshot", build.isSnapshot()) @@ -130,9 +131,11 @@ public class MainResponse extends ActionResponse implements ToXContentObject { PARSER.declareString((response, value) -> {}, new ParseField("tagline")); PARSER.declareObject((response, value) -> { final String buildFlavor = (String) value.get("build_flavor"); + final String buildType = (String) value.get("build_type"); response.build = new Build( buildFlavor == null ? Build.Flavor.UNKNOWN : Build.Flavor.fromDisplayName(buildFlavor), + buildType == null ? Build.Type.UNKNOWN : Build.Type.fromDisplayName(buildType), (String) value.get("build_hash"), (String) value.get("build_date"), (boolean) value.get("build_snapshot")); diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java index a0646288b1a..6296b611c15 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java @@ -38,6 +38,7 @@ import java.io.IOException; import java.nio.file.Path; import java.security.Permission; import java.util.Arrays; +import java.util.Locale; /** * This class starts elasticsearch. @@ -98,9 +99,16 @@ class Elasticsearch extends EnvironmentAwareCommand { throw new UserException(ExitCodes.USAGE, "Positional arguments not allowed, found " + options.nonOptionArguments()); } if (options.has(versionOption)) { - terminal.println("Version: " + Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()) - + ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date() - + ", JVM: " + JvmInfo.jvmInfo().version()); + final String versionOutput = String.format( + Locale.ROOT, + "Version: %s, Build: %s/%s/%s/%s, JVM: %s", + Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), + Build.CURRENT.flavor().displayName(), + Build.CURRENT.type().displayName(), + Build.CURRENT.shortHash(), + Build.CURRENT.date(), + JvmInfo.jvmInfo().version()); + terminal.println(versionOutput); return; } diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index d9f0027277a..cb7586b3d02 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -284,10 +284,11 @@ public class Node implements Closeable { final JvmInfo jvmInfo = JvmInfo.jvmInfo(); logger.info( - "version[{}], pid[{}], build[{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", + "version[{}], pid[{}], build[{}/{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), jvmInfo.pid(), Build.CURRENT.flavor().displayName(), + Build.CURRENT.type().displayName(), Build.CURRENT.shortHash(), Build.CURRENT.date(), Constants.OS_NAME, diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index c232ec25322..b3c480a2e7b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -123,6 +123,8 @@ public class RestNodesAction extends AbstractCatAction { table.addCell("http_address", "default:false;alias:http;desc:bound http address"); table.addCell("version", "default:false;alias:v;desc:es version"); + table.addCell("flavor", "default:false;alias:f;desc:es distribution flavor"); + table.addCell("type", "default:false;alias:t;desc:es distribution type"); table.addCell("build", "default:false;alias:b;desc:es build hash"); table.addCell("jdk", "default:false;alias:j;desc:jdk version"); table.addCell("disk.total", "default:false;alias:dt,diskTotal;text-align:right;desc:total disk space"); @@ -271,6 +273,8 @@ public class RestNodesAction extends AbstractCatAction { } table.addCell(node.getVersion().toString()); + table.addCell(info == null ? null : info.getBuild().flavor().displayName()); + table.addCell(info == null ? null : info.getBuild().type().displayName()); table.addCell(info == null ? null : info.getBuild().shortHash()); table.addCell(jvmInfo == null ? null : jvmInfo.version()); diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index d50ebfc0126..c2b0f3acb94 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -44,22 +44,29 @@ public class BuildTests extends ESTestCase { public void testEqualsAndHashCode() { Build build = Build.CURRENT; - Build another = new Build(build.flavor(), build.shortHash(), build.date(), build.isSnapshot()); + Build another = new Build(build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot()); assertEquals(build, another); assertEquals(build.hashCode(), another.hashCode()); final Set otherFlavors = Arrays.stream(Build.Flavor.values()).filter(f -> !f.equals(build.flavor())).collect(Collectors.toSet()); - Build differentFlavor = new Build(randomFrom(otherFlavors), build.shortHash(), build.date(), build.isSnapshot()); + final Build.Flavor otherFlavor = randomFrom(otherFlavors); + Build differentFlavor = new Build(otherFlavor, build.type(), build.shortHash(), build.date(), build.isSnapshot()); assertNotEquals(build, differentFlavor); - Build differentHash = new Build(build.flavor(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot()); + final Set otherTypes = + Arrays.stream(Build.Type.values()).filter(f -> !f.equals(build.type())).collect(Collectors.toSet()); + final Build.Type otherType = randomFrom(otherTypes); + Build differentType = new Build(build.flavor(), otherType, build.shortHash(), build.date(), build.isSnapshot()); + assertNotEquals(build, differentType); + + Build differentHash = new Build(build.flavor(), build.type(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot()); assertNotEquals(build, differentHash); - Build differentDate = new Build(build.flavor(), build.shortHash(), "1970-01-01", build.isSnapshot()); + Build differentDate = new Build(build.flavor(), build.type(), build.shortHash(), "1970-01-01", build.isSnapshot()); assertNotEquals(build, differentDate); - Build differentSnapshot = new Build(build.flavor(), build.shortHash(), build.date(), !build.isSnapshot()); + Build differentSnapshot = new Build(build.flavor(), build.type(), build.shortHash(), build.date(), !build.isSnapshot()); assertNotEquals(build, differentSnapshot); } } diff --git a/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java b/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java index 7651c94c391..b833ed674c0 100644 --- a/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java @@ -40,8 +40,8 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase VersionUtils.randomVersion(random())); diff --git a/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java b/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java index bcc70773146..b3e9eda4e13 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.monitor.jvm.JvmInfo; import java.nio.file.Path; +import java.util.Locale; import java.util.Map; import java.util.function.Consumer; @@ -65,7 +66,14 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase { private void runTestThatVersionIsReturned(String... args) throws Exception { runTestVersion(ExitCodes.OK, output -> { assertThat(output, containsString("Version: " + Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()))); - assertThat(output, containsString("Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date())); + final String expectedBuildOutput = String.format( + Locale.ROOT, + "Build: %s/%s/%s/%s", + Build.CURRENT.flavor().displayName(), + Build.CURRENT.type().displayName(), + Build.CURRENT.shortHash(), + Build.CURRENT.date()); + assertThat(output, containsString(expectedBuildOutput)); assertThat(output, containsString("JVM: " + JvmInfo.jvmInfo().version())); }, args); } diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-certgen b/x-pack/plugin/security/src/main/bin/elasticsearch-certgen index 9c059877c06..d56ae2f4d1a 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-certgen +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-certgen @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.core.ssl.CertificateGenerateTool \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat index 2b66e4b2f88..d44ca227c07 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^ %* diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-certutil b/x-pack/plugin/security/src/main/bin/elasticsearch-certutil index 29556b8bd65..c2502bd734f 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-certutil +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-certutil @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.core.ssl.CertificateTool \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat index 5b3a62262b0..4426fb87d3b 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.core.ssl.CertificateTool ^ %* diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-migrate b/x-pack/plugin/security/src/main/bin/elasticsearch-migrate index da49346fa0e..eb3c81febdf 100755 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-migrate +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-migrate @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat index 98ad6663582..79090b64907 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^ %* diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata b/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata index 7ad46be1cd0..92200d82e12 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat index 1bb42d1832a..9e5625d0b91 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^ %* diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords b/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords index 3b68426e773..e6aaa00d647 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat index 41b7cc9438d..b449ca09a6c 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^ %* diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen b/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen index eed48bb0a63..e8c4f10c044 100755 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat index fb6c4545c10..3ee9dcb3ba9 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^ %* diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-users b/x-pack/plugin/security/src/main/bin/elasticsearch-users index bb76e175cad..2d9ed8df93d 100755 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-users +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-users @@ -14,6 +14,7 @@ exec \ -Des.path.home="$ES_HOME" \ -Des.path.conf="$ES_PATH_CONF" \ -Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \ + -Des.distribution.type="$ES_DISTRIBUTION_TYPE" \ -cp "$ES_CLASSPATH" \ org.elasticsearch.xpack.security.authc.file.tool.UsersTool \ "$@" diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat index 7028b6ab44a..b32b9398f99 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^ %* diff --git a/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli.bat b/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli.bat index 165c4f1de3d..12173877649 100644 --- a/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli.bat +++ b/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli.bat @@ -15,6 +15,8 @@ set CLI_JAR=%ES_HOME%/plugins/bin/* %JAVA% ^ -cp "%CLI_JAR%" ^ + -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ org.elasticsearch.xpack.sql.cli.Cli ^ %* diff --git a/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat b/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat index 436f35bac91..7fd983c9ba5 100644 --- a/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat +++ b/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat @@ -16,6 +16,7 @@ call "%~dp0x-pack-watcher-env.bat" || exit /b 1 -Des.path.home="%ES_HOME%" ^ -Des.path.conf="%ES_PATH_CONF%" ^ -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^ + -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^ -cp "%ES_CLASSPATH%" ^ org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^ %*