Package org.jppf.comm.recovery
Class AbstractHeartbeatConnection
java.lang.Object
org.jppf.utils.concurrent.ThreadSynchronization
org.jppf.comm.recovery.AbstractHeartbeatConnection
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
HeartbeatConnection
Common abstract super class for a connection dedicated to recovery from hardware failure of a remote peer.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanDetermines whether the initial handshake has been performed.protected intMaximum number of failed write/read attempts on a connection before the remote peer is considered dead.protected booleanDetermines whether this connection is ok after is has been checked.protected Threadprotected intMaximum wait time on a response from the remote peer.protected SocketWrapperConnection to a client.protected StringThe JPPF node or client uuid.Fields inherited from class org.jppf.utils.concurrent.ThreadSynchronization
stopped -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Close this client and release any resources it is using.Get the object wrapping the connection.getUuid()Get the uuid of the remote peer.booleanDetermine whether the initial handshake has been performed.booleanisOk()Determine whether this connection is ok after is has been checked.protected HeartbeatMessageRead a message form the remote peer.protected HeartbeatMessagereceiveMessage(int maxRetries, int socketReadTimeout) Read a message from the remote peer.voidsendMessage(HeartbeatMessage message) Send a message to the remote peer.voidsetInitialized(boolean initialized) Specify whether the initial handshake has been performed.voidsetOk(boolean ok) Specify whether this connection is ok after is has been checked.toString()Methods inherited from class org.jppf.utils.concurrent.ThreadSynchronization
goToSleep, goToSleep, goToSleep, isStopped, setStopped, wakeUp
-
Field Details
-
socketWrapper
Connection to a client. -
maxRetries
protected int maxRetriesMaximum number of failed write/read attempts on a connection before the remote peer is considered dead. -
socketReadTimeout
protected int socketReadTimeoutMaximum wait time on a response from the remote peer. -
uuid
The JPPF node or client uuid. -
ok
protected boolean okDetermines whether this connection is ok after is has been checked. -
initialized
protected boolean initializedDetermines whether the initial handshake has been performed. -
runThread
-
-
Constructor Details
-
AbstractHeartbeatConnection
public AbstractHeartbeatConnection()
-
-
Method Details
-
receiveMessage
Read a message form the remote peer. While receiving the message, this method also waits forsocketReadTimeoutspecified in the configuration. If the timeout expiresmaxRetriestimes in a row, the connection is also considered broken.- Returns:
- the message that was received.
- Throws:
Exception- if any error occurs.
-
receiveMessage
Read a message from the remote peer. While receiving the message, this method also waits forsocketReadTimeoutspecified in the configuration. If the timeout expiresmaxRetriestimes in a row, the connection is also considered broken.- Parameters:
maxRetries- maximum number of attempts to read a response form the remote peer.socketReadTimeout- timeout for each attempt.- Returns:
- the message that was received.
- Throws:
Exception- if any error occurs.
-
sendMessage
Send a message to the remote peer.- Parameters:
message- the message to send.- Throws:
Exception- if any error occurs while sending the message.
-
close
public abstract void close()Close this client and release any resources it is using. -
getUuid
Get the uuid of the remote peer.- Returns:
- the uuid as a string.
-
isOk
public boolean isOk()Determine whether this connection is ok after is has been checked.- Returns:
- true if the connection is ok, false otherwise.
-
setOk
public void setOk(boolean ok) Specify whether this connection is ok after is has been checked.- Parameters:
ok- true if the connection is ok, false otherwise.
-
isInitialized
public boolean isInitialized()Determine whether the initial handshake has been performed.- Returns:
trueif the initial handshake was done,falseotherwise.
-
setInitialized
public void setInitialized(boolean initialized) Specify whether the initial handshake has been performed.- Parameters:
initialized-trueif the initial handshake was done,falseotherwise.
-
toString
-
getSocketWrapper
Get the object wrapping the connection.- Returns:
- a
SocketWrapperobject.
-