com.jniwrapper.win32.process.monitoring
Class Snapshot

java.lang.Object
  extended by com.jniwrapper.Parameter
      extended by com.jniwrapper.Pointer.Void
          extended by com.jniwrapper.win32.Handle
              extended by com.jniwrapper.win32.process.monitoring.Snapshot
All Implemented Interfaces:
com.jniwrapper.IntegerParameter, com.jniwrapper.PointerParameter, java.lang.Runnable

public final class Snapshot
extends Handle
implements java.lang.Runnable

Snapshot class represents a system performance snapshot. Snapshot enables to list all running processes, modules, threads and heaps.

NOTE: Do not forget to clean up the snapshot object using the close() method.


Nested Class Summary
static class Snapshot.Options
          Options class represents options for taking a performance snapshots.
protected static class Snapshot.SnapshotResource
          This class is responsible for destroying a native resource when the instance is collected by GC.
 
Field Summary
 
Fields inherited from class com.jniwrapper.win32.Handle
INFINITE_TIMEOUT, INVALID_HANDLE_VALUE, STATUS_ABANDONED_WAIT_0, STATUS_TIMEOUT, STATUS_WAIT_0
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
Snapshot(Snapshot.Options options)
          Creates a snapshot of specified processes in the system, as well as heaps, modules, and threads used by these processes.
Snapshot(Snapshot.Options options, long processID)
          Creates a snapshot of specified processes in the system, as well as heaps, modules, and threads used by these processes.
 
Method Summary
 void close()
          Closes the snapshot.
 java.util.List getHeapEntries(long processID, long heapID)
           
 java.util.Iterator getHeapEntriesIterator(long processID, long heapID)
          Returns a list of heap entries for the given process and the heap.
 java.util.List getHeapList()
          Returns a list of heap list from a snapshot.
 java.util.Iterator getHeapListIterator()
          Returns iterator for enumerating heap list from a snapshot.
 java.util.Iterator getModuleIterator()
          Returns an iterator for enumerating modules from the snapshot.
 java.util.List getModules()
          Returns a list of modules from the snapshot.
 Snapshot.Options getOptions()
          Returns SnapshotOptions.
 java.util.List getProcesses()
          Returns a list of processes from the snapshot.
 long getProcessID()
          Returns a specified processID.
 java.util.Iterator getProcessIterator()
          Returns an iterator for enumerating processes from the snapshot.
 java.util.Iterator getThreadIterator()
          Returns iterator for enumerating threads from a snapshot.
 java.util.List getThreadList()
          Returns a list of threads from a snapshot.
 void run()
          Updates the instance with new snapshot data.
 void setProcessID(long processID)
          Sets a new processID.
 
Methods inherited from class com.jniwrapper.win32.Handle
clone, closeHandle, equals, waitFor, waitFor
 
Methods inherited from class com.jniwrapper.Pointer.Void
asFunction, asFunction, asTypedPointer, castTo, castTo, getDebugInfo, getLength, getValue, hashCode, isNull, read, setValue, toString, write
 
Methods inherited from class com.jniwrapper.Parameter
, a, a, acceptIOPerformer, asReturnValue, b, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, indent, pop, push, read, read, setDataBuffer, toByteArray, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Snapshot

public Snapshot(Snapshot.Options options)
Creates a snapshot of specified processes in the system, as well as heaps, modules, and threads used by these processes. This constructor is used for current process.

Parameters:
options - Portions of the system information to include in the snapshot.

Snapshot

public Snapshot(Snapshot.Options options,
                long processID)
Creates a snapshot of specified processes in the system, as well as heaps, modules, and threads used by these processes.

Parameters:
options - Portions of the system information to include in the snapshot.
processID - Process identifier of the process to be included in the snapshot.
Method Detail

getOptions

public Snapshot.Options getOptions()
Returns SnapshotOptions.

Returns:
SnapshotOptions.

getProcessID

public long getProcessID()
Returns a specified processID.

Returns:
processID.

setProcessID

public void setProcessID(long processID)
Sets a new processID.

Parameters:
processID - new processID.

run

public void run()
Updates the instance with new snapshot data.

Specified by:
run in interface java.lang.Runnable

getProcessIterator

public java.util.Iterator getProcessIterator()
Returns an iterator for enumerating processes from the snapshot. Each next element of returned Iterator is an instance of ProcessEntry class.

Returns:
Iterator for enumerating processes from a snapshot.

getProcesses

public java.util.List getProcesses()
Returns a list of processes from the snapshot. Each element of the list is an instance of ProcessEntry class.

Returns:
List of processes from a snapshot.

getModuleIterator

public java.util.Iterator getModuleIterator()
Returns an iterator for enumerating modules from the snapshot. Each next element of returned Iterator is an instance of ModuleEntry class.

Returns:
Iterator for enumerating modules from a snapshot.

getModules

public java.util.List getModules()
Returns a list of modules from the snapshot. Each element of the list is an instance of ModuleEntry class.

Returns:
List of modules from a snapshot.

getHeapEntriesIterator

public java.util.Iterator getHeapEntriesIterator(long processID,
                                                 long heapID)
Returns a list of heap entries for the given process and the heap. Each element of the list is an instance of HeapEntry class.

Parameters:
processID - Identifier of the process context that owns the heap.
heapID - Identifier of the heap to be enumerated.
Returns:
List of heap entries for given process and heap.

getHeapEntries

public java.util.List getHeapEntries(long processID,
                                     long heapID)

getHeapListIterator

public java.util.Iterator getHeapListIterator()
Returns iterator for enumerating heap list from a snapshot. Each next element of returned Iterator is an instance of HeapList class.

Returns:
Iterator for enumerating heap list from a snapshot.

getHeapList

public java.util.List getHeapList()
Returns a list of heap list from a snapshot. Each element of the list is an instance of HeapList class.

Returns:
List of heap list from a snapshot.

getThreadIterator

public java.util.Iterator getThreadIterator()
Returns iterator for enumerating threads from a snapshot. Each next element of returned Iterator is an instance of ThreadEntry class.

Returns:
Iterator for enumerating threads from a snapshot.

getThreadList

public java.util.List getThreadList()
Returns a list of threads from a snapshot. Each element of the list is an instance of ThreadEntry class.

Returns:
List of threads from a snapshot.

close

public void close()
Closes the snapshot.