org.jboss.remoting.detection
Class AbstractDetector

java.lang.Object
  extended by org.jboss.remoting.detection.AbstractDetector
All Implemented Interfaces:
javax.management.MBeanRegistration, AbstractDetectorMBean, Detector
Direct Known Subclasses:
JNDIDetector, MulticastDetector

public abstract class AbstractDetector
extends java.lang.Object
implements AbstractDetectorMBean

AbstractDetector

Version:
$Revision: 5114 $
Author:
Jeff Haynie, Tom Elrod

Field Summary
protected  org.jboss.logging.Logger log
           
protected  javax.management.MBeanServer mbeanserver
           
protected  NetworkRegistryMBean networkRegistry
           
protected  javax.management.ObjectName objectName
           
protected  javax.management.ObjectName registryObjectName
           
 
Constructor Summary
AbstractDetector()
           
AbstractDetector(java.util.Map config)
           
 
Method Summary
protected  boolean checkInvokerServer(Detection detection, java.lang.ClassLoader cl)
           
 Detection createDetection()
          Will create a detection message based on the server invokers registered within the local InvokerRegistry.
protected  void detect(Detection detection)
          called when a remote detection from a peer is received by a detector
 NetworkInstance[] forceDetection()
          To be used to force detection to occur in synchronouse manner instead of being passive and waiting for detection messages to come in from remote detectors.
protected abstract  void forceHeartbeat()
          Used to force detection messages to be sent by remoting servers and consumed by detector and registered with network registry.
 org.w3c.dom.Element getConfiguration()
          The getConfiguration method
 long getDefaultTimeDelay()
           
protected  long getHeartbeatDelay()
          return the initial delay in milliseconds before the initial heartbeat is fired.
protected  long getHeartbeatPeriod()
          return the period in milliseconds between subsequent heartbeats.
 long getHeartbeatTimeDelay()
          The amount of time to wait between sending (and sometimes receiving) detection messages.
protected  long getPingerDelay()
          return the delay in milliseconds between when the timer is created to when the first pinger thread runs.
protected  long getPingerPeriod()
          return the period in milliseconds between checking lost servers against the last detection timestamp.
protected abstract  void heartbeat()
          subclasses must implement to provide the specific heartbeat protocol for this server to send out to other servers on the network
protected  boolean isRemoteDetection(Detection detection)
           
 void postDeregister()
           
 void postRegister(java.lang.Boolean aBoolean)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer mBeanServer, javax.management.ObjectName objectName)
           
 void setConfiguration(org.w3c.dom.Element xml)
          set the configuration for the domains to be recognized by detector
 void setDefaultTimeDelay(long defaultTimeDelay)
          The amount of time which can elapse without receiving a detection event before a server will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive.
 void setHeartbeatTimeDelay(long heartbeatTimeDelay)
          The amount of time to wait between sending (and sometimes receiving) detection messages.
 void start()
          called by MBeanServer to start the mbean lifecycle
protected  void startHeartbeat(long delay, long period)
          start heartbeating
protected  void startPinger(long delay, long period)
          start the pinger timer thread
 void stop()
          called by the MBeanServer to stop the mbean lifecycle
protected  void stopHeartbeat()
          stop heartbeating
protected  void stopPinger()
          stop the pinger timer thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.jboss.logging.Logger log

mbeanserver

protected javax.management.MBeanServer mbeanserver

objectName

protected javax.management.ObjectName objectName

registryObjectName

protected javax.management.ObjectName registryObjectName

networkRegistry

protected NetworkRegistryMBean networkRegistry
Constructor Detail

AbstractDetector

public AbstractDetector()

AbstractDetector

public AbstractDetector(java.util.Map config)
Method Detail

setHeartbeatTimeDelay

public void setHeartbeatTimeDelay(long heartbeatTimeDelay)
The amount of time to wait between sending (and sometimes receiving) detection messages.

Specified by:
setHeartbeatTimeDelay in interface AbstractDetectorMBean
Parameters:
heartbeatTimeDelay -
Throws:
java.lang.IllegalArgumentException

getHeartbeatTimeDelay

public long getHeartbeatTimeDelay()
The amount of time to wait between sending (and sometimes receiving) detection messages.

Specified by:
getHeartbeatTimeDelay in interface AbstractDetectorMBean
Returns:

setDefaultTimeDelay

public void setDefaultTimeDelay(long defaultTimeDelay)
The amount of time which can elapse without receiving a detection event before a server will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive.

Specified by:
setDefaultTimeDelay in interface AbstractDetectorMBean
Parameters:
defaultTimeDelay - time in milliseconds
Throws:
java.lang.IllegalArgumentException

getDefaultTimeDelay

public long getDefaultTimeDelay()
Specified by:
getDefaultTimeDelay in interface AbstractDetectorMBean
Returns:
The amount of time which can elapse without receiving a detection event before a server will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive.

createDetection

public Detection createDetection()
Will create a detection message based on the server invokers registered within the local InvokerRegistry. The detection message will contain the identity and array of server invoker metadata.

Returns:

start

public void start()
           throws java.lang.Exception
called by MBeanServer to start the mbean lifecycle

Specified by:
start in interface Detector
Throws:
java.lang.Exception

getPingerDelay

protected long getPingerDelay()
return the delay in milliseconds between when the timer is created to when the first pinger thread runs. defaults to 5000

Returns:

getPingerPeriod

protected long getPingerPeriod()
return the period in milliseconds between checking lost servers against the last detection timestamp. defaults to 1500

Returns:

startPinger

protected void startPinger(long delay,
                           long period)
start the pinger timer thread

Parameters:
delay -
period -

stopPinger

protected void stopPinger()
stop the pinger timer thread


stop

public void stop()
          throws java.lang.Exception
called by the MBeanServer to stop the mbean lifecycle

Specified by:
stop in interface Detector
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean aBoolean)
Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer mBeanServer,
                                               javax.management.ObjectName objectName)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

setConfiguration

public void setConfiguration(org.w3c.dom.Element xml)
                      throws java.lang.Exception
set the configuration for the domains to be recognized by detector

Specified by:
setConfiguration in interface AbstractDetectorMBean
Parameters:
xml -
Throws:
java.lang.Exception

getConfiguration

public org.w3c.dom.Element getConfiguration()
The getConfiguration method

Specified by:
getConfiguration in interface AbstractDetectorMBean
Returns:
an Element value

startHeartbeat

protected void startHeartbeat(long delay,
                              long period)
start heartbeating

Parameters:
delay -
period -

stopHeartbeat

protected void stopHeartbeat()
stop heartbeating


getHeartbeatDelay

protected long getHeartbeatDelay()
return the initial delay in milliseconds before the initial heartbeat is fired. Defaults to 0

Returns:

getHeartbeatPeriod

protected long getHeartbeatPeriod()
return the period in milliseconds between subsequent heartbeats. Defaults to 1000

Returns:

heartbeat

protected abstract void heartbeat()
subclasses must implement to provide the specific heartbeat protocol for this server to send out to other servers on the network


forceDetection

public NetworkInstance[] forceDetection()
To be used to force detection to occur in synchronouse manner instead of being passive and waiting for detection messages to come in from remote detectors. The servers returned should be the remote servers that are online at this point in time. Note, calling this method may take a few seconds to complete.

Returns:

forceHeartbeat

protected abstract void forceHeartbeat()
Used to force detection messages to be sent by remoting servers and consumed by detector and registered with network registry.


detect

protected void detect(Detection detection)
called when a remote detection from a peer is received by a detector

Parameters:
detection -

isRemoteDetection

protected boolean isRemoteDetection(Detection detection)

checkInvokerServer

protected boolean checkInvokerServer(Detection detection,
                                     java.lang.ClassLoader cl)


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.