com.isti.util
Class HeartbeatFile

java.lang.Object
  extended by com.isti.util.HeartbeatFile

public class HeartbeatFile
extends java.lang.Object

Class HeartbeatFile defines a utility that generates a heartbeat // file that can be used to determine if the program is running.


Constructor Summary
HeartbeatFile()
          Creates a thread heartbeat object.
 
Method Summary
 boolean addThread(NotifyThread threadObj)
          Adds a mandatory thread for the heartbeat.
 boolean addThread(java.lang.Thread threadObj)
          Adds a mandatory thread for the heartbeat.
protected  java.util.List createThreadList()
          Creates the thread list.
protected  java.util.List getThreadList()
          Gets the thread list.
protected  java.util.Iterator getThreadListIterator()
          Gets the thread list iterator.
protected  java.lang.String getThreadName(java.lang.Object obj)
          Determines if the thread name.
protected  boolean isThreadAlive(java.lang.Object obj)
          Determines if the thread is alive.
 void setFilename(java.lang.String heartbeatFilename)
          Sets the filename for the heartbeat file.
 void setIntervalMSecs(int intervalMSecs)
          Sets the interval for the heartbeat file.
 void setLogObj(LogFile logObj)
          Sets the logfile object.
 boolean start()
          Starts the heartbeat thread.
 void terminate()
          Terminates the heartbeat thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeartbeatFile

public HeartbeatFile()
Creates a thread heartbeat object. The "addThread", "setFilename", "setIntervalMSecs" and "setLogObj" methods should be called to setup the heartbeat parameters before starting the heartbeat thread via the "start" method.

Method Detail

addThread

public boolean addThread(NotifyThread threadObj)
Adds a mandatory thread for the heartbeat.

Parameters:
threadObj - the Thread object.
Returns:
true if the thread was added, false otherwise.

addThread

public boolean addThread(java.lang.Thread threadObj)
Adds a mandatory thread for the heartbeat.

Parameters:
threadObj - the Thread object.
Returns:
true if the thread was added, false otherwise.

getThreadName

protected java.lang.String getThreadName(java.lang.Object obj)
Determines if the thread name.

Parameters:
obj - the thread object.
Returns:
the thread name.

createThreadList

protected java.util.List createThreadList()
Creates the thread list.

Returns:
the thread list.

getThreadList

protected final java.util.List getThreadList()
Gets the thread list.

Returns:
the thread list.

getThreadListIterator

protected java.util.Iterator getThreadListIterator()
Gets the thread list iterator.

Returns:
the thread list iterator.

isThreadAlive

protected boolean isThreadAlive(java.lang.Object obj)
Determines if the thread is alive.

Parameters:
obj - the thread object.
Returns:
true if the thread is alive, false otherwise.

setFilename

public void setFilename(java.lang.String heartbeatFilename)
Sets the filename for the heartbeat file.

Parameters:
heartbeatFilename - the filename for the heartbeat file.

setIntervalMSecs

public void setIntervalMSecs(int intervalMSecs)
Sets the interval for the heartbeat file.

Parameters:
intervalMSecs - the interval for the heartbeat file.

setLogObj

public void setLogObj(LogFile logObj)
Sets the logfile object.

Parameters:
logObj - the LogFile object to use for output or null for none.

start

public boolean start()
Starts the heartbeat thread. The "addThread", "setFilename", "setIntervalMSecs" and "setLogObj" methods should be called to setup the heartbeat parameters before starting the heartbeat thread.

Returns:
true if there was an error starting the heartbeat thread, false otherwise.

terminate

public void terminate()
Terminates the heartbeat thread.