Ejemplo n.º 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);
      AHHandler = new AHHandler(this);
      GetTypeSource(PType.Protocol.AH).Subscribe(AHHandler, 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);
    }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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)
 {
 }
Ejemplo n.º 5
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)
 {
 }