Package com.linecorp.armeria.common.util
Class SystemInfo
java.lang.Object
com.linecorp.armeria.common.util.SystemInfo
Provides utilities for accessing the information about the current system and process.
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
Returns the number of microseconds since the epoch (00:00:00, 01-Jan-1970, GMT).static @Nullable Inet4Address
Returns the non-loopbackInet4Address
whoseNetworkInterface.getIndex()
is the lowest.static boolean
hasIpV6()
Returnstrue
if the system has at least one working IPv6 network interface and thejava.net.preferIPv4Stack
system property is not enabled.static String
hostname()
Returns the local hostname.static boolean
isLinux()
Returnstrue
if the operating system is Linux.static int
Returns the major version of the current Java Virtual Machine.static boolean
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.
-
hasIpV6
public static boolean hasIpV6()Returnstrue
if the system has at least one working IPv6 network interface and thejava.net.preferIPv4Stack
system property is not enabled.- See Also:
-
defaultNonLoopbackIpV4Address
Returns the non-loopbackInet4Address
whoseNetworkInterface.getIndex()
is the lowest.- See Also:
-
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.
-