com.caucho.http.admin
Class PingThread

java.lang.Object
  |
  +--com.caucho.http.admin.PingThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
PingMailer

public class PingThread
extends java.lang.Object
implements java.lang.Runnable

A thread to restart the Resin server if it fails for some reason.

This pinging only catches some problems because it's running in the same JDK process as Resin itself. If the entire JDK freezes, this thread will freeze as well. Assuming the JDK doesn't freeze, the PingThread will catch errors like deadlocks.


Field Summary
protected  ResinServer resinServer
           
 
Constructor Summary
PingThread()
           
 
Method Summary
 void addURL(java.lang.String url)
          Adds a new URL to be tested.
protected  boolean checkPing(Path url, int count)
          Called to check if the connection is alive.
 java.lang.String getPingHost()
          Returns the server's ping host
 int getPingPort()
          Returns the server's ping port
 ResinServer getResinServer()
          Gets the underlying server.
 long getRetryTime()
          Gets the retry time between failing pings
 long getSleepTime()
          Gets the sleep time between pings
 long getSocketTimeout()
          Gets the time to wait on a non-responsive socket before giving up.
 int getTryCount()
          Gets the number of times to retry before giving up
 void init()
           
protected  void pingFailed(Path url)
          Called if the ping completely fails.
protected  void pingFailedOnce(Path url, int count, ReadStream is)
          Called if the ping fails once.
 void run()
          Periodically pings the server to check for anything going wrong.
 void setPingHost(java.lang.String pingHost)
          Sets the server's ping host
 void setPingPort(int pingPort)
          Sets the server's ping port
 void setResinServer(ResinServer server)
          Sets the underlying server.
 void setRetryTime(long retryTime)
          Sets the retry time between failing pings
 void setSleepTime(long sleepTime)
          Sets the sleep time between pings
 void setSocketTimeout(long timeout)
          Sets the number of times to retry before giving up
 void setTryCount(int tryCount)
          Sets the number of times to retry before giving up
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resinServer

protected ResinServer resinServer
Constructor Detail

PingThread

public PingThread()
Method Detail

getResinServer

public ResinServer getResinServer()
Gets the underlying server.

setResinServer

public void setResinServer(ResinServer server)
Sets the underlying server.

getPingHost

public java.lang.String getPingHost()
Returns the server's ping host

setPingHost

public void setPingHost(java.lang.String pingHost)
Sets the server's ping host

getPingPort

public int getPingPort()
Returns the server's ping port

setPingPort

public void setPingPort(int pingPort)
Sets the server's ping port

addURL

public void addURL(java.lang.String url)
Adds a new URL to be tested.

getSleepTime

public long getSleepTime()
Gets the sleep time between pings

setSleepTime

public void setSleepTime(long sleepTime)
Sets the sleep time between pings

getRetryTime

public long getRetryTime()
Gets the retry time between failing pings

setRetryTime

public void setRetryTime(long retryTime)
Sets the retry time between failing pings

getTryCount

public int getTryCount()
Gets the number of times to retry before giving up

setTryCount

public void setTryCount(int tryCount)
Sets the number of times to retry before giving up

getSocketTimeout

public long getSocketTimeout()
Gets the time to wait on a non-responsive socket before giving up.

setSocketTimeout

public void setSocketTimeout(long timeout)
Sets the number of times to retry before giving up

init

public void init()

run

public void run()
Periodically pings the server to check for anything going wrong.
Specified by:
run in interface java.lang.Runnable

checkPing

protected boolean checkPing(Path url,
                            int count)
                     throws java.lang.Exception
Called to check if the connection is alive.

pingFailedOnce

protected void pingFailedOnce(Path url,
                              int count,
                              ReadStream is)
                       throws java.lang.Exception
Called if the ping fails once.

pingFailed

protected void pingFailed(Path url)
                   throws java.lang.Exception
Called if the ping completely fails.