示例#1
0
        public StructuredNode(AHAddress add, string realm) : base(add, realm)
        {
            /**
             * Here are the ConnectionOverlords
             */
            _leafco = new LeafConnectionOverlord(this);
            AddConnectionOverlord(_leafco);
            _snco = new StructuredNearConnectionOverlord(this);
            AddConnectionOverlord(_snco);
            _ssco = new StructuredShortcutConnectionOverlord(this);
            AddConnectionOverlord(_ssco);
#if !BRUNET_SIMULATOR
            _iphandler = new IPHandler();
            _iphandler.Subscribe(this, null);
            AddTADiscovery(new LocalDiscovery(this, Realm, _rpc, _iphandler));
#endif

            /**
             * Turn on some protocol support :
             */
            /// Turn on Packet Forwarding Support :
            GetTypeSource(PType.Protocol.Forwarding).Subscribe(new PacketForwarder(this), null);
            //Handles AHRouting:
            GetTypeSource(PType.Protocol.AH).Subscribe(new AHHandler(this), this);
            GetTypeSource(PType.Protocol.Echo).Subscribe(new EchoHandler(), this);

            //Add the standard RPC handlers:
            _rpc.AddHandler("sys:ctm", new CtmRequestHandler(this));
            sys_link = new ConnectionPacketHandler(this);
            _rpc.AddHandler("sys:link", sys_link);
            _rpc.AddHandler("trace", new TraceRpcHandler(this));
            //Serve some public information about our ConnectionTable
            _rpc.AddHandler("ConnectionTable", new ConnectionTableRpc(ConnectionTable, _rpc));
            //Add a map-reduce handlers:
            _mr_handler = new MapReduceHandler(this);
            //Subscribe it with the RPC handler:
            _rpc.AddHandler("mapreduce", _mr_handler);

            //Subscribe map-reduce tasks
            _mr_handler.SubscribeTask(new MapReduceTrace(this));
            _mr_handler.SubscribeTask(new MapReduceRangeCounter(this));


            /*
             * Handle Node state changes.
             */
            StateChangeEvent += delegate(Node n, Node.ConnectionState s) {
                if (s == Node.ConnectionState.Leaving)
                {
                    //Start our StructuredNode specific leaving:
                    Leave();
                }
            };

            _connection_table.ConnectionEvent    += new EventHandler(this.EstimateSize);
            _connection_table.ConnectionEvent    += new EventHandler(this.UpdateNeighborStatus);
            _connection_table.DisconnectionEvent += new EventHandler(this.EstimateSize);
            _connection_table.DisconnectionEvent += new EventHandler(this.UpdateNeighborStatus);
        }
示例#2
0
文件: Node.cs 项目: hseom/brunet
 public virtual void AddConnectionOverlord(ConnectionOverlord co)
 {
   _co_list.Add(co);
 }