Package io.deephaven.util.process
Class LoadSampler
java.lang.Object
io.deephaven.util.process.LoadSampler
Periodic sampling of load statistics, including load average, cpu utilization percentage, and free memory.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMachine constants relevant for interpreting a load sample, eg, total memory and number of cpu threads.static classLoad sample data -
Constructor Summary
ConstructorsConstructorDescriptionLoadSampler(long loadSamplePeriodMillis, com.fishlib.io.logger.Logger log) Creates a new LoadSampler with the given sampling period and the associated log -
Method Summary
Modifier and TypeMethodDescriptiongetSample(long nowMillis) Gets a copy of the current sample.booleangetSample(long nowMillis, LoadSampler.Sample toCopy) Gets a copy of the current sample.getSampleOrNull(long nowMillis) If the current sample is expired takes a new sample and returns a copy of that, null otherwise.booleanvoidmaybeLog()Log an info line with load sample data, but only if the current sample is expired, otherwise do nothing.voidrefreshAndGetSample(long nowMillis, LoadSampler.Sample toCopy) static StringtoMiBStr(long ramBytes) Format an amount of bytes as a MiBs string
-
Constructor Details
-
LoadSampler
public LoadSampler(long loadSamplePeriodMillis, com.fishlib.io.logger.Logger log) Creates a new LoadSampler with the given sampling period and the associated log- Parameters:
loadSamplePeriodMillis- a period in milliseconds. New samples won't be taken more frequently than this value, unless forced.log- a logger where to executemaybeLog()calls
-
-
Method Details
-
toMiBStr
Format an amount of bytes as a MiBs string- Parameters:
ramBytes- the number of bytes- Returns:
- a string with the number of MiB
-
isEnabled
public boolean isEnabled() -
getSample
Gets a copy of the current sample. If the current sample is expired, it refreshes the current sample before making the copy.- Parameters:
nowMillis- the current timetoCopy- the sample object where to copy the sampled data- Returns:
- true if the current sample was refreshed, false otherwise.
-
refreshAndGetSample
-
getSampleOrNull
If the current sample is expired takes a new sample and returns a copy of that, null otherwise.- Parameters:
nowMillis- the current time- Returns:
- A copy of a freshly taken sample.
-
getSample
Gets a copy of the current sample. If the current sample is expired, it refreshes the current sample before making the copy.- Parameters:
nowMillis- the current time- Returns:
- a newly created object with a copy of the sampled data
-
getConstants
-
maybeLog
public void maybeLog()Log an info line with load sample data, but only if the current sample is expired, otherwise do nothing.
-