Package org.jcsp.net.dynamic
Class OutputReconnectionManagerCNSImpl
- java.lang.Object
-
- org.jcsp.net.dynamic.OutputReconnectionManagerCNSImpl
-
- All Implemented Interfaces:
java.io.Serializable
,OutputReconnectionManager
class OutputReconnectionManagerCNSImpl extends java.lang.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 Summary
Fields Modifier and Type Field Description private NetChannelOutput
chanOut
Underlying networked channel output end.private java.lang.String
cnsServiceName
Name of the CNS service to use.private int
maxAttemptCount
Constant specifying the maximum number of retry attempts before aborting a write operation.private boolean
serializable
true
iff the object can be serialized and sent (migrated) to another node.
-
Constructor Summary
Constructors Constructor Description OutputReconnectionManagerCNSImpl(NetChannelOutput out)
Constructs a newOutputReconnectionManagerCNSImpl
with the given underlying networked channel output end.OutputReconnectionManagerCNSImpl(NetChannelOutput out, java.lang.String cnsServiceName)
Constructs a newOutputReconnectionManagerCNSImpl
with the given underlying networked channel output end using a specific CNS service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
dealWithWriteError(java.lang.Object value, java.lang.RuntimeException e)
Attempts to resolve the new channel location.NetChannelOutput
getOutputChannel()
Returns the underlying channel output end.void
prepareToMove()
Prepares the channel end for transfer to another node.private void
readObject(java.io.ObjectInputStream in)
Deserializes this object from an input stream.private void
writeObject(java.io.ObjectOutputStream out)
Serializes this object to the output stream.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
serializable
private transient boolean serializable
true
iff the object can be serialized and sent (migrated) to another node.
-
cnsServiceName
private java.lang.String cnsServiceName
Name of the CNS service to use.
-
-
Constructor Detail
-
OutputReconnectionManagerCNSImpl
public OutputReconnectionManagerCNSImpl(NetChannelOutput out)
Constructs a newOutputReconnectionManagerCNSImpl
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, java.lang.String cnsServiceName)
Constructs a newOutputReconnectionManagerCNSImpl
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 Detail
-
getOutputChannel
public NetChannelOutput getOutputChannel()
Description copied from interface:OutputReconnectionManager
Returns the underlying channel output end.- Specified by:
getOutputChannel
in interfaceOutputReconnectionManager
- See Also:
OutputReconnectionManager.getOutputChannel()
-
dealWithWriteError
private void dealWithWriteError(java.lang.Object value, java.lang.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 bymaxAttemptCount
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 interfaceOutputReconnectionManager
- See Also:
OutputReconnectionManager.prepareToMove()
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.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:
java.io.IOException
- if there is a problem with the output stream.
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
Deserializes this object from an input stream.- Parameters:
in
- input stream to read the object from.- Throws:
java.io.IOException
- if there is a problem with the input stream.java.lang.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.
-
-