br.shob.server
Class Pinger

java.lang.Object
  |
  +--java.util.TimerTask
        |
        +--br.shob.server.Pinger
All Implemented Interfaces:
Runnable

public class Pinger
extends TimerTask
implements Runnable

A TimerTask and static utility pinger. The server calls the pinger to concurrently ping clients and take action in case they don't respond.

Since:
September 18, 2002
Author:
crolmos
Created:
6 de Setembro de 2002

Field Summary
static int PING_ALL_HOSTS
          Constant that indicates that all hosts should be pingged
static int PING_OBSERVERS_ONLY
          Constant that indicates that only inactive hosts should be pingged
static int PING_OWNERS_AND_WRITERS
          Constant that indicates that only active hosts should be pingged
static int PING_OWNERS_ONLY
          Constant that indicates that only hosts who shared at least one object should be pingged
static int PING_WRITERS_ONLY
          Constant that indicates that only hosts who locked at least one object should be pingged
 
Constructor Summary
Pinger(Server server)
          Creates a pinger that pings all hosts every 5 seconds
Pinger(Server server, int pingMethod)
          Creates a pinger that pings by the specified pingMethod every 5 seconds
Pinger(Server server, int pingMethod, long waitTime)
          Creates a pinger that pings by the specified pingMethod every waitTime seconds
 
Method Summary
 int getPingMethod()
          Gets the pingMethod attribute of the Pinger object
static void pingAllHosts(Server server)
          Description of the Method
static void pingObservers(Server server)
          Description of the Method
 void pingOnce()
          Description of the Method
static void pingOnce(Server server, Set targets)
          Main processing method for the Pinger object
static void pingOwners(Server server)
          Description of the Method
static void pingWriters(Server server)
          Description of the Method
 void run()
          Main processing method for the Pinger object
 void scheduleTo(Timer timer)
           
 void setPingMethod(int pingMethod)
          Sets the pingMethod attribute of the Pinger object
 void setWaitTime(long miliseconds)
          Sets the waitTime attribute of the Pinger object
 void stop()
          Description of the Method
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PING_ALL_HOSTS

public static final int PING_ALL_HOSTS
Constant that indicates that all hosts should be pingged

See Also:
Constant Field Values

PING_OBSERVERS_ONLY

public static final int PING_OBSERVERS_ONLY
Constant that indicates that only inactive hosts should be pingged

See Also:
Constant Field Values

PING_OWNERS_AND_WRITERS

public static final int PING_OWNERS_AND_WRITERS
Constant that indicates that only active hosts should be pingged

See Also:
Constant Field Values

PING_OWNERS_ONLY

public static final int PING_OWNERS_ONLY
Constant that indicates that only hosts who shared at least one object should be pingged

See Also:
Constant Field Values

PING_WRITERS_ONLY

public static final int PING_WRITERS_ONLY
Constant that indicates that only hosts who locked at least one object should be pingged

See Also:
Constant Field Values
Constructor Detail

Pinger

public Pinger(Server server)
Creates a pinger that pings all hosts every 5 seconds

Parameters:
server - The server that wants the pinging service

Pinger

public Pinger(Server server,
              int pingMethod,
              long waitTime)
Creates a pinger that pings by the specified pingMethod every waitTime seconds

Parameters:
server - The server that wants the pinging service
pingMethod - one of the PING_* contants defined in this class
waitTime - time to wait between pings, in miliseconds

Pinger

public Pinger(Server server,
              int pingMethod)
Creates a pinger that pings by the specified pingMethod every 5 seconds

Parameters:
server - The server that wants the pinging service
pingMethod - one of the PING_* contants defined in this class
Method Detail

getPingMethod

public int getPingMethod()
Gets the pingMethod attribute of the Pinger object

Returns:
The pingMethod value

pingAllHosts

public static void pingAllHosts(Server server)
Description of the Method

Parameters:
server - Description of the Parameter

pingObservers

public static void pingObservers(Server server)
Description of the Method

Parameters:
server - Description of the Parameter

pingOnce

public void pingOnce()
Description of the Method


pingOnce

public static void pingOnce(Server server,
                            Set targets)
Main processing method for the Pinger object

Parameters:
targets - Description of the Parameter
server - Description of the Parameter

pingOwners

public static void pingOwners(Server server)
Description of the Method

Parameters:
server - Description of the Parameter

pingWriters

public static void pingWriters(Server server)
Description of the Method

Parameters:
server - Description of the Parameter

run

public void run()
Main processing method for the Pinger object

Specified by:
run in interface Runnable
Specified by:
run in class TimerTask

setPingMethod

public void setPingMethod(int pingMethod)
Sets the pingMethod attribute of the Pinger object

Parameters:
pingMethod - The new pingMethod value

setWaitTime

public void setWaitTime(long miliseconds)
Sets the waitTime attribute of the Pinger object

Parameters:
miliseconds - The new waitTime value

stop

public void stop()
Description of the Method


scheduleTo

public void scheduleTo(Timer timer)