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 theInputReconnectionManager
to 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.String
anonymousCnsNamePrefix
Unique prefix to use when registering channels with the CNS.private NetAltingChannelInput
chanIn
The underlying input channel end.(package private) java.lang.Class
channelFactoryClass
The factory class used to create the channel end.private NetChannelLocation
cnsNetChannelLocation
Current location of the channel.private java.lang.String
cnsRegisteredName
Name registered with the CNS.private NameAccessLevel
cnsRegisteredNameAccessLevel
NameAccessLevel
used to register the name against with the CNS.private java.lang.String
cnsServiceNameToUse
Identification of the CNS service to use.private ChannelNameKey
key
The name key allocated to the channel.private static int
MSG_CHAN_NETWORKED
Constant for representing a possible channel state.private static int
MSG_CHAN_SERIALIZABLE
Constant for representing a possible channel state.private static int
MSG_TERMINATE
Constant for representing a possible channel state.private boolean
serializable
True if the channel end has been prepared for serialization (migration).
-
Constructor Summary
Constructors Constructor Description InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn)
Constructs a newInputReconnectionManagerCNSImpl
for use with the given input channel.InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String cnsServiceName)
Constructs a newInputReconnectionManagerCNSImpl
for use with the given input channel and a specific CNS service.InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String name, NameAccessLevel accessLevel, ChannelNameKey key)
Constructs a newInputReconnectionManagerCNSImpl
for use with CNS registered channels usingNameAccessLevel
application isolation.InputReconnectionManagerCNSImpl(NetAltingChannelInput chanIn, java.lang.String name, NameAccessLevel accessLevel, ChannelNameKey key, java.lang.String cnsServiceName)
Constructs a newInputReconnectionManagerCNSImpl
for use with CNS registered channels.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NetChannelLocation
getCurrentLocation()
Returns the current location of the channel.NetAltingChannelInput
getInputChannel()
Obtain theNetAltingChannelInput
object to use.void
prepareToMove()
This method must be called before an instance of this class is serializable.private void
readObject(java.io.ObjectInputStream in)
Serialization method to read this object from a stream.private void
writeObject(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
NameAccessLevel
used 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 newInputReconnectionManagerCNSImpl
for 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 newInputReconnectionManagerCNSImpl
for 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 newInputReconnectionManagerCNSImpl
for use with CNS registered channels usingNameAccessLevel
application 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 newInputReconnectionManagerCNSImpl
for 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 theNetAltingChannelInput
object 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, aChannelEndContructionException
will be thrown.- Specified by:
getInputChannel
in 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:
getCurrentLocation
in 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:
prepareToMove
in interfaceInputReconnectionManager
- See Also:
InputReconnectionManager.prepareToMove()
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
Serialization 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.ClassNotFoundException
Serialization method to read this object from a stream.- Parameters:
in
- the source stream.- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-