Exemplo n.º 1
0
        /**
         * Sends a StatusMessage request (local node) to the nearest right and
         * left neighbors (in the local node's ConnectionTable) of the new Connection.
         */
        protected void UpdateNeighborStatus(object contab, EventArgs args)
        {
            ConnectionEventArgs cea = (ConnectionEventArgs)args;

            if (cea.ConnectionType != ConnectionType.Structured)
            {
                //We don't do anything,
                return;
            }

            //This is the list we had when things changed
            ConnectionList structs = cea.CList;

            //structs is constant
            if (structs.Count == 0)
            {
                //There is no one to talk to
                return;
            }

            /*
             * Get the data we need about this connection:
             */
            Connection con         = cea.Connection;
            AHAddress  new_address = (AHAddress)con.Address;

            /*
             * Update the left neighbor:
             */
            Connection lc = structs.GetLeftNeighborOf(new_address);

            EnqueueAction(new UpdateNeighborAction(this, con.ConType, lc));

            /*
             * Update the right neighbor:
             */
            Connection rc = structs.GetRightNeighborOf(new_address);

            if (lc != rc)
            {
                EnqueueAction(new UpdateNeighborAction(this, con.ConType, rc));
            }
        }
Exemplo n.º 2
0
        /**
         * Sends a StatusMessage request (local node) to the nearest right and
         * left neighbors (in the local node's ConnectionTable) of the new Connection.
         */
        protected void UpdateNeighborStatus(object contab, EventArgs args)
        {
            ConnectionEventArgs cea = (ConnectionEventArgs)args;

            if (cea.ConnectionType != ConnectionType.Structured)
            {
                //We don't do anything,
                return;
            }

            //This is the list we had when things changed
            ConnectionList structs = cea.CList;

            //structs is constant
            if (structs.Count == 0)
            {
                //There is no one to talk to
                return;
            }

            /*
             * Get the data we need about this connection:
             */
            Connection con             = cea.Connection;
            string     con_type_string = con.ConType;
            AHAddress  new_address     = (AHAddress)con.Address;

            /*
             * Update the left neighbor:
             */
            Connection lc = structs.GetLeftNeighborOf(new_address);

            try {
                //This edge could ahve been closed, which will
                //cause the Rpc to throw an exception
                CallGetStatus(con_type_string, lc);
            }
            catch (EdgeClosedException) {
                //Just ignore this connection if it is closed
            }
            catch (EdgeException ex) {
                if (!ex.IsTransient)
                {
                    //Make sure this Edge is closed before going forward
                    lc.Edge.Close();
                }
            }
            catch (Exception x) {
                if (ProtocolLog.Exceptions.Enabled)
                {
                    ProtocolLog.Write(ProtocolLog.Exceptions, String.Format(
                                          "CallGetStatus(left) on {0} failed: {1}", lc, x));
                }
            }

            /*
             * Update the right neighbor:
             */
            Connection rc = structs.GetRightNeighborOf(new_address);

            try {
                if ((lc != rc))
                {
                    //This edge could ahve been closed, which will
                    //cause the Rpc to throw an exception
                    CallGetStatus(con_type_string, rc);
                }
            }
            catch (EdgeClosedException) {
                //Just ignore this connection if it is closed
            }
            catch (EdgeException ex) {
                if (!ex.IsTransient)
                {
                    //Make sure this Edge is closed before going forward
                    rc.Edge.Close();
                }
            }
            catch (Exception x) {
                if (ProtocolLog.Exceptions.Enabled)
                {
                    ProtocolLog.Write(ProtocolLog.Exceptions, String.Format(
                                          "CallGetStatus(right) on {0} failed: {1}", rc, x));
                }
            }
        }