org.jppf.comm.recovery
Class AbstractRecoveryConnection

java.lang.Object
  extended by org.jppf.utils.ThreadSynchronization
      extended by org.jppf.comm.recovery.AbstractRecoveryConnection
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ClientConnection, ServerConnection

public abstract class AbstractRecoveryConnection
extends ThreadSynchronization
implements Runnable

Common abstract super class for a connection dedicated to receovery from hardware fialure of a remote peer.

Author:
Laurent Cohen

Field Summary
protected  boolean initialized
          Determines whether the initial handshake has been performed.
protected  int maxRetries
          Maximum number of failed write/read attempts on a connection before the remote peer is considered dead.
protected  boolean ok
          Determines whether this connection is ok after is has been checked.
protected  int socketReadTimeout
          Maximum wait time on a response from the remote peer.
protected  SocketWrapper socketWrapper
          Connection to a client.
protected  String uuid
          The JPPF node or client uuid.
 
Fields inherited from class org.jppf.utils.ThreadSynchronization
stopped
 
Constructor Summary
AbstractRecoveryConnection()
           
 
Method Summary
abstract  void close()
          Close this client and release any resources it is using.
 String getUuid()
          Get the uuid of the remote peer.
 boolean isInitialized()
          Determine whether the initial handshake has been performed.
 boolean isOk()
          Determine whether this connection is ok after is has been checked.
protected  String receiveMessage()
          Read a message form the remote peer.
protected  String receiveMessage(int maxRetries, int socketReadTimeout)
          Read a message from the remote peer.
 void sendMessage(String message)
          Send a message to the remote peer.
 void setInitialized(boolean initialized)
          Specify whether the initial handshake has been performed.
 void setOk(boolean ok)
          Specifiy whether this connection is ok after is has been checked.
 
Methods inherited from class org.jppf.utils.ThreadSynchronization
goToSleep, goToSleep, goToSleep, isStopped, setStopped, wakeUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

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.

Constructor Detail

AbstractRecoveryConnection

public AbstractRecoveryConnection()
Method Detail

receiveMessage

protected String 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 String 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 rmeote peer.
socketReadTimeout - timeout for each attempt.
Returns:
the message that was received.
Throws:
Exception - if any error occurs.

sendMessage

public void sendMessage(String 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)
Specifiy 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.


Copyright © 2005-2010 JPPF Team.