Class OutputReconnectionManagerCNSImpl

java.lang.Object
org.jcsp.net.dynamic.OutputReconnectionManagerCNSImpl
All Implemented Interfaces:
Serializable, OutputReconnectionManager

class OutputReconnectionManagerCNSImpl extends Object implements OutputReconnectionManager
Implementation of the output reconnection manager that uses a CNS service to track channel ends. If this class is used for the output end, InputReconnectionManagerCNSImpl should be used at the input end.
  • Field Details

    • chanOut

      private transient NetChannelOutput chanOut
      Underlying networked channel output end.
    • maxAttemptCount

      private final int maxAttemptCount
      Constant specifying the maximum number of retry attempts before aborting a write operation.
      See Also:
    • serializable

      private transient boolean serializable
      true iff the object can be serialized and sent (migrated) to another node.
    • cnsServiceName

      private String cnsServiceName
      Name of the CNS service to use.
  • Constructor Details

    • OutputReconnectionManagerCNSImpl

      public OutputReconnectionManagerCNSImpl(NetChannelOutput out)
      Constructs a new OutputReconnectionManagerCNSImpl with the given underlying networked channel output end. The default CNS service name will be used.
      Parameters:
      out - underlying networked channel end.
    • OutputReconnectionManagerCNSImpl

      public OutputReconnectionManagerCNSImpl(NetChannelOutput out, String cnsServiceName)
      Constructs a new OutputReconnectionManagerCNSImpl with the given underlying networked channel output end using a specific CNS service.
      Parameters:
      out - the underlying networked channel end.
      cnsServiceName - name of the CNS service to use.
  • Method Details

    • getOutputChannel

      public NetChannelOutput getOutputChannel()
      Description copied from interface: OutputReconnectionManager
      Returns the underlying channel output end.
      Specified by:
      getOutputChannel in interface OutputReconnectionManager
      See Also:
    • dealWithWriteError

      private void dealWithWriteError(Object value, RuntimeException e)
      Attempts to resolve the new channel location. This method is called when a write error occurs because the destination is no longer valid. The CNS service is queried to find out where the other channel end moved to. A number of attempts to write to the new location are made. If these fail, the channel is recreated. If the number of retry attempts exceeds the limit set by maxAttemptCount the write is considered to have failed and the original exception is rethrown.
      Parameters:
      value - the data value that the user was trying to write and that should be written.
      e - the exception originally raised to be thrown if the channel cannot be reconnected.
    • prepareToMove

      public void prepareToMove()
      Description copied from interface: OutputReconnectionManager
      Prepares the channel end for transfer to another node.
      Specified by:
      prepareToMove in interface OutputReconnectionManager
      See Also:
    • writeObject

      private void writeObject(ObjectOutputStream out) throws IOException
      Serializes this object to the output stream. Before moving this channel end, prepareToMove should be called.
      Parameters:
      out - destination stream to serialize to.
      Throws:
      IOException - if there is a problem with the output stream.
    • readObject

      private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
      Deserializes this object from an input stream.
      Parameters:
      in - input stream to read the object from.
      Throws:
      IOException - if there is a problem with the input stream.
      ClassNotFoundException - if the class definition for the channel implementation cannot be found. This is only likely to occur if there are different versions of the infrastructure library on each node.