Jvmstat

sun.jvmstat.monitor
Class MonitoredHost

java.lang.Object
  extended by sun.jvmstat.monitor.MonitoredHost
Direct Known Subclasses:
MonitoredHostProvider, MonitoredHostProvider, MonitoredHostProvider

public abstract class MonitoredHost
extends Object

An abstraction for a host that contains instrumented Java Virtual Machines. The class provides abstract factory methods for creating concrete instances of this class and factory methods for creating MonitoredVm instances. Concrete implementations of this class provide methods for managing the communications protocols and provide for event notification.

Since:
1.5
See Also:
HostIdentifier, VmIdentifier, MonitoredVm, HostListener

Field Summary
protected  HostIdentifier hostId
          The HostIdentifier for this MonitoredHost instance.
protected  int interval
          The polling interval, in milliseconds, for this MonitoredHost instance.
protected  Exception lastException
          The last Exception encountered while polling this MonitoredHost.
 
Constructor Summary
MonitoredHost()
           
 
Method Summary
abstract  Set activeVms()
          Return the current set of active Java Virtual Machines for this MonitoredHost.
abstract  void addHostListener(HostListener listener)
          Add a HostListener.
 void clearLastException()
          Clear the last exception.
abstract  void detach(MonitoredVm vm)
          Detach from the indicated MonitoredVm.
 HostIdentifier getHostIdentifier()
          Return the resolved HostIdentifier for this MonitoredHost.
 int getInterval()
          Get the polling interval.
 Exception getLastException()
          Get the last exception encountered while polling this MonitoredHost.
static MonitoredHost getMonitoredHost(HostIdentifier hostId)
          Factory method to construct a MonitoredHost instance to manage the connection to the host indicated by hostId.
static MonitoredHost getMonitoredHost(String hostIdString)
          Factory method to construct MonitoredHost instances to manage connections to the host indicated by hostIdString
static MonitoredHost getMonitoredHost(VmIdentifier vmid)
          Factory method to construct a MonitoredHost instance to manage the connection to the Java Virtual Machine indicated by vmid.
abstract  MonitoredVm getMonitoredVm(VmIdentifier id)
          Get the MonitoredVm for the given Java Virtual Machine.
abstract  MonitoredVm getMonitoredVm(VmIdentifier id, int interval)
          Get the MonitoredVm for the given Java Virtual Machine.
 boolean isErrored()
          Test if this MonitoredHost is in the errored state.
abstract  void removeHostListener(HostListener listener)
          Remove a HostListener.
protected static HostIdentifier resolveHostId(HostIdentifier hostId)
          Method to resolve unspecified components of the given HostIdentifier by constructing a new HostIdentifier that replaces the unspecified components with the default values.
 void setInterval(int interval)
          Set the polling interval for this MonitoredHost.
 void setLastException(Exception lastException)
          Set the last exception encountered while polling this MonitoredHost.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hostId

protected HostIdentifier hostId
The HostIdentifier for this MonitoredHost instance.


interval

protected int interval
The polling interval, in milliseconds, for this MonitoredHost instance.


lastException

protected Exception lastException
The last Exception encountered while polling this MonitoredHost.

Constructor Detail

MonitoredHost

public MonitoredHost()
Method Detail

getMonitoredHost

public static MonitoredHost getMonitoredHost(String hostIdString)
                                      throws MonitorException,
                                             URISyntaxException
Factory method to construct MonitoredHost instances to manage connections to the host indicated by hostIdString

Parameters:
hostIdString - a String representation of a HostIdentifier
Returns:
MonitoredHost - the MonitoredHost instance for communicating with the indicated host using the protocol specified in hostIdString.
Throws:
MonitorException - Thrown if monitoring errors occur.
URISyntaxException - Thrown when the hostIdString is poorly formed. This exception may get encapsulated into MonitorException in a future revision.

getMonitoredHost

public static MonitoredHost getMonitoredHost(VmIdentifier vmid)
                                      throws MonitorException
Factory method to construct a MonitoredHost instance to manage the connection to the Java Virtual Machine indicated by vmid. This method provide a convenient short cut for attaching to a specific instrumented Java Virtual Machine. The information in the VmIdentifier is used to construct a corresponding HostIdentifier, which in turn is used to create the MonitoredHost instance.

Parameters:
vmid - The identifier for the target Java Virtual Machine.
Returns:
MonitoredHost - The MonitoredHost object needed to attach to the target Java Virtual Machine.
Throws:
MonitorException - Thrown if monitoring errors occur.

getMonitoredHost

public static MonitoredHost getMonitoredHost(HostIdentifier hostId)
                                      throws MonitorException
Factory method to construct a MonitoredHost instance to manage the connection to the host indicated by hostId.

Parameters:
hostId - the identifier for the target host.
Returns:
MonitoredHost - The MonitoredHost object needed to attach to the target host.
Throws:
MonitorException - Thrown if monitoring errors occur.

resolveHostId

protected static HostIdentifier resolveHostId(HostIdentifier hostId)
                                       throws MonitorException
Method to resolve unspecified components of the given HostIdentifier by constructing a new HostIdentifier that replaces the unspecified components with the default values.

Parameters:
hostId - the unresolved HostIdentifier.
Returns:
HostIdentifier - a resolved HostIdentifier.
Throws:
MonitorException - Thrown if monitoring errors occur.

getHostIdentifier

public HostIdentifier getHostIdentifier()
Return the resolved HostIdentifier for this MonitoredHost.

Returns:
HostIdentifier - the resolved HostIdentifier.

setInterval

public void setInterval(int interval)
Set the polling interval for this MonitoredHost.

Parameters:
interval - the polling interval, in milliseconds

getInterval

public int getInterval()
Get the polling interval.

Returns:
int - the polling interval in milliseconds for this MonitoredHost

setLastException

public void setLastException(Exception lastException)
Set the last exception encountered while polling this MonitoredHost.

Parameters:
lastException - the last exception encountered;

getLastException

public Exception getLastException()
Get the last exception encountered while polling this MonitoredHost.

Returns:
Exception - the last exception occurred while polling this MonitoredHost, or null if no exception has occurred or the exception has been cleared,

clearLastException

public void clearLastException()
Clear the last exception.


isErrored

public boolean isErrored()
Test if this MonitoredHost is in the errored state. If this method returns true, then the Exception returned by getLastException() indicates the Exception that caused the error condition.

Returns:
boolean - true if the MonitoredHost instance has experienced an error, or false if it hasn't or if any past error has been cleared.

getMonitoredVm

public abstract MonitoredVm getMonitoredVm(VmIdentifier id)
                                    throws MonitorException
Get the MonitoredVm for the given Java Virtual Machine. The default sampling interval is used for the MonitoredVm instance.

Parameters:
id - the VmIdentifier specifying the target Java Virtual Machine.
Returns:
MonitoredVm - the MonitoredVm instance for the target Java Virtual Machine.
Throws:
MonitorException - Thrown if monitoring errors occur.

getMonitoredVm

public abstract MonitoredVm getMonitoredVm(VmIdentifier id,
                                           int interval)
                                    throws MonitorException
Get the MonitoredVm for the given Java Virtual Machine. The sampling interval is set to the given interval.

Parameters:
id - the VmIdentifier specifying the target Java Virtual Machine.
interval - the sampling interval for the target Java Virtual Machine.
Returns:
MonitoredVm - the MonitoredVm instance for the target Java Virtual Machine.
Throws:
MonitorException - Thrown if monitoring errors occur.

detach

public abstract void detach(MonitoredVm vm)
                     throws MonitorException
Detach from the indicated MonitoredVm.

Parameters:
vm - the monitored Java Virtual Machine.
Throws:
MonitorException - Thrown if monitoring errors occur.

addHostListener

public abstract void addHostListener(HostListener listener)
                              throws MonitorException
Add a HostListener. The given listener is added to the list of HostListener objects to be notified of MonitoredHost related events.

Parameters:
listener - the HostListener to add.
Throws:
MonitorException - Thrown if monitoring errors occur.

removeHostListener

public abstract void removeHostListener(HostListener listener)
                                 throws MonitorException
Remove a HostListener. The given listener is removed from the list of HostListener objects to be notified of MonitoredHost related events.

Parameters:
listener - the HostListener to add.
Throws:
MonitorException - Thrown if monitoring errors occur.

activeVms

public abstract Set activeVms()
                       throws MonitorException
Return the current set of active Java Virtual Machines for this MonitoredHost. The returned Set contains Integer instances holding the local virtual machine identifier, or lvmid for each instrumented Java Virtual Machine currently available.

Returns:
Set - the current set of active Java Virtual Machines associated with this MonitoredHost, or the empty set of none.
Throws:
MonitorException - Thrown if monitoring errors occur.

Jvmstat