Package com.linecorp.armeria.common.util
Class SystemInfo
java.lang.Object
com.linecorp.armeria.common.util.SystemInfo
public final class SystemInfo extends Object
Provides utilities for accessing the information about the current system and process.
-
Method Summary
Modifier and Type Method Description static long
currentTimeMicros()
Returns the number of microseconds since the epoch (00:00:00, 01-Jan-1970, GMT).static Inet4Address
defaultNonLoopbackIpV4Address()
Returns the non-loopbackInet4Address
whoseNetworkInterface.getIndex()
is the lowest.static String
hostname()
Returns the local hostname.static boolean
isLinux()
Returnstrue
if the operating system is Linux.static int
javaVersion()
Returns the major version of the current Java Virtual Machine.static boolean
jettyAlpnOptionalOrAvailable()
Whether the environment either supports ALPN natively or includes Jetty ALPN.static OsType
osType()
Returns the operating system for the currently running process.static int
pid()
Returns the current process ID.
-
Method Details
-
javaVersion
public static int javaVersion()Returns the major version of the current Java Virtual Machine. -
hostname
Returns the local hostname. -
jettyAlpnOptionalOrAvailable
public static boolean jettyAlpnOptionalOrAvailable()Whether the environment either supports ALPN natively or includes Jetty ALPN. -
pid
public static int pid()Returns the current process ID.- Throws:
IllegalStateException
- if failed to retrieve the current process ID.
-
defaultNonLoopbackIpV4Address
Returns the non-loopbackInet4Address
whoseNetworkInterface.getIndex()
is the lowest.- See Also:
Flags.preferredIpV4Addresses()
-
currentTimeMicros
public static long currentTimeMicros()Returns the number of microseconds since the epoch (00:00:00, 01-Jan-1970, GMT). The precision of the returned value may vary depending on Java version. Currently, Java 9 or above is required for microsecond precision.System.currentTimeMillis() * 1000
is returned on Java 8. -
osType
Returns the operating system for the currently running process. -
isLinux
public static boolean isLinux()Returnstrue
if the operating system is Linux.
-