/**
 <summary>Creates an Information object for the node and type of service
 provider.</summary>
 <param name="node">The node where the service is to be provided</param>
 <param name="type">The name of the application providing service (example:
 BasicNode)</param>
 */
 public Information(StructuredNode node, String type) {
   UserData = new Hashtable();
   _type = type;
   _node = node;
   _rpc = RpcManager.GetInstance(node);
   _rpc.AddHandler("Information", this);
 }
 /// <summary>Initiates a RpcProxyHandler instance. It uses reflection for rpc call.
 /// Thus, it does not have to inherit IRpcHanler.This instance keeps Entry
 /// to keep track of key, value, and ttl</summary>
 /// <param name="node">node which is currently connected.</param>
 /// <param name="dht">IDht instance</param>
 public RpcDhtProxy(IDht dht, Node node)
 {
   _entries = new Dictionary<MemBlock, Dictionary<MemBlock, Entry>>();
   _rpc = node.Rpc;
   _dht = dht;
   _sync = new Object();
   _rpc.AddHandler("RpcDhtProxy", this);
 }
 public SocialRpcHandler(StructuredNode node, SocialUser localUser,
                    Dictionary<string, SocialUser> friends)
 {
     _node = node;
       _rpc = node.Rpc;
       _rpc.AddHandler("SocialVPN", this);
       _local_user = localUser;
       _friends = friends;
 }
Beispiel #4
0
 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();
 }
    /**
    <summary>Creates a new TableServer object and registers it to the "dht"
    handler in the node's RpcManager.</summary>
    <param name="node">The node the dht is to serve from.</param>
    */
    public TableServer(Node node) {
      _sync = new Object();
      _transfer_sync = new Object();

      _node = node;
      _rpc = RpcManager.GetInstance(node);

      _data = new TableServerData(_node);
      lock(_transfer_sync) {
        node.ConnectionTable.ConnectionEvent += this.ConnectionHandler;
        node.ConnectionTable.DisconnectionEvent += this.ConnectionHandler;
        _node.StateChangeEvent += StateChangeHandler;
      }

      _rpc.AddHandler("dht", this);
    }
    public LocalConnectionOverlord(Node node) {
      _sync = new Object();
      _allow_localcons = false;
      _active = false;
      _local_addresses = new List<AHAddress>();
      _node = node;

      lock(_sync) {
        _rpc = RpcManager.GetInstance(node);
        _rpc.AddHandler("LocalCO", this);

        _node.HeartBeatEvent += CheckConnection;
        _node.StateChangeEvent += StateChangeHandler;
        _node.ConnectionTable.ConnectionEvent += ConnectHandler;
        _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
        _last_announce_call = DateTime.MinValue;
        _last_activate_call = DateTime.MinValue;
      }
    }
Beispiel #7
0
 /// <summary>A default Dht client provides a DEGREE of 1 and a sychronous wait
 /// time of up to 60 seconds.</summary>
 /// <param name ="node">The node to provide service for.</param>
 public Dht(Node node) {
   Node = node;
   _rpc = node.Rpc;
   _sync = new object();
   StateChangeHandler(Node, Node.ConState);
   Node.StateChangeEvent += StateChangeHandler;
   DEGREE = 1;
   MAJORITY = 1;
   DELAY = 60000;
 }
Beispiel #8
0
 public ReflectionRpcHandler(RpcManager rpc, object handler, bool use_sender) {
   _rpc = rpc;
   _handler = handler;
   _type = _handler.GetType();
   _use_sender = use_sender;
   _sync = new object();
   //Cache the 10 most used methods:
   _method_cache = new Cache(10);
 }
Beispiel #9
0
 /** 
  * Constructor
  * @param node local node
  * @param state RPC related state.
  * @param task map-reduce task.
  * @param args arguments to the map reduce task.
  */
 public MapReduceComputation(Node node, object state, 
                             MapReduceTask task,
                             MapReduceArgs args)
 {
   _node = node;
   _rpc = node.Rpc;
   _mr_request_state = state;
   _mr_task = task;
   _mr_args = args;
   //Here is our state variable:
   _state = new State();
   _result = State.DEFAULT_OBJ;
 }
Beispiel #10
0
 /** 
  * Constructor
  * @param node local node
  * @param state RPC related state.
  * @param task map-reduce task.
  * @param args arguments to the map reduce task.
  */
 public MapReduceComputation(Node node, object state, 
                             MapReduceTask task,
                             MapReduceArgs args)
 {
   _node = node;
   _rpc = RpcManager.GetInstance(node);
   _mr_request_state = state;
   _mr_task = task;
   _mr_args = args;
   _queue_to_child = new Hashtable();
   _sync = new object();
   _finished = false;
 }
Beispiel #11
0
 /**
  * Constructor
  * @param n local node
  */
 public MapReduceHandler(Node n) {
   _node = n;
   _rpc = n.Rpc;
   _name_to_task = new Dictionary<string, MapReduceTask>();
   _sync = new object();
   //Set up some basic tasks:
   var basetasks = new MapReduceTask[]{
     new MapReduceBoundedBroadcast(_node),
     new MapReduceGreedy(_node),
     new MapReduceListConcat(_node),
   };
   foreach(MapReduceTask mrt in basetasks) {
     SubscribeTask(mrt);
   }
 }
Beispiel #12
0
 /** 
  * Constructor
  * @param node local node
  * @param state RPC related state.
  * @param task map-reduce task.
  * @param args arguments to the map reduce task.
  */
 public MapReduceComputation(Node node, object state, 
                             MapReduceTask task,
                             MapReduceArgs args)
 {
   _node = node;
   _rpc = RpcManager.GetInstance(node);
   _mr_request_state = state;
   _mr_task = task;
   _mr_args = args;
   _queue_to_child = new Hashtable();
   _sync = new object();
   _finished = false;
   _start_time = DateTime.UtcNow;
   //register with the node hearbeat to for computation to finish.
   lock(_sync) {
     _node.HeartBeatEvent += new EventHandler(this.CheckTimeout);
   }
 }
Beispiel #13
0
 /**
  * Constructor
  * @param n local node
  */
 public MapReduceHandler(Node n) {
   _node = n;
   _rpc = RpcManager.GetInstance(n);
   _name_to_task = new Hashtable();
   _sync = new object();
 }
        /// <summary>
        /// Constructor for the class, it initializes various objects
        /// </summary>
        /// <param name="node">Takes in a structured node</param>
        public RpcAddressResolverAndDNS(StructuredNode node, DHCPServer dhcp, MemBlock local_ip)
            : base(MemBlock.Reference(dhcp.BaseIP), MemBlock.Reference(dhcp.Netmask))
        {
            _node = node;
              _rpc = _node.Rpc;
              _dns_a = new Hashtable();
              _dns_ptr = new Hashtable();
              _ip_addr = new Hashtable();
              _addr_ip = new Hashtable();
              _blocked_addrs = new Hashtable();
              mcast_addr = new ArrayList();

              _dhcp = dhcp;
              _local_ip = local_ip;

              _rpc.AddHandler("RpcIpopNode", this);
        }
Beispiel #15
0
 /**
  * Constructor.
  * @param node the p2p node.
  * @param localUser the local user object.
  * @param friends the list of friends.
  */
 public SocialRpcHandler(StructuredNode node, SocialUser localUser,
                    Dictionary<string, SocialUser> friends,
                    BlockingQueue queue, SocialDnsManager sdm)
 {
     _node = node;
       _rpc = node.Rpc;
       _rpc.AddHandler("SocialVPN", this);
       _local_user = localUser;
       _friends = friends;
       _queue = queue;
       _sdm = sdm;
 }
Beispiel #16
0
    /** 
     * Installs the network coordinate service on a given node. 
     * NCService instance can be installed on atmost one node. 
     * Each node is allowed to have only one NCService instance. 
     * @param node node for installing the service instance. 
     * @param InitialPoint a starting place for the NCService to use
     */
    public NCService(Node node, Point InitialPoint) {
      _sync = new object();
      _node = null;
      _last_sample_instant = DateTime.MinValue;
      _samples = new Hashtable();
      _vivaldi_state = new VivaldiState();
      _vivaldi_state.WeightedError = INITIAL_WEIGHTED_ERROR;
      _vivaldi_state.Position = new Point();
      _vivaldi_state.DistanceDelta = 0.0f;

      if(InitialPoint == null) {
        InitialPoint = new Point();
      }
      _vivaldi_state.Position = InitialPoint;

      if(node != null) {
        _node = node;

#if NC_DEBUG
        Console.Error.WriteLine("[NCService] {0} Starting an instance of NCService.", node.Address);
#endif 

        lock(_sync) {
          _rpc = _node.Rpc;
          _rpc.AddHandler("ncserver", this);
          _node.HeartBeatEvent += GetNextSample;
        }
      }
    }
Beispiel #17
0
 public MRpcMTestReflection()
 {
   rpc = new MockRpcManager();
   rpc.AddHandler("test", this); 
 }
Beispiel #18
0
 /**
 <summary>A default Dht client provides a DEGREE of 1 and a sychronous wait
 time of up to 60 seconds.</summary>
 <param name ="node">The node to provide service for.</param>
 */
 public Dht(Node node) {
   this.node = node;
   _rpc = RpcManager.GetInstance(node);
   _table = new TableServer(node);
   DEGREE = 1;
   MAJORITY = 1;
   DELAY = 60000;
 }