Top Description Fields Constructors Methods
sun.jvmstat.monitor

public abstract Class MonitoredHost

extends Object
Class Inheritance
Known Direct Subclasses
sun.jvmstat.perfdata.monitor.protocol.file.MonitoredHostProvider, sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider
Imports
java.net.URISyntaxException, java.util.HashMap, .Map, .ServiceLoader, .Set, sun.jvmstat.monitor.event.HostListener

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.
Author
Brian Doherty
Since
1.5
See Also
HostIdentifier, VmIdentifier, MonitoredVm, HostListener

Field Summary

Modifier and TypeField and Description
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.

private static final String
private static final String
private static final Map<HostIdentifier, MonitoredHost>
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract Set<Integer>

Returns:

Set - the current set of active Java Virtual Machines associated with this MonitoredHost, or the empty set of none.
activeVms
()

Return the current set of active Java Virtual Machines for this MonitoredHost.

public abstract void
addHostListener(HostListener
the HostListener to add.
listener
)

Add a HostListener.

public void
clearLastException()

Clear the last exception.

public abstract void
detach(MonitoredVm
the monitored Java Virtual Machine.
vm
)

Detach from the indicated MonitoredVm.

public HostIdentifier

Returns:

HostIdentifier - the resolved HostIdentifier.
getHostIdentifier
()

Return the resolved HostIdentifier for this MonitoredHost.

public int

Returns:

int - the polling interval in milliseconds for this MonitoredHost
getInterval
()

Get the polling interval.

public Exception

Returns:

Exception - the last exception occurred while polling this MonitoredHost, or null if no exception has occurred or the exception has been cleared,
getLastException
()

Get the last exception encountered while polling this MonitoredHost.

public static MonitoredHost

Returns:

MonitoredHost - the MonitoredHost instance for communicating with the indicated host using the protocol specified in hostIdString.
getMonitoredHost
(String
a String representation of a HostIdentifier
hostIdString
)

Factory method to construct MonitoredHost instances to manage connections to the host indicated by hostIdString

public static MonitoredHost

Returns:

MonitoredHost - The MonitoredHost object needed to attach to the target Java Virtual Machine.
getMonitoredHost
(VmIdentifier
The identifier for the target Java Virtual Machine.
vmid
)

Factory method to construct a MonitoredHost instance to manage the connection to the Java Virtual Machine indicated by vmid.

public static MonitoredHost

Returns:

MonitoredHost - The MonitoredHost object needed to attach to the target host.
getMonitoredHost
(HostIdentifier
the identifier for the target host.
hostId
)

Factory method to construct a MonitoredHost instance to manage the connection to the host indicated by hostId.

public abstract MonitoredVm

Returns:

MonitoredVm - the MonitoredVm instance for the target Java Virtual Machine.
getMonitoredVm
(VmIdentifier
the VmIdentifier specifying the target Java Virtual Machine.
id
)

Get the MonitoredVm for the given Java Virtual Machine.

public abstract MonitoredVm

Returns:

MonitoredVm - the MonitoredVm instance for the target Java Virtual Machine.
getMonitoredVm
(VmIdentifier
the VmIdentifier specifying the target Java Virtual Machine.
id
,
int
the sampling interval for the target Java Virtual Machine.
interval
)

Get the MonitoredVm for the given Java Virtual Machine.

public boolean

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.
isErrored
()

Test if this MonitoredHost is in the errored state.

public abstract void
removeHostListener(HostListener
the HostListener to add.
listener
)

Remove a HostListener.

protected static HostIdentifier

Returns:

HostIdentifier - a resolved HostIdentifier.
resolveHostId
(HostIdentifier
the unresolved 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.

public void
setInterval(int
the polling interval, in milliseconds
interval
)

Set the polling interval for this MonitoredHost.

public void
setLastException(Exception
the last exception encountered;
lastException
)

Set the last exception encountered while polling this MonitoredHost.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hostIdback to summary
protected HostIdentifier hostId

The HostIdentifier for this MonitoredHost instance.

intervalback to summary
protected int interval

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

lastExceptionback to summary
protected Exception lastException

The last Exception encountered while polling this MonitoredHost.

LOCAL_PROTOCOLback to summary
private static final String LOCAL_PROTOCOL
LOCAL_PROTOCOL_PROP_NAMEback to summary
private static final String LOCAL_PROTOCOL_PROP_NAME
monitoredHostsback to summary
private static final Map<HostIdentifier, MonitoredHost> monitoredHosts
REMOTE_PROTOCOLback to summary
private static final String REMOTE_PROTOCOL
REMOTE_PROTOCOL_PROP_NAMEback to summary
private static final String REMOTE_PROTOCOL_PROP_NAME

Constructor Detail

MonitoredHostback to summary
public MonitoredHost()

Method Detail

activeVmsback to summary
public abstract Set<Integer> 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<Integer>

Set - the current set of active Java Virtual Machines associated with this MonitoredHost, or the empty set of none.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
addHostListenerback to summary
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:HostListener

the HostListener to add.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
clearLastExceptionback to summary
public void clearLastException()

Clear the last exception.

detachback to summary
public abstract void detach(MonitoredVm vm) throws MonitorException

Detach from the indicated MonitoredVm.

Parameters
vm:MonitoredVm

the monitored Java Virtual Machine.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
getHostIdentifierback to summary
public HostIdentifier getHostIdentifier()

Return the resolved HostIdentifier for this MonitoredHost.

Returns:HostIdentifier

HostIdentifier - the resolved HostIdentifier.

getIntervalback to summary
public int getInterval()

Get the polling interval.

Returns:int

int - the polling interval in milliseconds for this MonitoredHost

getLastExceptionback to summary
public Exception getLastException()

Get the last exception encountered while polling this MonitoredHost.

Returns:Exception

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

getMonitoredHostback to summary
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:String

a String representation of a HostIdentifier

Returns:MonitoredHost

MonitoredHost - the MonitoredHost instance for communicating with the indicated host using the protocol specified in hostIdString.

Exceptions
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.
getMonitoredHostback to summary
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:VmIdentifier

The identifier for the target Java Virtual Machine.

Returns:MonitoredHost

MonitoredHost - The MonitoredHost object needed to attach to the target Java Virtual Machine.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
getMonitoredHostback to summary
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:HostIdentifier

the identifier for the target host.

Returns:MonitoredHost

MonitoredHost - The MonitoredHost object needed to attach to the target host.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
getMonitoredVmback to summary
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:VmIdentifier

the VmIdentifier specifying the target Java Virtual Machine.

Returns:MonitoredVm

MonitoredVm - the MonitoredVm instance for the target Java Virtual Machine.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
getMonitoredVmback to summary
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:VmIdentifier

the VmIdentifier specifying the target Java Virtual Machine.

interval:int

the sampling interval for the target Java Virtual Machine.

Returns:MonitoredVm

MonitoredVm - the MonitoredVm instance for the target Java Virtual Machine.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
isErroredback to summary
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

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

removeHostListenerback to summary
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:HostListener

the HostListener to add.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
resolveHostIdback to summary
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:HostIdentifier

the unresolved HostIdentifier.

Returns:HostIdentifier

HostIdentifier - a resolved HostIdentifier.

Exceptions
MonitorException:
Thrown if monitoring errors occur.
setIntervalback to summary
public void setInterval(int interval)

Set the polling interval for this MonitoredHost.

Parameters
interval:int

the polling interval, in milliseconds

setLastExceptionback to summary
public void setLastException(Exception lastException)

Set the last exception encountered while polling this MonitoredHost.

Parameters
lastException:Exception

the last exception encountered;