public StructuredNode(AHAddress add, string realm):base(add,realm) { // Instantiate rpc early! RpcManager rpc = RpcManager.GetInstance(this); /** * Here are the ConnectionOverlords */ _leafco = new LeafConnectionOverlord(this); _snco = new StructuredNearConnectionOverlord(this); _ssco = new StructuredShortcutConnectionOverlord(this); _cco = new ChotaConnectionOverlord(this); _mco = new ManagedConnectionOverlord(this); #if !BRUNET_SIMULATOR _localco = new LocalConnectionOverlord(this); _iphandler = new IPHandler(); _iphandler.Subscribe(this, null); #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); }
public BrunetRpc() { _rrm = new ReqrepManager("BrunetRpc"); _rrm.Subscribe(this, null); Rpc = new RpcManager(_rrm); IPHandler = new IPHandler(); IPHandler.Subscribe(this, null); _running = 1; _timer = new Thread(TimerThread); _timer.IsBackground = true; _timer.Start(); }