Esempio n. 1
0
    public void Update(Dht dht) {
      _sd = new SoapDht(dht);
      RemotingServices.Marshal(_sd, "sd.rem");

      _xd = new XmlRpcDht(dht);
      RemotingServices.Marshal(_xd, "xd.rem");
    }
Esempio n. 2
0
    public void Update(Dht dht,string type) {
      _sd = new SoapDht(dht);
      RemotingServices.Marshal(_sd, type+"_sd.rem");

      _xd = new XmlRpcDht(dht);
      RemotingServices.Marshal(_xd, type+"_xd.rem");
    }
 public SocialNetworkProvider(Dht dht, SocialUser user)
 {
     _local_user = user;
       _dht = dht;
       _provider = _drupal;
       _network = _drupal;
       _drupal = new DrupalNetwork(user);
       _online = false;
 }
Esempio n. 4
0
    public void Test14(ref int op) {
      Console.WriteLine("Test 14: Testing 1000 puts and 1 get with 1000 " +
          "results with the same key.  Then we remove the main owner of the " +
          "key.");
      RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
      byte[] key = new byte[10];
      byte[] value = new byte[value_size];
      rng.GetBytes(key);
      ArrayList al_results = new ArrayList();
      int count = 60;
      BlockingQueue[] results_queue = new BlockingQueue[count];

      for(int i = 0; i < count; i++) {
        value = new byte[value_size];
        rng.GetBytes(value);
        al_results.Add(value);
        results_queue[i] = new BlockingQueue();
        default_dht.AsyncPut(key, value, 3000, results_queue[i]);
      }
      for (int i = 0; i < count; i++) {
        try {
          bool res = (bool) results_queue[i].Dequeue();
          Console.WriteLine("success in put : " + i);
        }
        catch {
          Console.WriteLine("Failure in put : " + i);
        }
      }
      Console.WriteLine("Insertion done...");
      Console.WriteLine("Disconnecting nodes...");
      MemBlock[] b = default_dht.MapToRing(key);
      BigInteger[] baddrs = new BigInteger[default_dht.DEGREE];
      BigInteger[] addrs = new BigInteger[default_dht.DEGREE];
      bool first_run = true;
      foreach(DictionaryEntry de in nodes) {
        Address addr = (Address) de.Key;
        for(int j = 0; j < b.Length; j++) {
          if(first_run) {
            addrs[j] = addr.ToBigInteger();
            baddrs[j] = (new AHAddress(b[j])).ToBigInteger();
          }
          else {
            BigInteger caddr = addr.ToBigInteger();
            BigInteger new_diff = baddrs[j] - caddr;
            if(new_diff < 0) {
              new_diff *= -1;
            }
            BigInteger c_diff = baddrs[j] - addrs[j];
            if(c_diff < 0) {
              c_diff *= -1;
            }
            if(c_diff > new_diff) {
              addrs[j] = caddr;
            }
          }
        }
        first_run = false;
      }

      for(int i = 0; i < addrs.Length; i++) {
        Console.WriteLine(new AHAddress(baddrs[i]) + " " + new AHAddress(addrs[i]));
        Address laddr = new AHAddress(addrs[i]);
        Node node = (Node) nodes[laddr];
        node.Disconnect();
        nodes.Remove(laddr);
        tables.Remove(laddr);
        network_size--;
      }

      default_dht = new Dht((Node) nodes.GetByIndex(0), degree);

      // Checking the ring every 5 seconds..
      do  { Thread.Sleep(5000);}
      while(!CheckAllConnections());
      Console.WriteLine("Going to sleep now...");
      Thread.Sleep(15000);
      Console.WriteLine("Timeout done.... now attempting gets");
      this.SerialAsyncGet(key, (byte[][]) al_results.ToArray(typeof(byte[])), op++);
      Thread.Sleep(5000);
      Console.WriteLine("This checks to make sure our follow up Puts succeeded");
      this.SerialAsyncGet(key, (byte[][]) al_results.ToArray(typeof(byte[])), op++);
      Console.WriteLine("If no error messages successful up to: " + (op - 1));
      foreach(TableServer ts in tables.Values) {
        Console.WriteLine("Count ... " + ts.Count);
      }
    }
Esempio n. 5
0
    public void Init() {
      Console.WriteLine("Initializing...");
      ArrayList RemoteTA = new ArrayList();
      for(int i = 0; i < network_size; i++) {
        RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://127.0.0.1:" + (base_port + i)));
      }

      for(int i = 0; i < network_size; i++) {
        Address addr = (Address) new AHAddress(new RNGCryptoServiceProvider());
        Node node = new StructuredNode((AHAddress) addr, brunet_namespace);
        nodes.Add(addr, node);
        node.AddEdgeListener(new UdpEdgeListener(base_port + i));
        node.RemoteTAs = RemoteTA;
        tables[addr] = new TableServer(node);
        (new Thread(node.Connect)).Start();
//        if(i < network_size / ((Dht)dhts.GetByIndex(i)).DEGREE) {
//          ((Dht)dhts.GetByIndex(i)).debug = true;
//        }
      }
      default_dht = new Dht((Node) nodes.GetByIndex(0), degree);
    }
Esempio n. 6
0
    /**
    <summary>Creates a Brunet.Node, the resulting node will be available in
    the class as _node.</summary>
    <remarks>The steps to creating a node are first constructing it with a
    namespace, optionally adding local ip addresses to bind to, specifying
    local end points, specifying remote end points, and finally registering
    the dht.</remarks>
    */
    public virtual void CreateNode() {
      AHAddress address = (AHAddress) AddressParser.Parse(_node_config.NodeAddress);
      _node = new StructuredNode(address, _node_config.BrunetNamespace);
      IEnumerable addresses = IPAddresses.GetIPAddresses(_node_config.DevicesToBind);

      Brunet.EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in _node_config.EdgeListeners) {
        int port = item.port;
        if (item.type =="tcp") {
          try {
            el = new TcpEdgeListener(port, addresses);
          }
          catch {
            el = new TcpEdgeListener(0, addresses);
          }
        }
        else if (item.type == "udp") {
          try {
            el = new UdpEdgeListener(port, addresses);
          }
          catch {
            el = new UdpEdgeListener(0, addresses);
          }
        }
        else {
          throw new Exception("Unrecognized transport: " + item.type);
        }
        _node.AddEdgeListener(el);
      }
      el = new TunnelEdgeListener(_node);
      _node.AddEdgeListener(el);

      ArrayList RemoteTAs = null;
      if(_node_config.RemoteTAs != null) {
        RemoteTAs = new ArrayList();
        foreach(String ta in _node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
        _node.RemoteTAs = RemoteTAs;
      }

      try {
        if (_node_config.NCService.Enabled) {
          _ncservice = new NCService(_node, _node_config.NCService.Checkpoint);

          if (_node_config.NCService.OptimizeShortcuts) {
            _node.Sco.TargetSelector = new VivaldiTargetSelector(_node, _ncservice);
          }
        }
      } catch {}
      _dht = new Dht(_node, 3, 20);
    }
Esempio n. 7
0
 public DhtAdapter(Dht dht) {
   this._dht = dht;
 }
Esempio n. 8
0
 public XmlRpcDht(Dht dht) : base(dht) { }
Esempio n. 9
0
 public SoapDht(Dht dht) : base(dht) { }
Esempio n. 10
0
    /**
    <summary>Creates a Brunet.Node, the resulting node will be available in
    the class as _node.</summary>
    <remarks>The steps to creating a node are first constructing it with a
    namespace, optionally adding local ip addresses to bind to, specifying
    local end points, specifying remote end points, and finally registering
    the dht.</remarks>
    */
    public virtual void CreateNode(string type) {
      NodeConfig node_config = null;
      StructuredNode current_node = null;
      AHAddress address = null;
      if (type == "cache") {
        node_config = _c_node_config;
        address = (AHAddress) AddressParser.Parse(node_config.NodeAddress);
        current_node = new StructuredNode(address, node_config.BrunetNamespace);
      }
      else if ( type == "query" ) {
        node_config = _q_node_config;
        address = (AHAddress) AddressParser.Parse(node_config.NodeAddress);
        current_node = new StructuredNode(address, node_config.BrunetNamespace);
      }
      else {
        throw new Exception("Unrecognized node type: " + type);
      }
      IEnumerable addresses = IPAddresses.GetIPAddresses(node_config.DevicesToBind);

      Brunet.EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in node_config.EdgeListeners) {
        int port = item.port;
        if (item.type =="tcp") {
          try {
            el = new TcpEdgeListener(port, addresses);
          }
          catch {
            el = new TcpEdgeListener(0, addresses);
          }
        }
        else if (item.type == "udp") {
          try {
            el = new UdpEdgeListener(port, addresses);
          }
          catch {
            el = new UdpEdgeListener(0, addresses);
          }
        }
        else {
          throw new Exception("Unrecognized transport: " + item.type);
        }
	current_node.AddEdgeListener(el);
      }
      el = new TunnelEdgeListener(current_node);
      current_node.AddEdgeListener(el);

      ArrayList RemoteTAs = null;
      if(node_config.RemoteTAs != null) {
        RemoteTAs = new ArrayList();
        foreach(String ta in node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
	current_node.RemoteTAs = RemoteTAs;
      }

      try {
        if (node_config.NCService.Enabled) {
	  if (type == "cache") {
            _c_ncservice = new NCService(current_node, node_config.NCService.Checkpoint);
            if (node_config.NCService.OptimizeShortcuts) {
              current_node.Sco.TargetSelector = new VivaldiTargetSelector(current_node, _c_ncservice);
	    }
	  }
	  else {
            _q_ncservice = new NCService(current_node, node_config.NCService.Checkpoint);
            if (node_config.NCService.OptimizeShortcuts) {
              current_node.Sco.TargetSelector = new VivaldiTargetSelector(current_node, _q_ncservice);
	    }
	  }

        }
      } catch {}

      if (type == "cache") {
        _c_dht = new Dht(current_node, 3, 20);
        _cs = new CacheList(current_node);
        current_node.MapReduce.SubscribeTask(new MapReduceCache(current_node,_cs));
        current_node.MapReduce.SubscribeTask(new MapReduceCrawl(current_node));
	_c_node = current_node;
      }
      else {
        _q_dht = new Dht(current_node, 3, 20);
	CacheList q_cs = new CacheList(current_node);
        current_node.MapReduce.SubscribeTask(new MapReduceQuery(current_node,_cs));
        current_node.MapReduce.SubscribeTask(new MapReduceCrawl(current_node));
	_q_node = current_node;
      }

    }
Esempio n. 11
0
      public void Start()
      {
        Channel returns = new Channel();
        returns.EnqueueEvent += delegate(object o, EventArgs ea) {
          while(returns.Count > 0) {
            Hashtable result = null;
            try {
              result = returns.Dequeue() as Hashtable;
            } catch {
              continue;
            }

            byte[] res = result["value"] as byte[];
            if(res != null) {
              Results.Enqueue(MemBlock.Reference(res));
            }
          }
          if(_enqueue != null) {
            _enqueue(this, EventArgs.Empty);
          }
        };

        returns.CloseEvent += delegate(object o, EventArgs ea) {
          if(_close != null) {
            _close(this, EventArgs.Empty);
          }
          _done = true;
        };

        Dht dht = new Dht(Node, 3, 20);
        dht.AsyncGet(_key, returns);
      }
Esempio n. 12
0
      public void Start()
      {
        Channel returns = new Channel();
        returns.CloseEvent += delegate(object o, EventArgs ea) {
          try {
            _successful = (bool) returns.Dequeue();
          } catch {
          }

          _done = true;
          if(_callback != null) {
            _callback(this, EventArgs.Empty);
          }
        };
        Dht dht = new Dht(_node, 3, 20);
        dht.AsyncPut(_key, _value, _ttl, returns);
      }