Package org.apache.flink.runtime.util
Class EnvironmentInformation
java.lang.Object
org.apache.flink.runtime.util.EnvironmentInformation
Utility class that gives access to the execution environment of the JVM, like the executing user,
startup options, or the JVM version.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRevision information encapsulates information about the source code revision of the Flink code. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Instantstatic Stringstatic Stringstatic Stringstatic Instantstatic Stringstatic StringGets the name of the user that is running the JVM.static Stringstatic StringGets the system parameters and environment parameters that were passed to the JVM on startup.static String[]Gets the system parameters and environment parameters that were passed to the JVM on startup.static StringGets the version of the JVM in the form "VM_Name - Vendor - Spec/Version".static longThe maximum JVM heap size, in bytes.static longTries to retrieve the maximum number of open file handles.Returns the code revision (commit and commit date) of Flink, as generated by the Maven builds.static StringReturns the version of the used Scala compiler as String.static longGets an estimate of the size of the free heap memory.static longGets an estimate of the size of the free heap memory.static StringGets the directory for temporary files, as returned by the JVM system property "java.io.tmpdir".static StringReturns the version of the code as String.static voidlogEnvironmentInfo(org.slf4j.Logger log, String componentName, String[] commandLineArgs) Logs information about the environment, like code revision, current user, Java version, and JVM parameters.
-
Field Details
-
UNKNOWN_COMMIT_ID
- See Also:
-
UNKNOWN_COMMIT_ID_ABBREV
- See Also:
-
UNKNOWN
- See Also:
-
-
Method Details
-
getVersion
Returns the version of the code as String.- Returns:
- The project version string.
-
getScalaVersion
Returns the version of the used Scala compiler as String.- Returns:
- The scala version string.
-
getBuildTime
- Returns:
- The Instant this version of the software was built.
-
getBuildTimeString
- Returns:
- The Instant this version of the software was built as a String using the Europe/Berlin timezone.
-
getGitCommitId
- Returns:
- The last known commit id of this version of the software.
-
getGitCommitIdAbbrev
- Returns:
- The last known abbreviated commit id of this version of the software.
-
getGitCommitTime
- Returns:
- The Instant of the last commit of this code.
-
getGitCommitTimeString
- Returns:
- The Instant of the last commit of this code as a String using the Europe/Berlin timezone.
-
getRevisionInformation
Returns the code revision (commit and commit date) of Flink, as generated by the Maven builds.- Returns:
- The code revision.
-
getHadoopUser
Gets the name of the user that is running the JVM.- Returns:
- The name of the user that is running the JVM.
-
getMaxJvmHeapMemory
public static long getMaxJvmHeapMemory()The maximum JVM heap size, in bytes.This method uses the -Xmx value of the JVM, if set. If not set, it returns (as a heuristic) 1/4th of the physical memory size.
- Returns:
- The maximum JVM heap size, in bytes.
-
getSizeOfFreeHeapMemoryWithDefrag
public static long getSizeOfFreeHeapMemoryWithDefrag()Gets an estimate of the size of the free heap memory.NOTE: This method is heavy-weight. It triggers a garbage collection to reduce fragmentation and get a better estimate at the size of free memory. It is typically more accurate than the plain version
getSizeOfFreeHeapMemory().- Returns:
- An estimate of the size of the free heap memory, in bytes.
-
getSizeOfFreeHeapMemory
public static long getSizeOfFreeHeapMemory()Gets an estimate of the size of the free heap memory. The estimate may vary, depending on the current level of memory fragmentation and the number of dead objects. For a better (but more heavy-weight) estimate, usegetSizeOfFreeHeapMemoryWithDefrag().- Returns:
- An estimate of the size of the free heap memory, in bytes.
-
getJvmVersion
Gets the version of the JVM in the form "VM_Name - Vendor - Spec/Version".- Returns:
- The JVM version.
-
getJvmStartupOptions
Gets the system parameters and environment parameters that were passed to the JVM on startup.- Returns:
- The options passed to the JVM on startup.
-
getJvmStartupOptionsArray
Gets the system parameters and environment parameters that were passed to the JVM on startup.- Returns:
- The options passed to the JVM on startup.
-
getTemporaryFileDirectory
Gets the directory for temporary files, as returned by the JVM system property "java.io.tmpdir".- Returns:
- The directory for temporary files.
-
getOpenFileHandlesLimit
public static long getOpenFileHandlesLimit()Tries to retrieve the maximum number of open file handles. This method will only work on UNIX-based operating systems with Sun/Oracle Java versions.If the number of max open file handles cannot be determined, this method returns
-1.- Returns:
- The limit of open file handles, or
-1, if the limit could not be determined.
-
logEnvironmentInfo
public static void logEnvironmentInfo(org.slf4j.Logger log, String componentName, String[] commandLineArgs) Logs information about the environment, like code revision, current user, Java version, and JVM parameters.- Parameters:
log- The logger to log the information to.componentName- The component name to mention in the log.commandLineArgs- The arguments accompanying the starting the component.
-
getHadoopVersionString
-