com.funambol.push
Class CTPService.HeartbeatGenerator

java.lang.Object
  extended by java.lang.Thread
      extended by com.funambol.push.CTPService.HeartbeatGenerator
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
CTPService

protected class CTPService.HeartbeatGenerator
extends java.lang.Thread

This class implements an hearbeat generator. A thread which is in charge of generating messages for the CTP server to signal that the client is alive. The interval between successive messages is specified in the configuration. The thread sends a message and wait for an answer. The send operation is monitored for timeout. The answer is caught by the main listener thread. The heartbeat generator only checks whether an ok has been received. In this case it consider everything is OK. This is a trick as we do not really monitor the reading with a timeout. We rather expects that the OK arrives before we have to generate a new READY message. This way we simplify the implementation and the behavior seems still reasonable.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected CTPService.HeartbeatGenerator()
           
 
Method Summary
 boolean isRunning()
          Returns true if the heart is beating.
 void run()
          This is the heart beat main loop.
 
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
 

Constructor Detail

CTPService.HeartbeatGenerator

protected CTPService.HeartbeatGenerator()
Method Detail

run

public void run()
This is the heart beat main loop. It generates a beat every ready period of time (as specified in the PushConfig. The task runs until the termination flag (done) gets set. If at the moment of generating a new beat, the previous has not received an OK status, then a ctp restart is forced by closing the connection.

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

isRunning

public boolean isRunning()
Returns true if the heart is beating.



Copyright © 2001-2009 Funambol.