Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions distribution/src/bin/elasticsearch-cli
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exec \
-Des.path.home="$ES_HOME" \
-Des.path.conf="$ES_PATH_CONF" \
-Des.distribution.type="$ES_DISTRIBUTION_TYPE" \
-Des.java.type="$JAVA_TYPE" \
-cp "$LAUNCHER_CLASSPATH" \
org.elasticsearch.launcher.CliToolLauncher \
"$@"
1 change: 1 addition & 0 deletions distribution/src/bin/elasticsearch-cli.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set LAUNCHER_CLASSPATH=%ES_HOME%/lib/*;%ES_HOME%/lib/cli-launcher/*
-Des.path.home="%ES_HOME%" ^
-Des.path.conf="%ES_PATH_CONF%" ^
-Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^
-Des.java.type="%JAVA_TYPE%" ^
-cp "%LAUNCHER_CLASSPATH%" ^
org.elasticsearch.launcher.CliToolLauncher ^
%*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ final class SystemJvmOptions {

static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, String> sysprops) {
String distroType = sysprops.get("es.distribution.type");
String javaType = sysprops.get("es.java.type");
boolean isHotspot = sysprops.getOrDefault("sun.management.compiler", "").contains("HotSpot");
boolean entitlementsExplicitlyEnabled = Booleans.parseBoolean(sysprops.getOrDefault("es.entitlements.enabled", "true"));
// java 24+ only supports entitlements, but it may be enabled on earlier versions explicitly
Expand Down Expand Up @@ -68,8 +69,9 @@ static List<String> systemJvmOptions(Settings nodeSettings, final Map<String, St
"-Djava.locale.providers=CLDR",
// Enable vectorization for whatever version we are running. This ensures we use vectorization even when running EA builds.
"-Dorg.apache.lucene.vectorization.upperJavaFeatureVersion=" + Runtime.version().feature(),
// Pass through distribution type
"-Des.distribution.type=" + distroType
// Pass through distribution type and java type
"-Des.distribution.type=" + distroType,
"-Des.java.type=" + javaType
),
maybeEnableNativeAccess(useEntitlements),
maybeOverrideDockerCgroup(distroType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.VectorUtil;
import org.elasticsearch.Build;
Expand Down Expand Up @@ -57,6 +58,7 @@
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.invoke.MethodHandles;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -66,6 +68,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -176,6 +179,9 @@ public void checkPermission(Permission perm) {
* <p> Phase 2 consists of everything that must occur up to and including security manager initialization.
*/
private static void initPhase2(Bootstrap bootstrap) throws IOException {
// always start by dumping what we know about the process to the log
logSystemInfo();

final ServerArgs args = bootstrap.args();
final SecureSettings secrets = args.secrets();
bootstrap.setSecureSettings(secrets);
Expand Down Expand Up @@ -285,6 +291,35 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException {
bootstrap.setPluginsLoader(pluginsLoader);
}

private static void logSystemInfo() {
final Logger logger = LogManager.getLogger(Elasticsearch.class);
logger.info(
"version[{}], pid[{}], build[{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]",
Build.current().qualifiedVersion(),
ProcessHandle.current().pid(),
Build.current().type().displayName(),
Build.current().hash(),
Build.current().date(),
Constants.OS_NAME,
Constants.OS_VERSION,
Constants.OS_ARCH,
Constants.JVM_VENDOR,
Constants.JVM_NAME,
System.getProperty("java.version"),
Runtime.version().toString()
);
boolean isBundledJdk = System.getProperty("es.java.type", "").equals("bundled JDK");
logger.info("JVM home [{}], using bundled JDK [{}]", System.getProperty("java.home"), isBundledJdk);
logger.info("JVM arguments {}", ManagementFactory.getRuntimeMXBean().getInputArguments());
logger.info("Default Locale [{}]", Locale.getDefault());
if (Build.current().isProductionRelease() == false) {
logger.warn(
"version [{}] is a pre-release version of Elasticsearch and is not suitable for production",
Build.current().qualifiedVersion()
);
}
}

private static Map<String, String> collectPluginPolicyOverrides(
Set<PluginBundle> modulesBundles,
Set<PluginBundle> pluginsBundles,
Expand Down
16 changes: 1 addition & 15 deletions server/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@

package org.elasticsearch.monitor.jvm;

import org.apache.lucene.util.Constants;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.node.ReportingService;
import org.elasticsearch.xcontent.XContentBuilder;

Expand Down Expand Up @@ -168,19 +165,8 @@ public class JvmInfo implements ReportingService.Info {
);
}

@SuppressForbidden(reason = "PathUtils#get")
private static boolean usingBundledJdk() {
/*
* We are using the bundled JDK if java.home is the jdk sub-directory of our working directory. This is because we always set
* the working directory of Elasticsearch to home, and the bundled JDK is in the jdk sub-directory there.
*/
final String javaHome = System.getProperty("java.home");
final String userDir = System.getProperty("user.dir");
if (Constants.MAC_OS_X) {
return PathUtils.get(javaHome).equals(PathUtils.get(userDir).resolve("jdk.app/Contents/Home").toAbsolutePath());
} else {
return PathUtils.get(javaHome).equals(PathUtils.get(userDir).resolve("jdk").toAbsolutePath());
}
return System.getProperty("es.java.type", "").equals("bundled JDK");
}

public static JvmInfo jvmInfo() {
Expand Down
27 changes: 0 additions & 27 deletions server/src/main/java/org/elasticsearch/node/NodeConstruction.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.Build;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.ActionModule;
Expand Down Expand Up @@ -229,7 +227,6 @@
import java.util.IdentityHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -411,30 +408,6 @@ private Settings createEnvironment(Environment initialEnvironment, NodeServicePr
DeprecationLogger.initialize(envSettings);

JvmInfo jvmInfo = JvmInfo.jvmInfo();
logger.info(
"version[{}], pid[{}], build[{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]",
Build.current().qualifiedVersion(),
jvmInfo.pid(),
Build.current().type().displayName(),
Build.current().hash(),
Build.current().date(),
Constants.OS_NAME,
Constants.OS_VERSION,
Constants.OS_ARCH,
Constants.JVM_VENDOR,
Constants.JVM_NAME,
System.getProperty("java.version"),
Runtime.version().toString()
);
logger.info("JVM home [{}], using bundled JDK [{}]", System.getProperty("java.home"), jvmInfo.getUsingBundledJdk());
logger.info("JVM arguments {}", Arrays.toString(jvmInfo.getInputArguments()));
logger.info("Default Locale [{}]", Locale.getDefault());
if (Build.current().isProductionRelease() == false) {
logger.warn(
"version [{}] is a pre-release version of Elasticsearch and is not suitable for production",
Build.current().qualifiedVersion()
);
}
if (Environment.PATH_SHARED_DATA_SETTING.exists(envSettings)) {
// NOTE: this must be done with an explicit check here because the deprecation property on a path setting will
// cause ES to fail to start since logging is not yet initialized on first read of the setting
Expand Down
Loading