Interface IHostModel
public interface IHostModel
This interface represents a host system, for example a machine running Linux,
and allows to access information on the state of the machine at some
time[range]. Typically, there would be one model instance per host and all
traces taken on the same host (machine) will share the same model.
Users of the model do not need to know where the information comes from. For
each method providing information, a default value will be provided in case
the information is not available. See the method's javadoc for that value.
How the host information is accessed is up to each implementations. It can
make use of the various analyses of the traces that compose this model.
- Author:
- Geneviève Bastien
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
An enumeration of the types of data one can need. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Value to use when a duration or timestamp is not knownstatic final int
Value to use for thread ID -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Dispose of the model when it is not needed anymorelong
getCpuTime
(int tid, long start, long end) Get the amount of time a thread was active on the CPU (any CPU) during a period.@Nullable String
getExecName
(int tid, long t) Get the executable name of a threadint
getProcessId
(int tid, long t) Get the process ID of a threadgetRequiredModules
(EnumSet<IHostModel.ModelDataType> requiredData) Get the analyses modules required to get the data requestedgetSamplingData
(int tid, long start, long end) Get the aggregated sample data for a thread in a time range.default int
getThreadOnCpu
(int cpu, long t) Get which thread is running on the CPU at a given timeint
getThreadOnCpu
(int cpu, long t, boolean block) Get which thread is running on the CPU at a given time, but may blocks if the answer is not available yet but may come latergetThreadStatusIntervals
(int tid, long start, long end, long resolution) Get an iterable over the status intervals of a threadboolean
Get whether sampling data is available for this hostboolean
Get whether thread status information is available for this host
-
Field Details
-
UNKNOWN_TID
static final int UNKNOWN_TIDValue to use for thread ID- See Also:
-
TIME_UNKNOWN
static final long TIME_UNKNOWNValue to use when a duration or timestamp is not known- See Also:
-
-
Method Details
-
getThreadOnCpu
default int getThreadOnCpu(int cpu, long t) Get which thread is running on the CPU at a given time- Parameters:
cpu
- The CPU ID on which the thread is runningt
- The desired time- Returns:
- The ID of the thread running on the CPU, or
UNKNOWN_TID
if it is not available
-
getThreadOnCpu
int getThreadOnCpu(int cpu, long t, boolean block) Get which thread is running on the CPU at a given time, but may blocks if the answer is not available yet but may come later- Parameters:
cpu
- The CPU ID on which the thread is runningt
- The desired timeblock
- Iftrue
, the method will block until the providers have the data available.- Returns:
- The ID of the thread running on the CPU, or
UNKNOWN_TID
if it is not available
-
getProcessId
int getProcessId(int tid, long t) Get the process ID of a thread- Parameters:
tid
- The ID of the thread for which to get the process IDt
- The desired time. A negative value will return the first found value- Returns:
- The ID of the process this thread is part of, or
UNKNOWN_TID
if it is not available
-
getExecName
Get the executable name of a thread- Parameters:
tid
- The ID of the thread for which to get the process IDt
- The desired time. A negative value will return the first found value.- Returns:
- The executable name of the thread or
null
if the name is not found
-
getCpuTime
long getCpuTime(int tid, long start, long end) Get the amount of time a thread was active on the CPU (any CPU) during a period.- Parameters:
tid
- The ID of the threadstart
- The start of the period for which to get the time on CPUend
- The end of the period for which to get the time on CPU- Returns:
- The time spent on the CPU by the thread in that duration or
TIME_UNKNOWN
if it is not available
-
getSamplingData
Get the aggregated sample data for a thread in a time range.- Parameters:
tid
- The ID of the threadstart
- The start of the period for which to get the time on CPUend
- The end of the period for which to get the time on CPU- Returns:
- The collection of aggregated sampling data for the time range
-
getThreadStatusIntervals
Iterable<ProcessStatusInterval> getThreadStatusIntervals(int tid, long start, long end, long resolution) Get an iterable over the status intervals of a thread- Parameters:
tid
- The ID of the threadstart
- The start of the period for which to get the time on CPUend
- The end of the period for which to get the time on CPUresolution
- The resolution, ie the number of nanoseconds between kernel status queries. A value lower or equal to 1 will return all intervals.- Returns:
- An iterator over the status intervals for the thread
-
isSamplingDataAvailable
boolean isSamplingDataAvailable()Get whether sampling data is available for this host- Returns:
true
if sampling data is available,false
otherwise
-
isThreadStatusAvailable
boolean isThreadStatusAvailable()Get whether thread status information is available for this host- Returns:
true
if thread status information is available,false
otherwise
-
getRequiredModules
Get the analyses modules required to get the data requested- Parameters:
requiredData
- An enum set of model data that will be useful to the caller- Returns:
- A collection of analysis modules
-
dispose
void dispose()Dispose of the model when it is not needed anymore
-