ToDictionary() 공개 메소드

public ToDictionary ( ) : IDictionary
리턴 IDictionary
예제 #1
0
 public void RoundTripHT(StatusMessage sm) {
  StatusMessage sm2 = new StatusMessage( sm.ToDictionary() );
  Assert.AreEqual(sm, sm2, "Hashtable RT");
 }
예제 #2
0
        public void RoundTripHT(StatusMessage sm)
        {
            StatusMessage sm2 = new StatusMessage(sm.ToDictionary());

            Assert.AreEqual(sm, sm2, "Hashtable RT");
        }
예제 #3
0
        /**
         * When we get a response to the sys:link method, this handled
         * is called
         */
        protected void LinkCloseHandler(object q, EventArgs args)
        {
            try {
                Channel resq = (Channel)q;
                //If the Channel is empty this will throw an exception:
                RpcResult res = (RpcResult)resq.Dequeue();
                /* Here's the LinkMessage response */
                LinkMessage lm = new LinkMessage((IDictionary)res.Result);

                /**
                 * This will set our LinkMessageReply variable.  It can
                 * only be set once, so all future sets will fail.  It
                 * will also make sure we have the lock on the target.
                 * If we don't, that will throw an exception
                 */
                SetAndCheckLinkReply(lm);
                //If we got here, we have our response and the Lock on _target_address
                StatusMessage sm = _node.GetStatus(_contype, lm.Local.Address);
                /* Make the call */
                Channel results = new Channel();
                results.CloseAfterEnqueue();
                results.CloseEvent += this.StatusCloseHandler;
                RpcManager rpc = _node.Rpc;
                if (ProtocolLog.LinkDebug.Enabled)
                {
                    ProtocolLog.Write(ProtocolLog.LinkDebug,
                                      String.Format(
                                          "LPS target: {0} Invoking GetStatus() over edge: {1}",
                                          _linker.Target, _e));
                }

                /*
                 * This could throw an exception if the Edge is closed
                 */
                rpc.Invoke(_e, results, "sys:link.GetStatus", sm.ToDictionary());
            }
            catch (AdrException x) {
                /*
                 * This happens when the RPC call has some kind of issue,
                 * first we check for common error conditions:
                 */
                _x.Value = x;
                Finish(GetResultForErrorCode(x.Code));
            }
            catch (ConnectionExistsException x) {
                /* We already have a connection */
                _x.Value = x;
                Finish(Result.ProtocolError);
            }
            catch (CTLockException x) {
                //This is thrown when ConnectionTable cannot lock.  Lets try again:
                _x.Value = x;
                Finish(Result.RetryThisTA);
            }
            catch (LinkException x) {
                _x.Value = x;
                if (x.IsCritical)
                {
                    Finish(Result.MoveToNextTA);
                }
                else
                {
                    Finish(Result.RetryThisTA);
                }
            }
            catch (InvalidOperationException) {
                //The queue never got anything
                Finish(Result.MoveToNextTA);
            }
            catch (EdgeException) {
                //The Edge is goofy, let's move on:
                Finish(Result.MoveToNextTA);
            }
            catch (Exception x) {
                //The protocol was not followed correctly by the other node, fail
                _x.Value = x;
                Finish(Result.RetryThisTA);
            }
        }
예제 #4
0
        /**
         * Get a StatusMessage for this node
         */
        public IDictionary GetStatus(IDictionary status_message, ISender edge)
        {
            //we just got s status request
            if (1 == _disconnecting)
            {
                throw new AdrException((int)ErrorMessage.ErrorCode.Disconnecting, "disconnecting");
            }

            StatusMessage sm   = new StatusMessage(status_message);
            Edge          from = GetEdge(edge);

            if (ProtocolLog.LinkDebug.Enabled)
            {
                ProtocolLog.Write(ProtocolLog.LinkDebug, String.Format(
                                      "{0} -start- sys:link.GetStatus({1},{2})", _node.Address, sm, from));
            }

            CphState cphstate = null;

            if (from != null)
            {
                cphstate = _edge_to_cphstate[from] as CphState;
            }

            /**
             * StatusMessage objects are used to verify the completion
             * of the Link protocol.  If we receive a StatusMessage request
             * after we send a LinkMessage response, we know the other
             * Node got our LinkMessage response, and the connection
             * is active
             */
            StatusMessage   response = null;
            ConnectionTable tab      = _node.ConnectionTable;

            if (cphstate != null)
            {
                try {
                    LinkMessage lm_to_add = cphstate.LM;
                    //This is part of connection process:
                    response = _node.GetStatus(sm.NeighborType, lm_to_add.Local.Address);
                    Connection con = new Connection(from,
                                                    lm_to_add.Local.Address,
                                                    lm_to_add.ConTypeString,
                                                    sm,
                                                    lm_to_add);
                    tab.Add(con);
                }
                finally {
                    from.CloseEvent -= this.CloseHandler;
                    CloseHandler(from, null);
                }
            }
            else
            {
                //This is just a "regular" status request
                //update our table:
                Address    fadd = null;
                Connection c    = tab.GetConnection(from);
                if (c != null)
                {
                    fadd = c.Address;
                    c.SetStatus(sm);
                }
                response = _node.GetStatus(sm.NeighborType, fadd);
            }

            if (ProtocolLog.LinkDebug.Enabled)
            {
                ProtocolLog.Write(ProtocolLog.LinkDebug, String.Format(
                                      "{0} -end- sys:link.GetStatus()->{1}", _node.Address, response));
            }

            return(response.ToDictionary());
        }