org.gridrm.client.utilities.sorma.monitoring
Class MonitoringImpl

java.lang.Object
  extended by org.gridrm.client.utilities.sorma.monitoring.MonitoringImpl
All Implemented Interfaces:
Monitoring

public class MonitoringImpl
extends Object
implements Monitoring


Field Summary
protected  String endNonMetaRequest
           
protected  String xmlAllResources
           
 
Constructor Summary
MonitoringImpl(String clientName, String mediatorGroupName)
           
 
Method Summary
 boolean cancelEventRegistration(EventType eventType, String gatewayName, Credential userCredential)
          Use this method to cancel an event registration that you previously made using the registerForEvents(...) method.
 void finalize()
           
 Resource[] getCoreAttributeValues(String[] resourceNames, boolean registeredOnly, String gatewayName, CacheTTL ttl, Credential userCredential)
          Retrieve the core attribute values for the named resources
 Resource[] getCoreAttributeValues(String gatewayName, CacheTTL ttl, Credential userCredential)
          Retrieve the core attribute values for all resources registered with the named gateway.
 Resource getCoreAttributeValues(String resourceName, String gatewayName, CacheTTL ttl, Credential userCredential)
          Retrieve the core attribute values for the named resource only.
 Job getJobWatchData(String jobId, String resourceName, String gatewayName, Credential userCredential)
          Return data from the gateway's internal database that resulted from a particular jobWatch.
 ResultSet getResourceWatchData(String resourceName, String gatewayName, Credential userCredential)
          Returns historical data that was captured using the startResourceWatch() method.
 boolean haltResourceWatch(String resourceName, String gatewayName, Credential userCredential)
          Halt a previously started resource watch.
 Driver[] listRegisteredDrivers(String gatewayName, Credential userCredential)
          Returns a list of the drivers that have been registered at the default gateway
 ResourceRegistrationDescription[] listRegisteredResources(String gatewayName, Credential userCredential)
          Returns a list of the resources currently registered with the specified gateway
 void processMessage(Message t)
          Called by the BlockingTycho API and used internally by this class.
 ResultSet query(SqlQuery sqlQuery, String gatewayName, Credential userCredential)
          Submit an SQL query to the gateway
 long registerForEvents(EventType eventType, String gatewayName, EventHandler handler, Credential userCredential)
          Use this method to register interest in events.
 void registerResource(String name, DriverType driver, int nonStandardPort, Credential resourceCredential, String gatewayName, Credential userCredential)
          Register a new resource for monitoring by the specified gateway
 void reportProblem(ProblemReport report, String gatewayName, Credential userCredential)
          Send a problem report to the gateway.
 void shutdown()
          Unregister the client from the Tycho registry
 void startJobWatch(String jobId, int interval, String resourceName, String gatewayName, Credential userCredential)
          Instructs the gateway to monitor the execution of a particular job.
 void startResourceWatch(String resourceName, int frequency, long duration, String gatewayName, Credential userCredential, EventHandler handler)
          Instructs the gateway to capture the specified resource's core attribute values at the stated frequency and store them in the gateway's internal database.
 void stopJobWatch(String jobId, String resourceName, String gatewayName, Credential userCredential)
          Instructs the gateway to stop watching the specified job.
 void tychoClientRegistered()
          Invoked by Tycho when the client is registered.
 void unregisterResource(String resourceName, String gatewayName, Credential userCredential)
          Remove a resource
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlAllResources

protected String xmlAllResources

endNonMetaRequest

protected String endNonMetaRequest
Constructor Detail

MonitoringImpl

public MonitoringImpl(String clientName,
                      String mediatorGroupName)
               throws Exception
Parameters:
clientName: - The name of this client. Does not have to be unique, but if it is then other components can resolve an address to this client easily if they perform a registry lookup.
gridrmGatewayName: - The name of the GridRM Gateway that you initially want to connect to
mediatorGroupName: - The name of the Tycho mediator group that you will join
Throws:
Exception: - If any problems occur that mean this client cannot be registered with Tycho.
Exception
Method Detail

processMessage

public void processMessage(Message t)
Called by the BlockingTycho API and used internally by this class. Clients instantiating this class should NOT call this method. Instead they should interact with this object using the contract specified in the Monitoring and EventHandler Interfaces.


registerForEvents

public long registerForEvents(EventType eventType,
                              String gatewayName,
                              EventHandler handler,
                              Credential userCredential)
                       throws Exception
Use this method to register interest in events.

Specified by:
registerForEvents in interface Monitoring
Parameters:
eventType: - The type of event you wish to register to receive
gatewayName: - The name of the gateway to send command to.
Throws:
Exception

cancelEventRegistration

public boolean cancelEventRegistration(EventType eventType,
                                       String gatewayName,
                                       Credential userCredential)
                                throws Exception
Use this method to cancel an event registration that you previously made using the registerForEvents(...) method.

Specified by:
cancelEventRegistration in interface Monitoring
Parameters:
eventType: - The type of event you wish to register to receive
gatewayName: - The name of the gateway to send this command to.
userCredential -
Returns:
true if an event registration was cancelled. False if there was no existing event registration of this type at the gateway.
Throws:
Exception: - If any error occurred that prevented the request from being processed by the gateway (e.g. authorisation failure).
Exception

getCoreAttributeValues

public Resource getCoreAttributeValues(String resourceName,
                                       String gatewayName,
                                       CacheTTL ttl,
                                       Credential userCredential)
                                throws Exception
Retrieve the core attribute values for the named resource only. If the named resource is e.g. a beowulf cluster, only metrics for the head node is returned. If you want to see compute nodes as well then use the other getCoreAttributeValues() methods and set the namedOnly parameter to false.

Specified by:
getCoreAttributeValues in interface Monitoring
Parameters:
gatewayName: - The name of the gateway to send this command to.
resourceName -
attributes -
Returns:
Throws:
Exception

getCoreAttributeValues

public Resource[] getCoreAttributeValues(String gatewayName,
                                         CacheTTL ttl,
                                         Credential userCredential)
                                  throws Exception
Retrieve the core attribute values for all resources registered with the named gateway. This method returns all registered resources and any additional resources that are provided by the registered resource's monitoring agent.

Specified by:
getCoreAttributeValues in interface Monitoring
Parameters:
gatewayName: - The name of the gateway to send this command to.
ttl: - The gateway cache policy to use
userCredential: - The user credentials
Returns:
Throws:
Exception

getCoreAttributeValues

public Resource[] getCoreAttributeValues(String[] resourceNames,
                                         boolean registeredOnly,
                                         String gatewayName,
                                         CacheTTL ttl,
                                         Credential userCredential)
                                  throws Exception
Retrieve the core attribute values for the named resources

Specified by:
getCoreAttributeValues in interface Monitoring
Parameters:
resourceNames: - The name of each resource
namedOnly: - Some agents (e.g. Ganglia) allow a single resource to include data for multiple peer resources (e.g. nodes in a cluster). Such behaviour is not always desirable, for example when offering a single workstation to the SORMA market, that just happens to be monitored by a Ganglia gmond that is configured to receive peer metrics over multicast (the default gmond behaviour). Set to true to ensure the metrics for the named resource only are returned. Set to false if you also want to see any additional resources that are related to the named resource (e.g. a named resource is the headnode to a beowulf cluster and the related nodes would be the cluster's compute nodes.
gatewayName: - The name of the gateway to send this command to.
ttl: - The gateway cache policy to use
userCredential: - The user credentials
Returns:
Resource[] an array of Resource values.
Throws:
Exception

query

public ResultSet query(SqlQuery sqlQuery,
                       String gatewayName,
                       Credential userCredential)
                throws SQLException,
                       Exception
Submit an SQL query to the gateway

Specified by:
query in interface Monitoring
Parameters:
SqlQuery: - The SQL query to execute
gatewayName: - The name of the gateway to send this command to.
ttl: - The gateway cache policy to use (as appropriate)
userCredential: - The user credentials
Returns:
Throws:
SQLException
Exception

listRegisteredDrivers

public Driver[] listRegisteredDrivers(String gatewayName,
                                      Credential userCredential)
                               throws Exception
Description copied from interface: Monitoring
Returns a list of the drivers that have been registered at the default gateway

Specified by:
listRegisteredDrivers in interface Monitoring
Returns:
Throws:
Exception

listRegisteredResources

public ResourceRegistrationDescription[] listRegisteredResources(String gatewayName,
                                                                 Credential userCredential)
                                                          throws Exception
Returns a list of the resources currently registered with the specified gateway

Specified by:
listRegisteredResources in interface Monitoring
Parameters:
String - gatewayName: The gateway's Tycho name
Credential: - The user's credential
Throws:
Exception

tychoClientRegistered

public void tychoClientRegistered()
Invoked by Tycho when the client is registered.


finalize

public void finalize()
Overrides:
finalize in class Object

reportProblem

public void reportProblem(ProblemReport report,
                          String gatewayName,
                          Credential userCredential)
                   throws Exception
Description copied from interface: Monitoring
Send a problem report to the gateway.

Specified by:
reportProblem in interface Monitoring
Parameters:
ProblemReport - report: The issue we wish to report to the gateway admin
Throws:
Exception: - If any problems occur that mean the report cannot be sent
Exception

registerResource

public void registerResource(String name,
                             DriverType driver,
                             int nonStandardPort,
                             Credential resourceCredential,
                             String gatewayName,
                             Credential userCredential)
                      throws ResourceAlreadyRegisteredException,
                             IOException
Register a new resource for monitoring by the specified gateway

Specified by:
registerResource in interface Monitoring
Parameters:
name: - The name of the resource
driver: - The default driver to use for this resource
nonStandardPort: - If 0 use default port for resource agent, if >1 then use the specified port instead of the default port.
resourceCredential: - A credential required to authenticate with the underlying resource agent. A null value indicates that either a credential is not required, or it is not known at this time (in case of the latter, subsequent queries to the resource can be expected to fail. The admin can update resource credential at the gateway).
gatewayName: - The name of the gateway to submit the command to.
userDN: - The user's distinguished name
Throws:
ResourceAlreadyRegisteredException: - If the named resource is already registered at the gateway
IOException: - If the name resolution or network interaction fail
ResourceAlreadyRegisteredException
IOException

unregisterResource

public void unregisterResource(String resourceName,
                               String gatewayName,
                               Credential userCredential)
                        throws IOException
Remove a resource

Specified by:
unregisterResource in interface Monitoring
Parameters:
name - resource name
ip - resource IP address
userDN - uses distinguished name
gatewayName - the gateway to submit the command to
Throws:
IOException

shutdown

public void shutdown()
              throws IOException
Unregister the client from the Tycho registry

Specified by:
shutdown in interface Monitoring
Throws:
IOException

startResourceWatch

public void startResourceWatch(String resourceName,
                               int frequency,
                               long duration,
                               String gatewayName,
                               Credential userCredential,
                               EventHandler handler)
                        throws IOException
Instructs the gateway to capture the specified resource's core attribute values at the stated frequency and store them in the gateway's internal database. Subsequent watch requests for the same resource override earlier requests. If the resource is unregistered from the gateway during the watch, then the watch is cancelled and a RESOURCE_UNREGISTERED event is sent to the specified EventHandler. If data capture failures occur for any other reason then the client is notified by RESOURCE_FAILED_TO_RESPOND events.

Specified by:
startResourceWatch in interface Monitoring
Parameters:
resourceName: - The resource to watch.
frequency: - The frequency in seconds between resource polls
duration: - The duration in seconds that the watch should last
gatewayName: - the gateway to submit the command to
userCredential: - The user credentials
handler: - The eventHandler to receive
Throws:
java.io.IOException: - If the named resource is not a registered resource.
IOException

haltResourceWatch

public boolean haltResourceWatch(String resourceName,
                                 String gatewayName,
                                 Credential userCredential)
                          throws IOException
Halt a previously started resource watch. If no watch is in place then this call has no effect.

Specified by:
haltResourceWatch in interface Monitoring
Parameters:
resourceName -
gatewayName -
userCredential -
Throws:
java.io.IOException: - If any other problems occurred that caused this call to fail.
IOException

getResourceWatchData

public ResultSet getResourceWatchData(String resourceName,
                                      String gatewayName,
                                      Credential userCredential)
                               throws IOException
Returns historical data that was captured using the startResourceWatch() method. Currently this method returns all data that was ever recorded for the resource. Later versions will allow data to be retrieved from specific datetime ranges.

Specified by:
getResourceWatchData in interface Monitoring
Parameters:
resourceName -
gatewayName -
userCredential -
Returns:
Throws:
IOException

startJobWatch

public void startJobWatch(String jobId,
                          int interval,
                          String resourceName,
                          String gatewayName,
                          Credential userCredential)
                   throws IOException
Instructs the gateway to monitor the execution of a particular job. The gateway samples process utilisation at the specified period and saves the resulting data to the gateway's internal database. *

Specified by:
startJobWatch in interface Monitoring
Parameters:
jobId: - An identifier that the resource's agent can use to determine the process to be monitored. E.g. process ID (pid) in the case of fork().
interval: - the process utilisation sampling period in milliseconds
resourceName: - The resource executing the job.
gatewayName: - The gateway to submit the command to
userCredential: - The user credentials
Throws:
IOException

stopJobWatch

public void stopJobWatch(String jobId,
                         String resourceName,
                         String gatewayName,
                         Credential userCredential)
                  throws IOException
Instructs the gateway to stop watching the specified job.

Specified by:
stopJobWatch in interface Monitoring
Parameters:
jobId: - job identifier
resourceName: - The resource executing the job.
gatewayName: - The gateway to submit the command to
userCredential: - The user credentials
Throws:
IOException

getJobWatchData

public Job getJobWatchData(String jobId,
                           String resourceName,
                           String gatewayName,
                           Credential userCredential)
                    throws IOException
Return data from the gateway's internal database that resulted from a particular jobWatch.

Specified by:
getJobWatchData in interface Monitoring
Parameters:
jobId -
resourceName -
gatewayName -
userCredential -
Returns:
Throws:
IOException


Copyright © 2007 Garry Smith. All Rights Reserved.