com.limegroup.gnutella.uploader
Class StalledUploadWatchdog

java.lang.Object
  extended bycom.limegroup.gnutella.uploader.StalledUploadWatchdog
All Implemented Interfaces:
java.lang.Runnable

public final class StalledUploadWatchdog
extends java.lang.Object
implements java.lang.Runnable

Kills an OutputStream after a certain amount of time has passed.

The flow has the following methodology: When constructed, this class is inactive and does nothing. To activate the stall-checking, you must call 'activate'. When activate is called, it updates the 'check time' to be DELAY_TIME plus the current time and also schedules the task if necessary. To deactive the stall-checking, you must call 'deactivate'. Deactivate does NOT remove the task from the RouterService's schedule, but it does tell the checker to not kill the output stream when it is run.

Because the task can be reactivated without rescheduling, it is possible that RouterService may 'run' the task before the most recent delay time has expired. To counteract this, 'activate' will store the time that it expects 'run' to be called. If 'run' is called too soon, it will reschedule the task to be run at the appropriate time.

All methods are synchronized and guaranteed to not lock the timer queue.


Field Summary
static long DELAY_TIME
          The amount of time to wait before we close this connection if nothing has been written to the socket.
 
Constructor Summary
StalledUploadWatchdog()
           
 
Method Summary
 void activate(java.io.OutputStream ostream)
          Activates the checking.
 boolean deactivate()
          Deactives the killing of the NormalUploadState
 void run()
          Kills the upload if we're active, and tells the state to close the connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELAY_TIME

public static long DELAY_TIME
The amount of time to wait before we close this connection if nothing has been written to the socket. Non final for testing.

Constructor Detail

StalledUploadWatchdog

public StalledUploadWatchdog()
Method Detail

deactivate

public boolean deactivate()
Deactives the killing of the NormalUploadState


activate

public void activate(java.io.OutputStream ostream)
Activates the checking.


run

public void run()
Kills the upload if we're active, and tells the state to close the connection. Reschedules if needed.

Specified by:
run in interface java.lang.Runnable