edu.sdsc.inca.agent
Class ReporterManagerTable

java.lang.Object
  extended by java.lang.Thread
      extended by edu.sdsc.inca.agent.ReporterManagerTable
All Implemented Interfaces:
java.lang.Runnable

public class ReporterManagerTable
extends java.lang.Thread

Convenience class for storing and tracking reporter managers. This wraps a Hashtable and provides functions specifically for working with reporter manager objects (e.g., you don't have to cast an object after getting it). It also is a thread that checks the viability of reporter managers. In the case that a reporter manager starter thread gets stuck, this thread will force a restart. This class is thread-safe.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static long MAX_START_TIME
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ReporterManagerTable()
           
 
Method Summary
 boolean containsResource(java.lang.String resource)
          Returns true if the specified resource exists in the table.
 ReporterManagerController get(java.lang.String resource)
          Returns the reporter manager if it exists in the table regardless if it's running or not.
 int getCheckPeriod()
          Get the frequency of which this thread should check the health of the reporter managers.
 java.lang.String[] getResourceNames()
          Return the a list of resources who have reporter managers stored in the table.
 void put(java.lang.String resource, ReporterManagerController rm)
          Add a reporter manager to the table.
 void remove(java.lang.String resource)
          Removes the specified reporter manager from the table.
 void run()
          Check all reporter manager periodically to see if they are still running.
 void setCheckPeriod(int checkPeriod)
          Set the frequency of which the thread should check the health of the reporter managers.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_START_TIME

public static long MAX_START_TIME
Constructor Detail

ReporterManagerTable

public ReporterManagerTable()
Method Detail

containsResource

public boolean containsResource(java.lang.String resource)
Returns true if the specified resource exists in the table. Note, that the reporter manager may still be in the start up process.

Parameters:
resource - A resource name from the resource configuration file.
Returns:
True if the resource exists and false otherwise.

get

public ReporterManagerController get(java.lang.String resource)
Returns the reporter manager if it exists in the table regardless if it's running or not.

Parameters:
resource -
Returns:
A reporter manager object.

getCheckPeriod

public int getCheckPeriod()
Get the frequency of which this thread should check the health of the reporter managers.

Returns:
The period in milliseconds.

getResourceNames

public java.lang.String[] getResourceNames()
Return the a list of resources who have reporter managers stored in the table.

Returns:
A list of resource names.

put

public void put(java.lang.String resource,
                ReporterManagerController rm)
Add a reporter manager to the table.

Parameters:
resource - A string for retrieving the reporter manager from the table.
rm - A reporter manager to store in the table.

remove

public void remove(java.lang.String resource)
Removes the specified reporter manager from the table.

Parameters:
resource - The name of the resource whose reporter manager should be removed from the table.

run

public void run()
Check all reporter manager periodically to see if they are still running. If the rm.isRunning flag is false, we know there is no remote reporter manager running. In that case, either 1) the reporter manager's starter thread is running and we just need to give it time to do start up a remote reporter manager, 2) the reporter manager's starter thread is running but is blocked on a call and needs to be timed out, or 3) the reporter manager starter thread is not running in which case we can start up a new one. We are ignoring (2) until we have more experience with the nature of reporter managers not getting restarted automatically.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setCheckPeriod

public void setCheckPeriod(int checkPeriod)
Set the frequency of which the thread should check the health of the reporter managers.

Parameters:
checkPeriod - Period in milliseconds.