Modifications on ProcessInfo implementation
Thomas Segismont
tsegismo at redhat.com
Tue Jan 8 13:49:17 UTC 2013
Hi all,
While working on a fix for BZ 885664 (OpenSSHD and MySQL availability
check may report stale data) we started to have a discussion with Lukas
on how the current ProcessInfo is implemented.
ProcessInfo uses SIGAR to gather information on platform processes. It
behaves like a cache of the SIGAR call results. So, when a user gets an
existing ProcessInfo instance and invokes one of its methods, generally
no new SIGAR call is made.
This behavior (and the corresponding API) is not really documented and
it has led to bugs like the BZ 885664 (the cached ProcState instance
reports the underlying process is up even if it no longer exists).
Lukas suggested I should try to make usage of the class less error prone
while fixing the bug so I have updated the implementation in this way:
* created a public internal class ProcessInfoSnapshot, which groups non
static process property accessors (like state, CPU usage) and operations
on these properties (like isRunning method)
* added two new methods, priorSnapshot and freshSnapshot, to get the
last or retrieve a new ProcessInfoSnapshot respectively.
* kept static process properties and associated operations in the top
level type
* kept the previous API but marked it deprecated.
If you want to see the changeset:
http://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?h=bug/885664&id=c40606d165efabf4091ebe506d4cf7ea2f5c098e
As an example, to check if a process is alive with the new API:
processInfo.freshSnapshot().isRunning();
What do you think?
Regards
Thomas
More information about the rhq-devel
mailing list