org.elasticsearch.bootstrap.BootstrapInfo Maven / Gradle / Ivy
Show all versions of elasticsearch Show documentation
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.bootstrap;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.core.SuppressForbidden;
import java.util.Dictionary;
import java.util.Enumeration;
/**
* Exposes system startup information
*/
@SuppressForbidden(reason = "exposes read-only view of system properties")
public final class BootstrapInfo {
private static final SetOnce console = new SetOnce<>();
/** no instantiation */
private BootstrapInfo() {}
/**
* Returns true if we successfully loaded native libraries.
*
* If this returns false, then native operations such as locking
* memory did not work.
*/
public static boolean isNativesAvailable() {
return Natives.JNA_AVAILABLE;
}
/**
* Returns true if we were able to lock the process's address space.
*/
public static boolean isMemoryLocked() {
return Natives.isMemoryLocked();
}
/**
* Returns true if system call filter is installed (supported systems only)
*/
public static boolean isSystemCallFilterInstalled() {
return Natives.isSystemCallFilterInstalled();
}
/**
* Returns a reference to a stream attached to Standard Output, iff we have determined that stdout is a console (tty)
*/
public static ConsoleLoader.Console getConsole() {
return console.get();
}
/**
* codebase location for untrusted scripts (provide some additional safety)
*
* This is not a full URL, just a path.
*/
public static final String UNTRUSTED_CODEBASE = "/untrusted";
/**
* A non-printable character denoting a UserException has occurred.
*
* This is sent over stderr to the controlling CLI process.
*/
public static final char USER_EXCEPTION_MARKER = '\u0015';
/**
* A non-printable character denoting the server is ready to process requests.
*
* This is sent over stderr to the controlling CLI process.
*/
public static final char SERVER_READY_MARKER = '\u0018';
/**
* A non-printable character denoting the server should shut itself down.
*
* This is sent over stdin from the controlling CLI process.
*/
public static final char SERVER_SHUTDOWN_MARKER = '\u001B';
// create a view of sysprops map that does not allow modifications
// this must be done this way (e.g. versus an actual typed map), because
// some test methods still change properties, so whitelisted changes must
// be reflected in this view.
private static final Dictionary