Class AbstractHeartbeatConnection

java.lang.Object
org.jppf.utils.concurrent.ThreadSynchronization
org.jppf.comm.recovery.AbstractHeartbeatConnection
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
HeartbeatConnection

public abstract class AbstractHeartbeatConnection extends ThreadSynchronization implements Runnable
Common abstract super class for a connection dedicated to recovery from hardware failure of a remote peer.
Author:
Laurent Cohen
  • Field Details

    • socketWrapper

      protected SocketWrapper socketWrapper
      Connection to a client.
    • maxRetries

      protected int maxRetries
      Maximum number of failed write/read attempts on a connection before the remote peer is considered dead.
    • socketReadTimeout

      protected int socketReadTimeout
      Maximum wait time on a response from the remote peer.
    • uuid

      protected String uuid
      The JPPF node or client uuid.
    • ok

      protected boolean ok
      Determines whether this connection is ok after is has been checked.
    • initialized

      protected boolean initialized
      Determines whether the initial handshake has been performed.
    • runThread

      protected Thread runThread
  • Constructor Details

    • AbstractHeartbeatConnection

      public AbstractHeartbeatConnection()
  • Method Details

    • receiveMessage

      protected HeartbeatMessage receiveMessage() throws Exception
      Read a message form the remote peer. While receiving the message, this method also waits for socketReadTimeout specified in the configuration. If the timeout expires maxRetries times in a row, the connection is also considered broken.
      Returns:
      the message that was received.
      Throws:
      Exception - if any error occurs.
    • receiveMessage

      protected HeartbeatMessage receiveMessage(int maxRetries, int socketReadTimeout) throws Exception
      Read a message from the remote peer. While receiving the message, this method also waits for socketReadTimeout specified in the configuration. If the timeout expires maxRetries times 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

      public void sendMessage(HeartbeatMessage message) throws Exception
      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

      public String 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:
      true if the initial handshake was done, false otherwise.
    • setInitialized

      public void setInitialized(boolean initialized)
      Specify whether the initial handshake has been performed.
      Parameters:
      initialized - true if the initial handshake was done, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSocketWrapper

      public SocketWrapper getSocketWrapper()
      Get the object wrapping the connection.
      Returns:
      a SocketWrapper object.