示例#1
0
    //Methods:

    protected PathELManager(EdgeListener el, bool thread) {
      _el = el;
      _sync = new object();
      _edges = new List<Edge>();
      _unannounced = new Dictionary<Edge, PathEdge>();
      _pel_map = new Dictionary<string, PathEdgeListener>();
      //Use the reqrep protocol with a special prefix:
      _rrm = new ReqrepManager("PathELManager:" + el.ToString(), PType.Protocol.Pathing);
      _rrm.Subscribe(this, null);
      Rpc = new RpcManager(_rrm);
      Rpc.AddHandler("sys:pathing", this);
      _el.EdgeEvent += HandleEdge;
      _running = true;

      if(thread) {
        _timer_thread = new Thread(
          delegate() {
            int counter = 0;
            int max_counter = EDGE_PERIOD / 1000;
            while(_running) {
              Thread.Sleep(1000);
              ReqrepTimeoutChecker();
              if(++counter == max_counter) {
                counter = 0;
                EdgeTimeoutChecker();
              }
            }
          }
        );

        _timer_thread.IsBackground = true;
        _timer_thread.Start();
      }
    }
示例#2
0
 public PathEdgeListener(PathELManager pem, string path, EdgeListener el)
 {
     _path       = path;
     _el         = el;
     _pem        = pem;
     _is_started = 0;
     _count      = 0;
 }
示例#3
0
 public WrapperEdgeListener(EdgeListener el) {
   _sync = new object();
   lock(_sync) {
     _el = el;
     _el.EdgeEvent += HandleEdgeEvent;
     _el.EdgeCloseRequestEvent += HandleEdgeCloseRequestEvent;
     _edge_to_wrapper_edge = new Dictionary<Edge, WrapperEdge>(); 
     _edge_to_ecw = new  Dictionary<Edge, EdgeCreationWrapper>();
   }
 }
示例#4
0
 public WrapperEdgeListener(EdgeListener el)
 {
     _sync = new object();
     lock (_sync) {
         _el                        = el;
         _el.EdgeEvent             += HandleEdgeEvent;
         _el.EdgeCloseRequestEvent += HandleEdgeCloseRequestEvent;
         _edge_to_wrapper_edge      = new Dictionary <Edge, WrapperEdge>();
         _edge_to_ecw               = new  Dictionary <Edge, EdgeCreationWrapper>();
     }
 }
示例#5
0
 /**
  * This creates Edges of a given type
  */
 public void CreateEdgeTo(TransportAddress destination,
                          EdgeListener.EdgeCreationCallback ecb)
 {
   TransportAddress.TAType t = destination.TransportAddressType;
   if( _el_map.Contains( t ) ) {
     EdgeListener el = (EdgeListener)_el_map[ t ];
     el.CreateEdgeTo( destination, ecb );
   }
   else {
     ecb(false, null, new EdgeException("No EdgeListener for TA type: " +
                                        t.ToString() ) );
   }
 }
示例#6
0
 /**
  * This creates Edges of a given type
  */
 public void CreateEdgeTo(TransportAddress destination,
                          EdgeListener.EdgeCreationCallback ecb)
 {
     TransportAddress.TAType t = destination.TransportAddressType;
     if (_el_map.Contains(t))
     {
         EdgeListener el = (EdgeListener)_el_map[t];
         el.CreateEdgeTo(destination, ecb);
     }
     else
     {
         ecb(false, null, new EdgeException("No EdgeListener for TA type: " +
                                            t.ToString()));
     }
 }
示例#7
0
        /** Multiplex an EdgeListener using Pathing with the IActionQueue managing the
         * Rrm.
         * @param el the EdgeListener to multiplex
         */
        public PathELManager(EdgeListener el, IActionQueue queue) : this(el, false)
        {
            PathELManagerAction pema_rrm  = new PathELManagerAction(this, ReqrepTimeoutChecker);
            Action <DateTime>   torun_rrm = delegate(DateTime now) {
                queue.EnqueueAction(pema_rrm);
            };

            _rrm_fe = Brunet.Util.FuzzyTimer.Instance.DoEvery(torun_rrm, RRM_PERIOD, (RRM_PERIOD / 2) + 1);

            PathELManagerAction pema_edge  = new PathELManagerAction(this, EdgeTimeoutChecker);
            Action <DateTime>   torun_edge = delegate(DateTime now) {
                queue.EnqueueAction(pema_edge);
            };

            _edge_fe = Brunet.Util.FuzzyTimer.Instance.DoEvery(torun_edge, EDGE_PERIOD, (EDGE_PERIOD / 2) + 1);
        }
示例#8
0
        //Methods:

        protected PathELManager(EdgeListener el, bool thread)
        {
            _el          = el;
            _sync        = new object();
            _edges       = new List <Edge>();
            _unannounced = new Dictionary <Edge, PathEdge>();
            _pel_map     = new Dictionary <string, PathEdgeListener>();
            //Use the reqrep protocol with a special prefix:
            _rrm = new ReqrepManager("PathELManager:" + el.ToString(), PType.Protocol.Pathing);
            _rrm.Subscribe(this, null);
            Rpc = new RpcManager(_rrm);
            Rpc.AddHandler("sys:pathing", this);
            _el.EdgeEvent += HandleEdge;
            _running       = true;

            if (thread)
            {
                _timer_thread = new Thread(
                    delegate() {
                    int counter     = 0;
                    int max_counter = EDGE_PERIOD / 1000;
                    while (_running)
                    {
                        Thread.Sleep(1000);
                        ReqrepTimeoutChecker();
                        if (++counter == max_counter)
                        {
                            counter = 0;
                            EdgeTimeoutChecker();
                        }
                    }
                }
                    );

                _timer_thread.IsBackground = true;
                _timer_thread.Start();
            }
        }
示例#9
0
 public CreateState(PathEdgeListener pel, string rem, string loc,
                    EdgeListener.EdgeCreationCallback ecb, bool root) {
   _pel = pel;
   RemotePath = rem;
   LocalPath = loc;
   ECB = ecb;
   _root = root;
 }
示例#10
0
 public PathEdgeListener(PathELManager pem, string path, EdgeListener el) {
   _path = path;
   _el = el;
   _pem = pem;
   _is_started = 0;
   _count = 0;
 }
示例#11
0
    /** Multiplex an EdgeListener using Pathing with the IActionQueue managing the
     * Rrm.
     * @param el the EdgeListener to multiplex
     */
    public PathELManager(EdgeListener el, IActionQueue queue) : this(el, false) {
      PathELManagerAction pema_rrm = new PathELManagerAction(this, ReqrepTimeoutChecker);
      Action<DateTime> torun_rrm = delegate(DateTime now) {
        queue.EnqueueAction(pema_rrm);
      };
      _rrm_fe = Brunet.Util.FuzzyTimer.Instance.DoEvery(torun_rrm, RRM_PERIOD, (RRM_PERIOD / 2) + 1);

      PathELManagerAction pema_edge = new PathELManagerAction(this, EdgeTimeoutChecker);
      Action<DateTime> torun_edge = delegate(DateTime now) {
        queue.EnqueueAction(pema_edge);
      };
      _edge_fe = Brunet.Util.FuzzyTimer.Instance.DoEvery(torun_edge, EDGE_PERIOD, (EDGE_PERIOD / 2) + 1);
    }
示例#12
0
 /** Multiplex an EdgeListener using Pathing with a thread managing the Rrm
  * @param el the EdgeListener to multiplex
  */
 public PathELManager(EdgeListener el) : this(el, true) {
 }
示例#13
0
 /**
  * NOTE: This should only be called by the Node that
  * owns this EdgeFactory.  DO NOT ADD EdgeListener objects
  * to the EdgeFactory.  Add them through the Node, and it
  * will add them to its EdgeFactory.
  * @see Node
  *
  * EdgeListener objects actually make the edges of a given
  * type.  In order to make an Edge of a given type, you need
  * to register an EdgeListener to do that job.
  */
 public void AddListener(EdgeListener el)
 {
     _el_map[el.TAType] = el;
 }
示例#14
0
 /**
  * NOTE: This should only be called by the Node that
  * owns this EdgeFactory.  DO NOT ADD EdgeListener objects
  * to the EdgeFactory.  Add them through the Node, and it
  * will add them to its EdgeFactory.
  * @see Node
  * 
  * EdgeListener objects actually make the edges of a given
  * type.  In order to make an Edge of a given type, you need
  * to register an EdgeListener to do that job.
  */
 public void AddListener(EdgeListener el)
 {
   _el_map[ el.TAType ] = el;
 }
示例#15
0
 /** creates a new outgoing Edge using the pathing protocol
  */
 public override void CreateEdgeTo(TransportAddress ta,
                                   EdgeListener.EdgeCreationCallback ecb) {
   if( !IsStarted ) {
     throw new EdgeException("PathEdgeListener is not started");
   }
   string rempath;
   TransportAddress base_ta = PathELManager.SplitPath(ta, out rempath);
   bool root = false;
   if( _path == PathELManager.Root && rempath == PathELManager.Root ) {
     root = true;
   }
   CreateState cs = new CreateState(this, rempath, _path, ecb, root);
   _el.CreateEdgeTo(base_ta, cs.HandleEC);
 }
示例#16
0
 public EdgeCreationWrapper(TransportAddress ta, EdgeListener.EdgeCreationCallback ecb,
     Edge edge, WrapperEdgeListener parent)
 {
   ExternalECB = ecb;
   TA = ta;
   Parent = parent;
   _edge = edge;
   _called = 0;
 }
示例#17
0
 /** Multiplex an EdgeListener using Pathing with a thread managing the Rrm
  * @param el the EdgeListener to multiplex
  */
 public PathELManager(EdgeListener el) : this(el, true)
 {
 }