Brunet.Services.MapReduce.MapReduceHandler.SubscribeTask C# (CSharp) Method

SubscribeTask() public method

public SubscribeTask ( MapReduceTask task ) : void
task MapReduceTask
return void
    public void SubscribeTask(MapReduceTask task) {
      lock(_sync) {
        if (_name_to_task.ContainsKey(task.TaskName)) {
          throw new Exception(String.Format("Map reduce task name: {0} already registered.", task.TaskName));
        }
        _name_to_task[task.TaskName] = task;
      }
    }

Usage Example

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);
    }