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_RETRIES
public long getPulsePeriod()
HeartBeat
getPulsePeriod
in interface HeartBeat
MX4JRemoteConstants.CONNECTION_HEARTBEAT_PERIOD
,
HeartBeat.getMaxRetries()
public int getMaxRetries()
HeartBeat
getMaxRetries
in interface HeartBeat
MX4JRemoteConstants.CONNECTION_HEARTBEAT_RETRIES
,
HeartBeat.getPulsePeriod()
protected abstract void pulse() throws java.io.IOException
MBeanServerConnection.getDefaultDomain()
is used
to "ping" the server side.java.io.IOException
public void start() throws java.io.IOException
HeartBeat
start
in interface HeartBeat
java.io.IOException
- If there are problems contacting the serverHeartBeat.stop()
public void stop() throws java.io.IOException
HeartBeat
stop
in interface HeartBeat
java.io.IOException
- If there are problems contacting the serverHeartBeat.start()
public void run()
run
in interface java.lang.Runnable
protected void sendConnectionNotificationFailed()
AbstractHeartBeat(mx4j.remote.ConnectionNotificationEmitter, java.util.Map)