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);
    }
Example #2
0
 public Connector(Node local, ISender ps, ConnectToMessage ctm, ConnectionOverlord co, object state)
 {
   _sync = new Object();
   _local_node = local;
   _is_finished = 0;
   _got_ctms = new ArrayList();
   _sender = ps;
   _ctm = ctm;
   _co = co;
   _task = new ConnectorTask(ps);
   _abort = new WriteOnce<AbortCheck>();
   State = state;
 }
Example #3
0
 /**
  * @param local the local Node to connect to the remote node
  * @param eh EventHandler to call when we are finished.
  * @param ISender Use this specific edge.  This is used when we want to
  * connecto to a neighbor of a neighbor
  * @param ctm the ConnectToMessage which is serialized in the packet
  */
 public Connector(Node local, ISender ps, ConnectToMessage ctm, ConnectionOverlord co):
   this(local, ps, ctm, co, null)
 {
 }