Package org.jcsp.net.dynamic
Class InputReconnectionManagerCNSImpl
- java.lang.Object
-
- org.jcsp.net.dynamic.InputReconnectionManagerCNSImpl
-
- All Implemented Interfaces:
java.io.Serializable,InputReconnectionManager
class InputReconnectionManagerCNSImpl extends java.lang.Object implements InputReconnectionManager
Implementation of theInputReconnectionManagerto work with a CNS service for resolution of the channel's current location.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.StringanonymousCnsNamePrefixUnique prefix to use when registering channels with the CNS.private NetAltingChannelInputchanInThe underlying input channel end.(package private) java.lang.ClasschannelFactoryClassThe factory class used to create the channel end.private NetChannelLocationcnsNetChannelLocationCurrent location of the channel.private java.lang.StringcnsRegisteredNameName registered with the CNS.private NameAccessLevelcnsRegisteredNameAccessLevelNameAccessLevelused to register the name against with the CNS.private java.lang.StringcnsServiceNameToUseIdentification of the CNS service to use.private ChannelNameKeykeyThe name key allocated to the channel.private static intMSG_CHAN_NETWORKEDConstant for representing a possible channel state.private static intMSG_CHAN_SERIALIZABLEConstant for representing a possible channel state.private static intMSG_TERMINATEConstant for representing a possible channel state.private booleanserializableTrue if the channel end has been prepared for serialization (migration).
-
Constructor Summary
Constructors Constructor Description InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn)Constructs a newInputReconnectionManagerCNSImplfor use with the given input channel.InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String cnsServiceName)Constructs a newInputReconnectionManagerCNSImplfor use with the given input channel and a specific CNS service.InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String name, NameAccessLevel accessLevel, ChannelNameKey key)Constructs a newInputReconnectionManagerCNSImplfor use with CNS registered channels usingNameAccessLevelapplication isolation.InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String name, NameAccessLevel accessLevel, ChannelNameKey key, java.lang.String cnsServiceName)Constructs a newInputReconnectionManagerCNSImplfor use with CNS registered channels.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NetChannelLocationgetCurrentLocation()Returns the current location of the channel.NetAltingChannelInputgetInputChannel()Obtain theNetAltingChannelInputobject to use.voidprepareToMove()This method must be called before an instance of this class is serializable.private voidreadObject(java.io.ObjectInputStream in)Serialization method to read this object from a stream.private voidwriteObject(java.io.ObjectOutputStream out)Serialization method to write this object to a stream.
-
-
-
Field Detail
-
chanIn
private NetAltingChannelInput chanIn
The underlying input channel end.
-
channelFactoryClass
java.lang.Class channelFactoryClass
The factory class used to create the channel end.
-
cnsServiceNameToUse
private java.lang.String cnsServiceNameToUse
Identification of the CNS service to use.
-
cnsRegisteredName
private java.lang.String cnsRegisteredName
Name registered with the CNS.
-
cnsRegisteredNameAccessLevel
private NameAccessLevel cnsRegisteredNameAccessLevel
NameAccessLevelused to register the name against with the CNS.
-
key
private ChannelNameKey key
The name key allocated to the channel.
-
serializable
private transient boolean serializable
True if the channel end has been prepared for serialization (migration).
-
cnsNetChannelLocation
private transient NetChannelLocation cnsNetChannelLocation
Current location of the channel.
-
MSG_CHAN_SERIALIZABLE
private static final int MSG_CHAN_SERIALIZABLE
Constant for representing a possible channel state.- See Also:
- Constant Field Values
-
MSG_CHAN_NETWORKED
private static final int MSG_CHAN_NETWORKED
Constant for representing a possible channel state.- See Also:
- Constant Field Values
-
MSG_TERMINATE
private static final int MSG_TERMINATE
Constant for representing a possible channel state.- See Also:
- Constant Field Values
-
anonymousCnsNamePrefix
static final java.lang.String anonymousCnsNamePrefix
Unique prefix to use when registering channels with the CNS. It is assumed that only the reconnection managers will be using channels with names of this form.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InputReconnectionManagerCNSImpl
public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn)
Constructs a newInputReconnectionManagerCNSImplfor use with the given input channel. The default CNS service name will be used.- Parameters:
chanIn- the input channel end.
-
InputReconnectionManagerCNSImpl
public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String cnsServiceName)
Constructs a newInputReconnectionManagerCNSImplfor use with the given input channel and a specific CNS service.- Parameters:
chanIn- the input channel end.cnsServiceName- name of the CNS service to use.
-
InputReconnectionManagerCNSImpl
public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String name, NameAccessLevel accessLevel, ChannelNameKey key)
Constructs a newInputReconnectionManagerCNSImplfor use with CNS registered channels usingNameAccessLevelapplication isolation. The default CNS service name is used.- Parameters:
chanIn- the input channel end.name- the CNS registered name of the channel.accessLevel- the application isolation level.key- the allocated channel key.
-
InputReconnectionManagerCNSImpl
public InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String name, NameAccessLevel accessLevel, ChannelNameKey key, java.lang.String cnsServiceName)
Constructs a newInputReconnectionManagerCNSImplfor use with CNS registered channels.- Parameters:
chanIn- the input channel end.name- the CNS registered name of the channel.accessLevel- the application isolation level.key- the allocated channel key.cnsServiceName- name of the CNS service to use.
-
-
Method Detail
-
getInputChannel
public NetAltingChannelInput getInputChannel()
Obtain theNetAltingChannelInputobject to use. After serialization, the first call to this method will reconstruct the channel and register it with the CNS. If there is a problem while trying to construct a channel, aChannelEndContructionExceptionwill be thrown.- Specified by:
getInputChannelin interfaceInputReconnectionManager- See Also:
InputReconnectionManager.getInputChannel()
-
getCurrentLocation
public NetChannelLocation getCurrentLocation()
Returns the current location of the channel. This method can only be called aftergetInputChannel()has been called to resolve the channel being managed.- Specified by:
getCurrentLocationin interfaceInputReconnectionManager
-
prepareToMove
public void prepareToMove()
This method must be called before an instance of this class is serializable. If an instance is deserialized, it can be reserialized without calling this method ifgetInputChannel()has not been called.- Specified by:
prepareToMovein interfaceInputReconnectionManager- See Also:
InputReconnectionManager.prepareToMove()
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOExceptionSerialization method to write this object to a stream.- Parameters:
out- destination stream to serialize to.- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundExceptionSerialization method to read this object from a stream.- Parameters:
in- the source stream.- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-