edu.sdsc.inca.agent
Class ReporterManagerController

java.lang.Object
  extended by edu.sdsc.inca.agent.ReporterManagerController

public class ReporterManagerController
extends java.lang.Object

Manages a reporter manager instance on a remote machine. It maintains a persistent connection to the manager and provides the ability to send packages and suites to the remote reporter manager. It also has the ability to detect a fault of the reporter manager by regularly pinging it and and restarting it if necessary.

Author:
Shava Smallen

Field Summary
protected  Agent agent
           
static java.lang.String BATCH_REPORTER
           
static int ISREADY_PERIOD
           
static int SUITE_CHECK_PERIOD
           
 
Constructor Summary
ReporterManagerController(ReporterManagerController rm)
          Create a new reporter manager object, whose configuration is identical to rm, which will manage an instance of a reporter manager on a remote resource.
ReporterManagerController(java.lang.String resource, Agent agent)
          Create a reporter manager object which will manage a instance of a reporter manager on a remote resource.
 
Method Summary
 void addPackage(java.lang.String packageName)
          Add the specified package to the work queue so that the register thread can pick it up and send it to the reporter manager.
 void addSuite(edu.sdsc.inca.dataModel.suite.SuiteDocument suite)
          Add the specified suite to the work queue so that the register thread can pick it up and send it to the reporter manager.
 edu.sdsc.inca.dataModel.catalog.PackageType[] extractReportersFromSuite(edu.sdsc.inca.dataModel.suite.SuiteDocument s)
          Extract the reporters from the specified suite document which do not already exist on the remote reporter manager.
 edu.sdsc.inca.ManagerClient getManagerClient()
          Return the client connection to the remote reporter manager.
 edu.sdsc.inca.dataModel.catalog.PackageType[] getPackages()
          Return the packages that are installed on the reporter manager.
 ReporterManagerProxy getProxy()
          Return the proxy object for this resource.
 ReporterManagerStarter getReporterManagerStarter()
           
 java.lang.String getResource()
          Return the name of this resource.
 java.lang.String getTemporaryDirectory()
          Gets the directory path where the temporary files can be stored.
 boolean hasPackage(java.lang.String name, java.lang.String version)
          Return true if the manager has been sent the given package; otherwise return false.
 boolean hasProxy()
          Return whether or not proxy information is listed for this resource.
 boolean isRemoteManagerAlive()
          Pings the reporter manager to check whether it is still running on the remote resource and returns the status.
 boolean isRunning()
          Return true if the reporter manager is currently registered and running.
 void register(edu.sdsc.inca.protocol.ProtocolReader reader, edu.sdsc.inca.protocol.ProtocolWriter writer)
          Register the specified reporter manager with the agent so that the agent can send it commands.
 void restart()
          Restart this reporter manager.
protected  void sendReporters(edu.sdsc.inca.dataModel.catalog.PackageType[] reporters)
          Send the specified reporters and their package dependencies to the remote reporter manager.
 void sendSuite(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
          Send the specified suite and any needed reporters to the remote reporter manager.
 void setManagerClient(edu.sdsc.inca.ManagerClient managerClient)
          Set the client connection to the remote reporter manager.
 void setProxy(ReporterManagerProxy proxy)
          Set the proxy renewal information so it can be passed to the remote reporter manager on registration.
 void setRunning(boolean isRunning)
          Set the status of the reporter manager to running and notify any waiting threads.
 void setTempDir(java.lang.String tempDir)
          Set the location of the temporary directory.
 void shutdown()
          Cleanly shutdown the reporter manager by signaling the register thread to exit and sending an END statement to the remote reporter manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ISREADY_PERIOD

public static final int ISREADY_PERIOD
See Also:
Constant Field Values

SUITE_CHECK_PERIOD

public static final int SUITE_CHECK_PERIOD
See Also:
Constant Field Values

BATCH_REPORTER

public static final java.lang.String BATCH_REPORTER
See Also:
Constant Field Values

agent

protected Agent agent
Constructor Detail

ReporterManagerController

public ReporterManagerController(java.lang.String resource,
                                 Agent agent)
                          throws edu.sdsc.inca.ConfigurationException
Create a reporter manager object which will manage a instance of a reporter manager on a remote resource.

Parameters:
resource - Name of the resource (from the resource configuration file) to start the reporter manager on.
agent - The agent the reporter manager is registered with
Throws:
edu.sdsc.inca.ConfigurationException - if there is missing configuration information for the resource.

ReporterManagerController

public ReporterManagerController(ReporterManagerController rm)
Create a new reporter manager object, whose configuration is identical to rm, which will manage an instance of a reporter manager on a remote resource.

Parameters:
rm - A reporter manager object that will be used to configure this reporter manager object.
Method Detail

addPackage

public void addPackage(java.lang.String packageName)
Add the specified package to the work queue so that the register thread can pick it up and send it to the reporter manager.

Parameters:
packageName - The name of the package to send to the remote reporter manager.

addSuite

public void addSuite(edu.sdsc.inca.dataModel.suite.SuiteDocument suite)
Add the specified suite to the work queue so that the register thread can pick it up and send it to the reporter manager.

Parameters:
suite - A suite document to send to the reporter manager.

extractReportersFromSuite

public edu.sdsc.inca.dataModel.catalog.PackageType[] extractReportersFromSuite(edu.sdsc.inca.dataModel.suite.SuiteDocument s)
Extract the reporters from the specified suite document which do not already exist on the remote reporter manager.

Parameters:
s - A suite document that will be sent to the reporter manager
Returns:
An array of reporter packages that exist in the suite and do not exist on the remote reporter manager.

getManagerClient

public edu.sdsc.inca.ManagerClient getManagerClient()
Return the client connection to the remote reporter manager.

Returns:
The manager client object connected to the remote reporter manager.

getPackages

public edu.sdsc.inca.dataModel.catalog.PackageType[] getPackages()
Return the packages that are installed on the reporter manager.

Returns:
A property list of packages that are installed on the reporter manager where the package names are the "name" and package versions are the "value".

getProxy

public ReporterManagerProxy getProxy()
Return the proxy object for this resource.

Returns:
A ReporterManagerProxy object containing the proxy information for this resource or null if it does not exist.

getResource

public java.lang.String getResource()
Return the name of this resource.

Returns:
The name of the resource the reporter manager will execute on.

isRunning

public boolean isRunning()
Return true if the reporter manager is currently registered and running.

Returns:
True if the reporter manager is currently registered and running and false otherwise.

getReporterManagerStarter

public ReporterManagerStarter getReporterManagerStarter()

getTemporaryDirectory

public java.lang.String getTemporaryDirectory()
Gets the directory path where the temporary files can be stored.

Returns:
A path to a local directory.

hasPackage

public boolean hasPackage(java.lang.String name,
                          java.lang.String version)
Return true if the manager has been sent the given package; otherwise return false.

Parameters:
name - The name of the package to check for.
version - The version of the package to check for.
Returns:
true if the manager has been sent the given package; otherwise return false.

hasProxy

public boolean hasProxy()
Return whether or not proxy information is listed for this resource.

Returns:
True if proxy information is available for this resource; otherwise false.

isRemoteManagerAlive

public boolean isRemoteManagerAlive()
Pings the reporter manager to check whether it is still running on the remote resource and returns the status.

Returns:
True if the reporter manager responded to the ping and false otherwise.

register

public void register(edu.sdsc.inca.protocol.ProtocolReader reader,
                     edu.sdsc.inca.protocol.ProtocolWriter writer)
Register the specified reporter manager with the agent so that the agent can send it commands. Holds a socket connection open to the reporter manager and loops indefinitely (until a shutdown) to send requests to the reporter manager. Initially, the agent will retrieve any existing suites for the reporter manager and empty its work queue (since any pending work should already be incorporated into the suites. Following that requests (currently suites only) are retrieved from a work queue. Work is added to the work queue, for example, when a client sends the agent a suite request

Parameters:
reader - the ProtocolReader for reading responses from the remote reporter manager.
writer - the ProtocolWriter for sending commands to the remote

sendSuite

public void sendSuite(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
               throws java.io.IOException,
                      java.lang.InterruptedException
Send the specified suite and any needed reporters to the remote reporter manager. Will pass thru an IOException so that it can be addressed (most likely this means the reporter manager died and we need to restart it). Catches ProtocolExceptions and logs them as errors but will continue operation.

Parameters:
suiteDoc - The suite to send to the remote reporter manager.
Throws:
java.io.IOException - if trouble sending suite
java.lang.InterruptedException - if interrupted during send of suite

setManagerClient

public void setManagerClient(edu.sdsc.inca.ManagerClient managerClient)
Set the client connection to the remote reporter manager.

Parameters:
managerClient - The manager client object connected to the remote reporter manager.

setProxy

public void setProxy(ReporterManagerProxy proxy)
Set the proxy renewal information so it can be passed to the remote reporter manager on registration.

Parameters:
proxy - Contains MyProxy information that can be used to retrieve a new proxy for the remote reporter manager.

setRunning

public void setRunning(boolean isRunning)
Set the status of the reporter manager to running and notify any waiting threads.

Parameters:
isRunning - True indicates the reporter manager is running on the remote machine and available; false otherwise.

setTempDir

public void setTempDir(java.lang.String tempDir)
Set the location of the temporary directory.

Parameters:
tempDir - A path to a directory where temporary files can be stored.

shutdown

public void shutdown()
Cleanly shutdown the reporter manager by signaling the register thread to exit and sending an END statement to the remote reporter manager.


sendReporters

protected void sendReporters(edu.sdsc.inca.dataModel.catalog.PackageType[] reporters)
                      throws java.io.IOException,
                             java.lang.InterruptedException
Send the specified reporters and their package dependencies to the remote reporter manager.

Parameters:
reporters - A list of reporters to send to the remote reporter manager.
Throws:
java.io.IOException - if problem sending reporters
java.lang.InterruptedException - if interrupted during send of reporters

restart

public void restart()
Restart this reporter manager. Since you cannot restart a thread we create a duplicate reporter manager object and execute its start method. We then replace the reporter manager in the reporter manager table.