Package com.seeq.utilities.process
Class SystemInfo
java.lang.Object
com.seeq.utilities.process.SystemInfo
Convenience functions related to the properties of the system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final long
static final long
static final long
static final int
static final long
static final long
static final long
static final long
static final int
static final long
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
This method calculates an optimal page size for database queries based on the memory available to appserver.static String
getSystemMemoryInfo
(Runtime runtime) Retrieves a string representation of the memory statistics of the Java virtual machine.static long
getTotalDiskSpaceSafely
(File disk) Get the amount of total disk space.static long
getTotalPhysicalMemory
(OperatingSystemMXBean osMXBean) Retrieves the amount of actual system memory in bytes.static long
getUsableDiskSpaceSafely
(File disk) Get the amount of usable disk space.static String
humanReadableByteCount
(long bytes, boolean useBaseTwo) Constructs a human readable string of the given bytes, such as '2.02GiB' or '9.75TB'.static String
humanReadableByteCount
(long bytes, boolean useBaseTwo, boolean roundToInt) Constructs a human readable string of the given bytes, such as '2.02GiB' or '9TB'.static boolean
isDiskTooFull
(File disk) Decide if the disk has enough space to safely run Seeq.
-
Field Details
-
BYTES_PER_GIGABYTE
public static final long BYTES_PER_GIGABYTE- See Also:
-
BYTES_PER_GIBIBYTE
public static final long BYTES_PER_GIBIBYTE- See Also:
-
RECOMMENDED_USABLE_SPACE_IN_BYTES
public static final long RECOMMENDED_USABLE_SPACE_IN_BYTES- See Also:
-
RECOMMENDED_CPU_CORES
public static final long RECOMMENDED_CPU_CORES- See Also:
-
RECOMMENDED_PAGE_SIZE
public static final int RECOMMENDED_PAGE_SIZE- See Also:
-
RECOMMENDED_MEMORY_IN_BYTES
public static final long RECOMMENDED_MEMORY_IN_BYTES- See Also:
-
MINIMUM_USABLE_SPACE_IN_GIGABYTES
public static final long MINIMUM_USABLE_SPACE_IN_GIGABYTES- See Also:
-
MINIMUM_USABLE_SPACE_IN_BYTES
public static final long MINIMUM_USABLE_SPACE_IN_BYTES- See Also:
-
MINIMUM_CPU_CORES
public static final long MINIMUM_CPU_CORES- See Also:
-
MINIMUM_PAGE_SIZE
public static final int MINIMUM_PAGE_SIZE- See Also:
-
MINIMUM_MEMORY_IN_BYTES
public static final long MINIMUM_MEMORY_IN_BYTES- See Also:
-
-
Method Details
-
isDiskTooFull
Decide if the disk has enough space to safely run Seeq. See CRAB-10248.- Parameters:
disk
- A file on the disk in question. Likely the Seeq data directory.- Returns:
- True if the disk is too full and Seeq should shut down; false if there is enough space.
-
getRecommendedPageSize
public static int getRecommendedPageSize()This method calculates an optimal page size for database queries based on the memory available to appserver.- Returns:
- the recommended page size for database queries.
-
getUsableDiskSpaceSafely
Get the amount of usable disk space. Note that 'usable' disk space is typically lower than disk-reported 'free' disk space.- Parameters:
disk
- A file on the disk in question. Likely the Seeq data directory.- Returns:
- the amount of usable disk space in bytes. If the query failed, returns -1.
-
getTotalDiskSpaceSafely
Get the amount of total disk space.- Parameters:
disk
- A file on the disk in question. Likely the Seeq data directory.- Returns:
- the amount of usable disk space in bytes. If the query failed, returns -1.
-
getSystemMemoryInfo
Retrieves a string representation of the memory statistics of the Java virtual machine. Primarily intended for logging.- Returns:
- The memory statistics of the system. Primarily intended for logging.
-
getTotalPhysicalMemory
Retrieves the amount of actual system memory in bytes.- Parameters:
osMXBean
- an instance of ManagementFactory.getOperatingSystemMXBean()- Returns:
- The amount of actual system memory
-
humanReadableByteCount
Constructs a human readable string of the given bytes, such as '2.02GiB' or '9.75TB'.- Parameters:
bytes
- The byte value for which to construct a human readable representation.useBaseTwo
- If true, uses base-two units (GiB). If false, uses base-ten units (GB).- Returns:
- A human readable string of the given bytes, such as '2.02GiB' or '9.75TB'.
-
humanReadableByteCount
Constructs a human readable string of the given bytes, such as '2.02GiB' or '9TB'.- Parameters:
bytes
- The byte value for which to construct a human readable representation.useBaseTwo
- If true, uses base-two units (GiB). If false, uses base-ten units (GB).roundToInt
- If true, rounds the value to the nearest integer. If false, outputs two decimal points.- Returns:
- A human readable string of the given bytes, such as '2.02GiB' or '9TB'.
-