コード例 #1
0
        /**
         * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, with the given
         * poison immunity level and uses the given filter to encode outgoing messages
         *
         * @param nodeID
         *            The NodeID of the Node that the input channel resides on
         * @param vcn
         *            The Virtual Channel Number of the input channel
         * @param immunityLevel
         *            The immunity to poison that the channel has
         * @param filter
         *            The filter that encodes the outgoing messages
         * @return A new NetChannelOutput
         * @//throws JCSPNetworkException
         *             Thrown if something goes wrong with the underlying architecture
         */
        public NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel, NetworkMessageFilter.FilterTx filter)
        //throws JCSPNetworkException
        {
            NetChannelLocation loc = new NetChannelLocation(nodeID, vcn);

            return(One2NetChannel.create(loc, immunityLevel, filter));
        }
コード例 #2
0
        private NetAltingConnectionClient(AltingChannelInput input, ChannelOutput toLink, Link link,
                                          ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX,
                                          NetworkMessageFilter.FilterRx filterRX) : base(input)
        {
            this.toLinkTX       = toLink;
            this.In             = input;
            this.data           = connData;
            this.serverLocation = loc;
            this.localLocation  = new NetConnectionLocation(Node.getInstance().getNodeID(), connData.vconnn);
            this.outputFilter   = filterTX;
            this.inputFilter    = filterRX;

            if (link != null)
            {
                this.linkConnectedTo = link;
                // TODO: registration stuff

                this.isLocal         = false;
                this.localConnection = null;
            }
            else
            {
                this.isLocal         = true;
                this.localConnection = ConnectionManager.getInstance().getConnection(this.serverLocation.getVConnN());
                this.linkConnectedTo = null;
            }
        }
コード例 #3
0
        /**
         * Private constructor for creating a One2NetChannel. This is called by the create method.
         *
         * @param ackChannel
         *            The channel used to receive acknowledgements from Links
         * @param toLink
         *            The channel used to send messages to the input end
         * @param link
         *            The Link that this channel is connected to
         * @param chanData
         *            The structure used to store the state of the channel
         * @param loc
         *            The location of the input end that this channel is connected to
         * @param immunity
         *            The poison immunity level of the channel
         * @param filter
         *            Filter used to encode outgoing messages
         */
        private One2NetChannel(AltingChannelInput ackChannel, ChannelOutput toLink, Link link, ChannelData chanData,
                               NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter)
        {
            // Set all the object properties for the channel
            this.toLinkTx           = toLink;
            this.theAckChannel      = ackChannel;
            this.data               = chanData;
            this.remoteLocation     = loc;
            this.localLocation      = new NetChannelLocation(Node.getInstance().getNodeID(), chanData.vcn);
            this.data.immunityLevel = immunity;
            this.messageFilter      = filter;

            // We now must either register with the Link connecting us to the input end, or we connect directly to the
            // channel if it is local
            if (link != null)
            {
                // We are connected to a remote Node. Register with Link
                this.linkConnectedTo = link;
                this.linkConnectedTo.registerChannel(this.data);

                // Set the localised parameters accordingly
                this.isLocal      = false;
                this.localChannel = null;
            }
            else
            {
                // We are connected to an input end on this Node. Set the localised parameters
                this.isLocal = true;
                // Get hold of the local channel data structure
                this.localChannel = ChannelManager.getInstance().getChannel(this.remoteLocation.getVCN());

                // Set the Link connected to to null
                this.linkConnectedTo = null;
            }
        }
コード例 #4
0
/**
 * Sets the underlying message filter
 *
 * @param encoder
 *            The new message filter to use
 */
        public void setEncoder(NetworkMessageFilter.FilterTx encoder)
        {
            lock (this)
            {
                this.chan.setEncoder(encoder);
            }
        }
コード例 #5
0
        /**
         * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, which uses
         * the given filter to encode outgoing messages
         *
         * @param nodeID
         *            The NodeID of the Node to connect to
         * @param vcn
         *            The Virtual Channel Number of the input channel
         * @param filter
         *            The filter used to encode the outgoing messages
         * @return A new NetSharedChannelOutput
         * @//throws JCSPNetworkException
         *             Thrown if something goes wrong in the underlying architecture
         */
        public NetSharedChannelOutput any2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter)
        //throws JCSPNetworkException
        {
            NetChannelLocation loc = new NetChannelLocation(nodeID, vcn);

            return(Any2NetChannel.create(loc, Int32.MaxValue, filter));
        }
コード例 #6
0
        /**
         * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node which uses the
         * given filter to encode outgoing messages
         *
         * @param nodeAddr
         *            The NodeAddress of the Node to connect to
         * @param vcn
         *            The Virtual Channel Number of the input channel
         * @param filter
         *            The immunity to poison that the channel has
         * @return A new NetSharedChannelOutput
         * @//throws JCSPNetworkException
         *             Thrown if something goes wrong in the underlying architecture
         */
        public NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter)
        //throws JCSPNetworkException
        {
            NodeID             remoteNode = LinkFactory.getLink(nodeAddr).remoteID;
            NetChannelLocation loc        = new NetChannelLocation(remoteNode, vcn);

            return(Any2NetChannel.create(loc, Int32.MaxValue, filter));
        }
コード例 #7
0
        /**
         * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which has the given
         * poison immunity and uses the given filter to encode outgoing messages
         *
         * @param nodeAddr
         *            The NodeAddress of the Node to connect to
         * @param vcn
         *            The Virtual Channel Number of the input channel
         * @param immunityLevel
         *            The immunity to poison that the channel has
         * @param filter
         *            The filter used to encode outgoing messages
         * @return A new NetChannelOutput
         * @//throws JCSPNetworkException
         *             Thrown if something goes wrong in the underlying architecture
         */
        public NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, int immunityLevel,
                                        NetworkMessageFilter.FilterTx filter)
        //throws JCSPNetworkException
        {
            NodeID             remoteNode = LinkFactory.getLink(nodeAddr).remoteID;
            NetChannelLocation loc        = new NetChannelLocation(remoteNode, vcn);

            return(One2NetChannel.create(loc, immunityLevel, filter));
        }
コード例 #8
0
 private NetAltingConnectionServer(AltingChannelInput openChan, AltingChannelInput requestChan,
                                   ConnectionData connData, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) : base(openChan)
     ////throws JCSPNetworkException
 {
     this.openIn       = openChan;
     this.requestIn    = requestChan;
     this.data         = connData;
     this.inputFilter  = filterRX;
     this.outputFilter = filterTX;
     this.location     = new NetConnectionLocation(Node.getInstance().getNodeID(), this.data.vconnn);
 }
コード例 #9
0
        static NetAltingConnectionServer create(NetworkMessageFilter.FilterRx filterRX,
                                                NetworkMessageFilter.FilterTx filterTX)
        {
            ConnectionData data        = new ConnectionData();
            Any2OneChannel requestChan = Channel.any2one(new InfiniteBuffer());
            Any2OneChannel openChan    = Channel.any2one(new InfiniteBuffer());

            data.toConnection = requestChan.Out();
            data.openServer   = openChan.Out();
            data.state        = ConnectionDataState.SERVER_STATE_CLOSED;
            ConnectionManager.getInstance().create(data);
            return(new NetAltingConnectionServer(openChan.In(), requestChan.In(), data, filterRX, filterTX));
        }
コード例 #10
0
        /**
         * Static factory method used to create an Any2NetChannel
         *
         * @param loc
         *            The location of the input channel end
         * @param immunity
         *            The immunity level of the channel
         * @param filter
         *            The filter used to convert the object being sent into bytes
         * @return A new Any2NetChannel connected to the input end.
         * @//throws JCSPNetworkException
         *             Thrown if a connection to the Node cannot be made.
         */
        internal static Any2NetChannel create(NetChannelLocation loc, int immunity, NetworkMessageFilter.FilterTx filter)
        {
            One2NetChannel channel = null;

            try
            {
                channel = One2NetChannel.create(loc, immunity, filter);
            }
            catch (JCSPNetworkException e)
            {
                Console.WriteLine(e);
            }
            return(new Any2NetChannel(channel));
        }
コード例 #11
0
        /**
         * Creates a new One2NetChannel by connecting to an already created NetChannelInput
         *
         * @param loc
         *            The location of the NetChannelInput
         * @param immunity
         *            The immunity level of the channel
         * @param filter
         *            The filter used to encode outgoing messages
         * @return A new One2NetChannel
         * @//throws JCSPNetworkException
         *             Thrown if the connection to the remote Node fails
         */
        internal static One2NetChannel create(NetChannelLocation loc, int immunity,
                                              NetworkMessageFilter.FilterTx filter)
        ////throws JCSPNetworkException
        {
            // Create the channel data structure
            ChannelData data = new ChannelData();

            // Create the channel linking this to the Link level. This channel is the one used to receive acknowledgement
            // messages
            One2OneChannel chan = Channel.one2one(new InfiniteBuffer());

            data.toChannel = chan.Out();

            // Set state of channel
            data.state = ChannelDataState.OK_OUTPUT;

            // Register channel
            ChannelManager.getInstance().create(data);

            // We now need to create the connection to the input end of the channel
            ChannelOutput toLink;

            // Check if this is a local link, and if so connect directly to the input channel
            if (loc.getNodeID().equals(Node.getInstance().getNodeID()))
            {
                toLink = ChannelManager.getInstance().getChannel(loc.getVCN()).toChannel;
                return(new One2NetChannel(chan.In(), toLink, null, data, loc, immunity, filter));
            }

            // Connect to remote node if necessary
            Link link = LinkManager.getInstance().requestLink(loc.getNodeID());

            // Check if an existing connection exists
            if (link == null)
            {
                // We are not connected. Connect to remote Node.
                link = LinkFactory.getLink(loc.getNodeID());
            }

            // Get the connection to the Link.
            toLink = link.getTxChannel();

            // Return new channel
            return(new One2NetChannel(chan.In(), toLink, link, data, loc, immunity, filter));
        }
コード例 #12
0
        static NetAltingConnectionClient create(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX)
        ////throws JCSPNetworkException
        {
            // Create the connection data structure
            ConnectionData data = new ConnectionData();

            // Create channel linking this to the Link level. This channel is used to receive response and
            // acknowledgement messages
            Any2OneChannel chan = Channel.any2one(new InfiniteBuffer());

            data.toConnection = chan.Out();

            // Set state of connection
            data.state = ConnectionDataState.CLIENT_STATE_CLOSED;

            ConnectionManager.getInstance().create(data);

            ChannelOutput toLink;

            if (loc.getNodeID().equals(Node.getInstance().getNodeID()))
            {
                toLink = ConnectionManager.getInstance().getConnection(loc.getVConnN()).toConnection;
                return(new NetAltingConnectionClient(chan.In(), toLink, null, data, loc, filterTX, filterRX));
            }

            Link link = LinkManager.getInstance().requestLink(loc.getNodeID());

            if (link == null)
            {
                link = LinkFactory.getLink(loc.getNodeID());
            }

            toLink = link.getTxChannel();

            return(new NetAltingConnectionClient(chan.In(), toLink, link, data, loc, filterTX, filterRX));
        }
コード例 #13
0
/**
 * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node which uses the given
 * filter to encode outgoing messages
 *
 * @param nodeAddr
 *            The NodeAddress of the Node to connect to
 * @param vcn
 *            The Virtual Channel Number of the input channel
 * @param filter
 *            The filter used to encode outgoing messages
 * @return A new NetChannelOutput
 * @//throws JCSPNetworkException
 *             Thrown if something goes wrong in the underlying architecture
 */
        public static NetChannelOutput one2net(NodeAddress nodeAddr, int vcn, NetworkMessageFilter.FilterTx filter)
//throws JCSPNetworkException
        {
            return(factory.one2net(nodeAddr, vcn, filter));
        }
コード例 #14
0
/**
 * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node that has the
 * given poison immunity level and uses the given filter to encode outgoing messages
 *
 * @param nodeAddr
 *            The NodeAddress of the Node to connect to
 * @param vcn
 *            The Virtual Channel Number of the input channel
 * @param immunityLevel
 *            The immunity to poison that the channel has
 * @param filter
 *            The filter used to encode outgoing messages
 * @return A new NetSharedChannelOutput
 * @//throws JCSPNetworkException
 *             Thrown if something goes wrong in the underlying architecture
 */
        public static NetSharedChannelOutput any2net(NodeAddress nodeAddr, int vcn, int immunityLevel,
                                                     NetworkMessageFilter.FilterTx filter)
//throws JCSPNetworkException
        {
            return(factory.any2net(nodeAddr, vcn, immunityLevel, filter));
        }
コード例 #15
0
/**
 * Creates a new NetChannelOutput connected to the channel with the given vcn on the given Node, with the given
 * poison immunity level and uses the given filter to encode outgoing messages
 *
 * @param nodeID
 *            The NodeID of the Node that the input channel resides on
 * @param vcn
 *            The Virtual Channel Number of the input channel
 * @param immunityLevel
 *            The immunity to poison that the channel has
 * @param filter
 *            The filter that encodes the outgoing messages
 * @return A new NetChannelOutput
 * @//throws JCSPNetworkException
 *             Thrown if something goes wrong with the underlying architecture
 */
        public static NetChannelOutput one2net(NodeID nodeID, int vcn, int immunityLevel,
                                               NetworkMessageFilter.FilterTx filter)
//throws JCSPNetworkException
        {
            return(factory.one2net(nodeID, vcn, immunityLevel, filter));
        }
コード例 #16
0
/**
 * Creates a new NetSharedChannelOutput connected to the channel with the given vcn on the given Node, which uses
 * the given filter to encode outgoing messages
 *
 * @param nodeID
 *            The NodeID of the Node to connect to
 * @param vcn
 *            The Virtual Channel Number of the input channel
 * @param filter
 *            The filter used to encode the outgoing messages
 * @return A new NetSharedChannelOutput
 * @//throws JCSPNetworkException
 *             Thrown if something goes wrong in the underlying architecture
 */
        public static NetSharedChannelOutput any2net(NodeID nodeID, int vcn, NetworkMessageFilter.FilterTx filter)
//throws JCSPNetworkException
        {
            return(factory.any2net(nodeID, vcn, filter));
        }
コード例 #17
0
/**
 * Creates a new NetSharedChannelOutput connected to the input end with the given location and with the given
 * immunity level, which uses the given filter to encode outgoing messages.
 *
 * @param loc
 *            The location of the input end of the channel
 * @param immunityLevel
 *            The immunity to poison that this channel has
 * @param filter
 *            The filter used to encode outgoing messages
 * @return A new NetSharedChannelOutput
 * @//throws JCSPNetworkException
 *             Thrown if something goes wrong in the underlying architecture
 */
        public static NetSharedChannelOutput any2net(NetChannelLocation loc, int immunityLevel,
                                                     NetworkMessageFilter.FilterTx filter)
//throws JCSPNetworkException
        {
            return(factory.any2net(loc, immunityLevel, filter));
        }
コード例 #18
0
/**
 * Creates a new NetChannelOutput connected to the input end with the given NetChannelLocation, and uses the given
 * filter to encode outgoing messages
 *
 * @param loc
 *            The location of the input end of the channel
 * @param filter
 *            The filter used to encode outgoing messages
 * @return A new NetChannelOutput
 * @//throws JCSPNetworkException
 *             Thrown if something goes wrong in the underlying architecture
 */
        public static NetChannelOutput one2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter)
//throws JCSPNetworkException
        {
            return(factory.one2net(loc, filter));
        }
コード例 #19
0
 /**
  * Sets the underlying message filter
  *
  * @param encoder
  *            The new message filter to use
  */
 public void setEncoder(NetworkMessageFilter.FilterTx encoder)
 {
     this.messageFilter = encoder;
 }
コード例 #20
0
 /**
  * Creates a new NetChannelOutput connected to the given location with the given poison immunity level, and uses the
  * given filter to encode outgoing messages.
  *
  * @param loc
  *            The location of the input end of the channel
  * @param immunityLevel
  *            The immunity to poison that this channel has
  * @param filter
  *            The filter used to encode outgoing messages
  * @return A new NetChannelOutput
  * @//throws JCSPNetworkException
  *             Thrown if something goes wrong in the underlying architecture
  */
 public NetChannelOutput one2net(NetChannelLocation loc, int immunityLevel, NetworkMessageFilter.FilterTx filter)
 //throws JCSPNetworkException
 {
     return(One2NetChannel.create(loc, immunityLevel, filter));
 }
コード例 #21
0
 /**
  * Creates a new NetSharedChannelOutput connected to the input end with the given location, and uses the given
  * filter to encode outgoing messages
  *
  * @param loc
  *            The location of the input end of the channel
  * @param filter
  *            The filter used to encode outgoing messages
  * @return A new NetSharedChannelOutput
  * @//throws JCSPNetworkException
  *             Thrown if something goes wrong in the underlying architecture
  */
 public NetSharedChannelOutput any2net(NetChannelLocation loc, NetworkMessageFilter.FilterTx filter)
 //throws JCSPNetworkException
 {
     return(Any2NetChannel.create(loc, Int32.MaxValue, filter));
 }