Add distribution flavor to startup scripts

This commit adds the distribution flavor (default versus oss) to the
build process which is passed through the startup scripts to
Elasticsearch. This change will be used to customize the message on
attempting to install/remove x-pack based on the distribution flavor.
This commit is contained in:
Jason Tedor 2018-03-19 15:13:31 -04:00 committed by Ryan Ernst
parent fab5e21e7d
commit e64e6d8996
39 changed files with 180 additions and 35 deletions

View File

@ -42,14 +42,14 @@ task createPluginsDir(type: EmptyDirTask) {
dirMode 0755 dirMode 0755
} }
CopySpec archiveFiles(CopySpec modulesFiles) { CopySpec archiveFiles(CopySpec modulesFiles, boolean oss) {
return copySpec { return copySpec {
into("elasticsearch-${version}") { into("elasticsearch-${version}") {
with libFiles with libFiles
into('config') { into('config') {
dirMode 0750 dirMode 0750
fileMode 0660 fileMode 0660
with configFiles('def', false) with configFiles('def', oss)
} }
into('bin') { into('bin') {
with binFiles('def', oss) with binFiles('def', oss)
@ -58,7 +58,7 @@ CopySpec archiveFiles(CopySpec modulesFiles) {
include '*.bat' include '*.bat'
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf')) filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
} }
MavenFilteringHack.filter(it, expansionsForDistribution('def')) MavenFilteringHack.filter(it, expansionsForDistribution('def', oss))
} }
} }
into('') { into('') {
@ -94,15 +94,15 @@ tasks.withType(AbstractArchiveTask) {
} }
task buildIntegTestZip(type: Zip) { task buildIntegTestZip(type: Zip) {
with archiveFiles(transportModulesFiles) with archiveFiles(transportModulesFiles, false)
} }
task buildZip(type: Zip) { task buildZip(type: Zip) {
with archiveFiles(modulesFiles(false)) with archiveFiles(modulesFiles(false), false)
} }
task buildOssZip(type: Zip) { task buildOssZip(type: Zip) {
with archiveFiles(modulesFiles(true)) with archiveFiles(modulesFiles(true), true)
} }
Closure commonTarConfig = { Closure commonTarConfig = {
@ -114,12 +114,12 @@ Closure commonTarConfig = {
task buildTar(type: Tar) { task buildTar(type: Tar) {
configure(commonTarConfig) configure(commonTarConfig)
with archiveFiles(modulesFiles(false)) with archiveFiles(modulesFiles(false), false)
} }
task buildOssTar(type: Tar) { task buildOssTar(type: Tar) {
configure(commonTarConfig) configure(commonTarConfig)
with archiveFiles(modulesFiles(true)) with archiveFiles(modulesFiles(true), true)
} }
// This configures the default artifact for the distribution specific // This configures the default artifact for the distribution specific

View File

@ -269,7 +269,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
// main config files, processed with distribution specific substitutions // main config files, processed with distribution specific substitutions
from '../src/config' from '../src/config'
exclude 'log4j2.properties' // this is handled separately below exclude 'log4j2.properties' // this is handled separately below
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType)) MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
} }
if (oss) { if (oss) {
from project(':distribution').buildOssLog4jConfig from project(':distribution').buildOssLog4jConfig
@ -287,11 +287,10 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
// main bin files, processed with distribution specific substitutions // main bin files, processed with distribution specific substitutions
// everything except windows files // everything except windows files
from '../src/bin' from '../src/bin'
exclude '*.bat'
exclude '*.exe' exclude '*.exe'
exclude '*.bat' exclude '*.bat'
eachFile { it.setMode(0755) } eachFile { it.setMode(0755) }
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType)) MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
} }
with copySpec { with copySpec {
eachFile { it.setMode(0755) } eachFile { it.setMode(0755) }
@ -356,7 +355,7 @@ task run(type: RunTask) {
* </dl> * </dl>
*/ */
subprojects { subprojects {
ext.expansionsForDistribution = { distributionType -> ext.expansionsForDistribution = { distributionType, oss ->
final String defaultHeapSize = "1g" final String defaultHeapSize = "1g"
final String packagingPathData = "path.data: /var/lib/elasticsearch" final String packagingPathData = "path.data: /var/lib/elasticsearch"
final String pathLogs = "/var/log/elasticsearch" final String pathLogs = "/var/log/elasticsearch"
@ -427,6 +426,10 @@ subprojects {
'deb': "exit 0\n${footer}", 'deb': "exit 0\n${footer}",
'def': footer 'def': footer
], ],
'es.distribution.flavor': [
'def': oss ? 'oss' : 'default'
]
] ]
Map<String, String> result = [:] Map<String, String> result = [:]
expansions = expansions.each { key, value -> expansions = expansions.each { key, value ->

View File

@ -69,6 +69,7 @@ void addProcessFilesTask(String type, boolean oss) {
into('config') { into('config') {
with configFiles(type, oss) with configFiles(type, oss)
} }
MavenFilteringHack.filter(it, expansionsForDistribution(type, oss))
doLast { doLast {
// create empty dirs, we set the permissions when configuring the packages // create empty dirs, we set the permissions when configuring the packages
@ -150,7 +151,7 @@ Closure commonPackageConfig(String type, boolean oss) {
fileType CONFIG | NOREPLACE fileType CONFIG | NOREPLACE
from "${packagingFiles}/config" from "${packagingFiles}/config"
} }
String envFile = expansionsForDistribution(type)['path.env'] String envFile = expansionsForDistribution(type, false)['path.env']
configurationFile envFile configurationFile envFile
into(new File(envFile).getParent()) { into(new File(envFile).getParent()) {
fileType CONFIG | NOREPLACE fileType CONFIG | NOREPLACE

View File

@ -28,6 +28,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null;
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch \ org.elasticsearch.bootstrap.Elasticsearch \
"$@" "$@"
@ -37,6 +38,7 @@ else
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch \ org.elasticsearch.bootstrap.Elasticsearch \
"$@" \ "$@" \

View File

@ -77,6 +77,8 @@ fi
# now make ES_PATH_CONF absolute # now make ES_PATH_CONF absolute
ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd` ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd`
ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
if [ -z "$ES_TMPDIR" ]; then if [ -z "$ES_TMPDIR" ]; then
set +e set +e
mktemp --version 2>&1 | grep coreutils > /dev/null mktemp --version 2>&1 | grep coreutils > /dev/null

View File

@ -53,6 +53,8 @@ if not defined ES_PATH_CONF (
rem now make ES_PATH_CONF absolute rem now make ES_PATH_CONF absolute
for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI
set ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
if not defined ES_TMPDIR ( if not defined ES_TMPDIR (
set ES_TMPDIR=!TMP!\elasticsearch set ES_TMPDIR=!TMP!\elasticsearch
) )

View File

@ -7,6 +7,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.common.settings.KeyStoreCli \ org.elasticsearch.common.settings.KeyStoreCli \
"$@" "$@"

View File

@ -9,6 +9,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.common.settings.KeyStoreCli ^ org.elasticsearch.common.settings.KeyStoreCli ^
%* %*

View File

@ -7,6 +7,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.plugins.PluginCli \ org.elasticsearch.plugins.PluginCli \
"$@" "$@"

View File

@ -9,6 +9,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.plugins.PluginCli ^ org.elasticsearch.plugins.PluginCli ^
%* %*

View File

@ -159,7 +159,7 @@ if "%JVM_SS%" == "" (
goto:eof goto:eof
) )
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%" set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%";-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%"
if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0 if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0

View File

@ -7,6 +7,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.index.translog.TranslogToolCli \ org.elasticsearch.index.translog.TranslogToolCli \
"$@" "$@"

View File

@ -9,6 +9,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.index.translog.TranslogToolCli ^ org.elasticsearch.index.translog.TranslogToolCli ^
%* %*

View File

@ -51,7 +51,7 @@ if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" (
) )
cd /d "%ES_HOME%" cd /d "%ES_HOME%"
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -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%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
endlocal endlocal
endlocal endlocal

View File

@ -222,6 +222,23 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
install(terminal, isBatch, extractedZip, env); install(terminal, isBatch, extractedZip, env);
} }
Build.Flavor buildFlavor() {
return Build.CURRENT.flavor();
}
private static void handleInstallXPack(final Build.Flavor flavor) throws UserException {
switch (flavor) {
case DEFAULT:
throw new UserException(ExitCodes.CONFIG, "this distribution of Elasticsearch contains X-Pack by default");
case OSS:
throw new UserException(
ExitCodes.CONFIG,
"X-Pack is not available with the oss distribution; to use X-Pack features use the default distribution");
case UNKNOWN:
throw new IllegalStateException("your distribution is broken");
}
}
/** Downloads the plugin and returns the file it was downloaded to. */ /** Downloads the plugin and returns the file it was downloaded to. */
private Path download(Terminal terminal, String pluginId, Path tmpDir) throws Exception { private Path download(Terminal terminal, String pluginId, Path tmpDir) throws Exception {
if (OFFICIAL_PLUGINS.contains(pluginId)) { if (OFFICIAL_PLUGINS.contains(pluginId)) {

View File

@ -24,6 +24,7 @@ import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs; import com.google.common.jimfs.Jimfs;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.Build;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.ExitCodes;
import org.elasticsearch.cli.MockTerminal; import org.elasticsearch.cli.MockTerminal;
@ -890,6 +891,29 @@ public class InstallPluginCommandTests extends ESTestCase {
} }
} }
public void testInstallXPack() throws IOException {
runInstallXPackTest(Build.Flavor.DEFAULT, UserException.class, "this distribution of Elasticsearch contains X-Pack by default");
runInstallXPackTest(
Build.Flavor.OSS,
UserException.class,
"X-Pack is not available with the oss distribution; to use X-Pack features use the default distribution");
runInstallXPackTest(Build.Flavor.UNKNOWN, IllegalStateException.class, "your distribution is broken");
}
private <T extends Exception> void runInstallXPackTest(
final Build.Flavor flavor, final Class<T> clazz, final String expectedMessage) throws IOException {
final InstallPluginCommand flavorCommand = new InstallPluginCommand() {
@Override
Build.Flavor buildFlavor() {
return flavor;
}
};
final Environment environment = createEnv(fs, temp).v2();
final T exception = expectThrows(clazz, () -> flavorCommand.execute(terminal, "x-pack", false, environment));
assertThat(exception, hasToString(containsString(expectedMessage)));
}
public void testInstallMisspelledOfficialPlugins() throws Exception { public void testInstallMisspelledOfficialPlugins() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp); Tuple<Path, Environment> env = createEnv(fs, temp);

View File

@ -372,6 +372,7 @@ This command should give you a JSON result:
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : { "version" : {
"number" : "{version}", "number" : "{version}",
"build_flavor" : "oss",
"build_hash" : "f27399d", "build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z", "build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false, "build_snapshot" : false,

View File

@ -19,6 +19,7 @@ which should give you a response something like this:
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : { "version" : {
"number" : "{version}", "number" : "{version}",
"build_flavor" : "oss",
"build_hash" : "f27399d", "build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z", "build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false, "build_snapshot" : false,

View File

@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.security.CodeSource; import java.security.CodeSource;
import java.util.Objects;
import java.util.jar.JarInputStream; import java.util.jar.JarInputStream;
import java.util.jar.Manifest; import java.util.jar.Manifest;
@ -40,11 +41,45 @@ public class Build {
*/ */
public static final Build CURRENT; public static final Build CURRENT;
public enum Flavor {
DEFAULT("default"),
OSS("oss"),
UNKNOWN("unknown");
final String displayName;
Flavor(final String displayName) {
this.displayName = displayName;
}
public String displayName() {
return displayName;
}
public static Flavor fromDisplayName(final String displayName) {
switch (displayName) {
case "default":
return Flavor.DEFAULT;
case "oss":
return Flavor.OSS;
case "unknown":
return Flavor.UNKNOWN;
default:
throw new IllegalStateException("unexpected distribution flavor [" + displayName + "]; your distribution is broken");
}
}
}
static { static {
final Flavor flavor;
final String shortHash; final String shortHash;
final String date; final String date;
final boolean isSnapshot; final boolean isSnapshot;
flavor = Flavor.fromDisplayName(System.getProperty("es.distribution.flavor", "unknown"));
final String esPrefix = "elasticsearch-" + Version.CURRENT; final String esPrefix = "elasticsearch-" + Version.CURRENT;
final URL url = getElasticsearchCodeSourceLocation(); final URL url = getElasticsearchCodeSourceLocation();
final String urlStr = url == null ? "" : url.toString(); final String urlStr = url == null ? "" : url.toString();
@ -76,14 +111,14 @@ public class Build {
} }
if (shortHash == null) { if (shortHash == null) {
throw new IllegalStateException("Error finding the build shortHash. " + throw new IllegalStateException("Error finding the build shortHash. " +
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug."); "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
} }
if (date == null) { if (date == null) {
throw new IllegalStateException("Error finding the build date. " + throw new IllegalStateException("Error finding the build date. " +
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug."); "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
} }
CURRENT = new Build(shortHash, date, isSnapshot); CURRENT = new Build(flavor, shortHash, date, isSnapshot);
} }
private final boolean isSnapshot; private final boolean isSnapshot;
@ -98,10 +133,12 @@ public class Build {
return codeSource == null ? null : codeSource.getLocation(); return codeSource == null ? null : codeSource.getLocation();
} }
private final Flavor flavor;
private final String shortHash; private final String shortHash;
private final String date; private final String date;
public Build(String shortHash, String date, boolean isSnapshot) { public Build(Flavor flavor, String shortHash, String date, boolean isSnapshot) {
this.flavor = flavor;
this.shortHash = shortHash; this.shortHash = shortHash;
this.date = date; this.date = date;
this.isSnapshot = isSnapshot; this.isSnapshot = isSnapshot;
@ -116,25 +153,38 @@ public class Build {
} }
public static Build readBuild(StreamInput in) throws IOException { public static Build readBuild(StreamInput in) throws IOException {
final Flavor flavor;
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
flavor = Flavor.fromDisplayName(in.readString());
} else {
flavor = Flavor.OSS;
}
String hash = in.readString(); String hash = in.readString();
String date = in.readString(); String date = in.readString();
boolean snapshot = in.readBoolean(); boolean snapshot = in.readBoolean();
return new Build(hash, date, snapshot); return new Build(flavor, hash, date, snapshot);
} }
public static void writeBuild(Build build, StreamOutput out) throws IOException { public static void writeBuild(Build build, StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
out.writeString(build.flavor().displayName());
}
out.writeString(build.shortHash()); out.writeString(build.shortHash());
out.writeString(build.date()); out.writeString(build.date());
out.writeBoolean(build.isSnapshot()); out.writeBoolean(build.isSnapshot());
} }
public Flavor flavor() {
return flavor;
}
public boolean isSnapshot() { public boolean isSnapshot() {
return isSnapshot; return isSnapshot;
} }
@Override @Override
public String toString() { public String toString() {
return "[" + shortHash + "][" + date + "]"; return "[" + flavor.displayName() + "][" + shortHash + "][" + date + "]";
} }
@Override @Override
@ -148,6 +198,10 @@ public class Build {
Build build = (Build) o; Build build = (Build) o;
if (!flavor.equals(build.flavor)) {
return false;
}
if (isSnapshot != build.isSnapshot) { if (isSnapshot != build.isSnapshot) {
return false; return false;
} }
@ -160,9 +214,7 @@ public class Build {
@Override @Override
public int hashCode() { public int hashCode() {
int result = (isSnapshot ? 1 : 0); return Objects.hash(flavor, isSnapshot, shortHash, date);
result = 31 * result + shortHash.hashCode();
result = 31 * result + date.hashCode();
return result;
} }
} }

View File

@ -107,6 +107,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
builder.field("cluster_uuid", clusterUuid); builder.field("cluster_uuid", clusterUuid);
builder.startObject("version") builder.startObject("version")
.field("number", version.toString()) .field("number", version.toString())
.field("build_flavor", build.flavor().displayName())
.field("build_hash", build.shortHash()) .field("build_hash", build.shortHash())
.field("build_date", build.date()) .field("build_date", build.date())
.field("build_snapshot", build.isSnapshot()) .field("build_snapshot", build.isSnapshot())
@ -128,8 +129,13 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
PARSER.declareString((response, value) -> response.clusterUuid = value, new ParseField("cluster_uuid")); PARSER.declareString((response, value) -> response.clusterUuid = value, new ParseField("cluster_uuid"));
PARSER.declareString((response, value) -> {}, new ParseField("tagline")); PARSER.declareString((response, value) -> {}, new ParseField("tagline"));
PARSER.declareObject((response, value) -> { PARSER.declareObject((response, value) -> {
response.build = new Build((String) value.get("build_hash"), (String) value.get("build_date"), final String buildFlavor = (String) value.get("build_flavor");
(boolean) value.get("build_snapshot")); response.build =
new Build(
buildFlavor == null ? Build.Flavor.UNKNOWN : Build.Flavor.fromDisplayName(buildFlavor),
(String) value.get("build_hash"),
(String) value.get("build_date"),
(boolean) value.get("build_snapshot"));
response.version = Version.fromString((String) value.get("number")); response.version = Version.fromString((String) value.get("number"));
}, (parser, context) -> parser.map(), new ParseField("version")); }, (parser, context) -> parser.map(), new ParseField("version"));
} }

View File

@ -284,9 +284,10 @@ public class Node implements Closeable {
final JvmInfo jvmInfo = JvmInfo.jvmInfo(); final JvmInfo jvmInfo = JvmInfo.jvmInfo();
logger.info( logger.info(
"version[{}], pid[{}], build[{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", "version[{}], pid[{}], build[{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]",
Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()),
jvmInfo.pid(), jvmInfo.pid(),
Build.CURRENT.flavor().displayName(),
Build.CURRENT.shortHash(), Build.CURRENT.shortHash(),
Build.CURRENT.date(), Build.CURRENT.date(),
Constants.OS_NAME, Constants.OS_NAME,

View File

@ -25,6 +25,9 @@ import org.elasticsearch.test.ESTestCase;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
public class BuildTests extends ESTestCase { public class BuildTests extends ESTestCase {
@ -40,17 +43,23 @@ public class BuildTests extends ESTestCase {
public void testEqualsAndHashCode() { public void testEqualsAndHashCode() {
Build build = Build.CURRENT; Build build = Build.CURRENT;
Build another = new Build(build.shortHash(), build.date(), build.isSnapshot());
Build another = new Build(build.flavor(), build.shortHash(), build.date(), build.isSnapshot());
assertEquals(build, another); assertEquals(build, another);
assertEquals(build.hashCode(), another.hashCode()); assertEquals(build.hashCode(), another.hashCode());
Build differentHash = new Build(randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot()); final Set<Build.Flavor> 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());
assertNotEquals(build, differentFlavor);
Build differentHash = new Build(build.flavor(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot());
assertNotEquals(build, differentHash); assertNotEquals(build, differentHash);
Build differentDate = new Build(build.shortHash(), "1970-01-01", build.isSnapshot()); Build differentDate = new Build(build.flavor(), build.shortHash(), "1970-01-01", build.isSnapshot());
assertNotEquals(build, differentDate); assertNotEquals(build, differentDate);
Build differentSnapshot = new Build(build.shortHash(), build.date(), !build.isSnapshot()); Build differentSnapshot = new Build(build.flavor(), build.shortHash(), build.date(), !build.isSnapshot());
assertNotEquals(build, differentSnapshot); assertNotEquals(build, differentSnapshot);
} }
} }

View File

@ -40,7 +40,8 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
String clusterUuid = randomAlphaOfLength(10); String clusterUuid = randomAlphaOfLength(10);
ClusterName clusterName = new ClusterName(randomAlphaOfLength(10)); ClusterName clusterName = new ClusterName(randomAlphaOfLength(10));
String nodeName = randomAlphaOfLength(10); String nodeName = randomAlphaOfLength(10);
Build build = new Build(randomAlphaOfLength(8), new Date(randomNonNegativeLong()).toString(), randomBoolean()); Build build =
new Build(Build.Flavor.UNKNOWN, randomAlphaOfLength(8), new Date(randomNonNegativeLong()).toString(), randomBoolean());
Version version = VersionUtils.randomVersion(random()); Version version = VersionUtils.randomVersion(random());
return new MainResponse(nodeName, version, clusterName, clusterUuid , build); return new MainResponse(nodeName, version, clusterName, clusterUuid , build);
} }
@ -57,7 +58,7 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
public void testToXContent() throws IOException { public void testToXContent() throws IOException {
String clusterUUID = randomAlphaOfLengthBetween(10, 20); String clusterUUID = randomAlphaOfLengthBetween(10, 20);
Build build = new Build(Build.CURRENT.shortHash(), Build.CURRENT.date(), Build.CURRENT.isSnapshot()); Build build = new Build(Build.CURRENT.flavor(), Build.CURRENT.shortHash(), Build.CURRENT.date(), Build.CURRENT.isSnapshot());
Version version = Version.CURRENT; Version version = Version.CURRENT;
MainResponse response = new MainResponse("nodeName", version, new ClusterName("clusterName"), clusterUUID, build); MainResponse response = new MainResponse("nodeName", version, new ClusterName("clusterName"), clusterUUID, build);
XContentBuilder builder = XContentFactory.jsonBuilder(); XContentBuilder builder = XContentFactory.jsonBuilder();
@ -68,6 +69,7 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
+ "\"cluster_uuid\":\"" + clusterUUID + "\"," + "\"cluster_uuid\":\"" + clusterUUID + "\","
+ "\"version\":{" + "\"version\":{"
+ "\"number\":\"" + version.toString() + "\"," + "\"number\":\"" + version.toString() + "\","
+ "\"build_flavor\":\"" + Build.CURRENT.flavor().displayName() + "\","
+ "\"build_hash\":\"" + Build.CURRENT.shortHash() + "\"," + "\"build_hash\":\"" + Build.CURRENT.shortHash() + "\","
+ "\"build_date\":\"" + Build.CURRENT.date() + "\"," + "\"build_date\":\"" + Build.CURRENT.date() + "\","
+ "\"build_snapshot\":" + Build.CURRENT.isSnapshot() + "," + "\"build_snapshot\":" + Build.CURRENT.isSnapshot() + ","
@ -94,7 +96,7 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
break; break;
case 2: case 2:
// toggle the snapshot flag of the original Build parameter // toggle the snapshot flag of the original Build parameter
build = new Build(build.shortHash(), build.date(), !build.isSnapshot()); build = new Build(Build.Flavor.UNKNOWN, build.shortHash(), build.date(), !build.isSnapshot());
break; break;
case 3: case 3:
version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random())); version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random()));

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.core.ssl.CertificateGenerateTool \ org.elasticsearch.xpack.core.ssl.CertificateGenerateTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^ org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.core.ssl.CertificateTool \ org.elasticsearch.xpack.core.ssl.CertificateTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.core.ssl.CertificateTool ^ org.elasticsearch.xpack.core.ssl.CertificateTool ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool \ org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^ org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand \ org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^ org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool \ org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^ org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool \ org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^ org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.security.authc.file.tool.UsersTool \ org.elasticsearch.xpack.security.authc.file.tool.UsersTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^ org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^
%* %*

View File

@ -13,6 +13,7 @@ exec \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \ -Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool \ org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool \
"$@" "$@"

View File

@ -15,6 +15,7 @@ call "%~dp0x-pack-watcher-env.bat" || exit /b 1
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^ org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^
%* %*