public abstract class AbstractHeartBeat extends java.lang.Object implements HeartBeat, java.lang.Runnable
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractHeartBeat(ConnectionNotificationEmitter emitter,
java.util.Map environment)
Creates a new HeartBeat.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxRetries()
Returns the maximum number of retries this heart beat attempts after
a first connection failure before declaring the connection or the server
as dead.
|
long |
getPulsePeriod()
Returns the period of time in milliseconds between two heart beats
|
protected abstract void |
pulse()
Subclasses will implement this method using protocol specific connections.
|
void |
run() |
protected void |
sendConnectionNotificationFailed()
Sends the connection failed notification using the emitter specified in
AbstractHeartBeat(mx4j.remote.ConnectionNotificationEmitter, java.util.Map) |
void |
start()
Starts the heart beat
|
void |
stop()
Stops the heart beat
|
protected AbstractHeartBeat(ConnectionNotificationEmitter emitter, java.util.Map environment)
emitter - The NotificationEmitter that sends connection failures notifications.environment - The environment that may contain properties that specify heart beat's behaviorsendConnectionNotificationFailed(),
MX4JRemoteConstants.CONNECTION_HEARTBEAT_PERIOD,
MX4JRemoteConstants.CONNECTION_HEARTBEAT_RETRIESpublic long getPulsePeriod()
HeartBeatgetPulsePeriod in interface HeartBeatMX4JRemoteConstants.CONNECTION_HEARTBEAT_PERIOD,
HeartBeat.getMaxRetries()public int getMaxRetries()
HeartBeatgetMaxRetries in interface HeartBeatMX4JRemoteConstants.CONNECTION_HEARTBEAT_RETRIES,
HeartBeat.getPulsePeriod()protected abstract void pulse()
throws java.io.IOException
MBeanServerConnection.getDefaultDomain() is used
to "ping" the server side.java.io.IOExceptionpublic void start()
throws java.io.IOException
HeartBeatstart in interface HeartBeatjava.io.IOException - If there are problems contacting the serverHeartBeat.stop()public void stop()
throws java.io.IOException
HeartBeatstop in interface HeartBeatjava.io.IOException - If there are problems contacting the serverHeartBeat.start()public void run()
run in interface java.lang.Runnableprotected void sendConnectionNotificationFailed()
AbstractHeartBeat(mx4j.remote.ConnectionNotificationEmitter, java.util.Map)