Package org.jcsp.net.dynamic
Class OutputReconnectionManagerCNSImpl
java.lang.Object
org.jcsp.net.dynamic.OutputReconnectionManagerCNSImpl
- All Implemented Interfaces:
Serializable,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
FieldsModifier and TypeFieldDescriptionprivate NetChannelOutputUnderlying networked channel output end.private StringName of the CNS service to use.private final intConstant specifying the maximum number of retry attempts before aborting a write operation.private booleantrueiff the object can be serialized and sent (migrated) to another node. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newOutputReconnectionManagerCNSImplwith the given underlying networked channel output end.OutputReconnectionManagerCNSImpl(NetChannelOutput out, String cnsServiceName) Constructs a newOutputReconnectionManagerCNSImplwith the given underlying networked channel output end using a specific CNS service. -
Method Summary
Modifier and TypeMethodDescriptionprivate voiddealWithWriteError(Object value, RuntimeException e) Attempts to resolve the new channel location.Returns the underlying channel output end.voidPrepares the channel end for transfer to another node.private voidDeserializes this object from an input stream.private voidSerializes this object to the output stream.
-
Field Details
-
chanOut
Underlying networked channel output end. -
maxAttemptCount
private final int maxAttemptCountConstant specifying the maximum number of retry attempts before aborting a write operation.- See Also:
-
serializable
private transient boolean serializabletrueiff the object can be serialized and sent (migrated) to another node. -
cnsServiceName
Name of the CNS service to use.
-
-
Constructor Details
-
OutputReconnectionManagerCNSImpl
Constructs a newOutputReconnectionManagerCNSImplwith the given underlying networked channel output end. The default CNS service name will be used.- Parameters:
out- underlying networked channel end.
-
OutputReconnectionManagerCNSImpl
Constructs a newOutputReconnectionManagerCNSImplwith 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
Description copied from interface:OutputReconnectionManagerReturns the underlying channel output end.- Specified by:
getOutputChannelin interfaceOutputReconnectionManager- See Also:
-
dealWithWriteError
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 bymaxAttemptCountthe 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:OutputReconnectionManagerPrepares the channel end for transfer to another node.- Specified by:
prepareToMovein interfaceOutputReconnectionManager- See Also:
-
writeObject
Serializes this object to the output stream. Before moving this channel end,prepareToMoveshould be called.- Parameters:
out- destination stream to serialize to.- Throws:
IOException- if there is a problem with the output stream.
-
readObject
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.
-