Examples of DHT


Examples of com.aelitis.azureus.core.dht.DHT

       
        if ( i > 0 ){
          ci.out.println("");
        }
       
        DHT  dht = dhts[i];
       
        DHTTransport transport = dht.getTransport();
       
        DHTTransportStats  t_stats = transport.getStats();
        DHTDBStats      d_stats  = dht.getDataBase().getStats();
        DHTControlStats    c_stats = dht.getControl().getStats();
        DHTRouterStats    r_stats = dht.getRouter().getStats();
       
        long[]  rs = r_stats.getStats();
 
        DHTNetworkPosition[]  nps = transport.getLocalContact().getNetworkPositions();
       
View Full Code Here

Examples of com.aelitis.azureus.core.dht.DHT

    try{
      if ( test_address.length() == 0 ){
       
        DHT[]  dhts = dht_plugin.getDHTs();
       
        DHT  target_dht = null;
       
        int  target_network  = Constants.isCVSVersion()?DHT.NW_CVS:DHT.NW_MAIN;
       
        for (int i=0;i<dhts.length;i++){
         
          if ( dhts[i].getTransport().getNetwork() == target_network ){
           
            target_dht = dhts[i];
           
            break;
          }
        }
       
        if ( target_dht == null ){
         
          listener.logError( "Distributed database unavailable" );
         
        }else{
         
          DHTTransportContact[] contacts = target_dht.getTransport().getReachableContacts();
         
          final List f_contacts = new ArrayList(Arrays.asList(contacts));
         
          final int[]  ok = new int[]{ 0 };
         
View Full Code Here

Examples of com.aelitis.azureus.core.dht.DHT

               
                if ( first_dht ){
                 
                  first_dht  = false;
               
                  DHT   dht = (DHT)ev.getValue();
                 
                  speed_manager.setSpeedTester( dht.getSpeedTester());
                 
                  global_manager.addListener(
                      new GlobalManagerAdapter()
                      {
                        public void
View Full Code Here

Examples of com.aelitis.azureus.core.dht.DHT

                  return;
                }
               
                for (int i=0;i<dhts.length;i++){

                  DHT  dht = dhts[i].getDHT();
                 
                  DHTTransportUDP  transport = (DHTTransportUDP)dht.getTransport();
                 
                  String  c = command.getValue().trim();
                 
                  String  lc = c.toLowerCase();
                 
                  if ( lc.equals("print")){
                   
                    dht.print( true );
                   
                    dhts[i].logStats();
                   
                  }else if ( lc.equals( "pingall" )){
                   
                    if ( i == 1 ){
                     
                      dht.getControl().pingAll();
                    }
                   
                  }else if ( lc.equals( "versions" )){
                   
                    List<DHTRouterContact> contacts = dht.getRouter().getAllContacts();
                   
                    Map<Byte,Integer>  counts = new TreeMap<Byte, Integer>();
                   
                    for ( DHTRouterContact r: contacts ){
                     
                      DHTControlContact contact = (DHTControlContact)r.getAttachment();
                     
                      byte v = contact.getTransportContact().getProtocolVersion();
                     
                      Integer count = counts.get( v );
                     
                      if ( count == null ){
                       
                        counts.put( v, 1 );
                       
                      }else{
                       
                        counts.put( v, count+1 );
                      }
                    }
                   
                    log.log( "Net " + dht.getTransport().getNetwork());
                   
                    int  total = contacts.size();
                   
                    if ( total == 0 ){
                     
                      log.log( "   no contacts" );
                     
                    }else{
                     
                      String ver = "";
                     
                      for ( Map.Entry<Byte, Integer> entry: counts.entrySet()){
                     
                        ver += (ver.length()==0?"":", " ) + entry.getKey() + "=" + 100*entry.getValue()/total + "%";
                      }
                     
                      log.log( "    contacts=" + total + ": " + ver );
                    }
                  }else if ( lc.equals( "testca" )){
                               
                    ((DHTTransportUDPImpl)transport).testExternalAddressChange();
                   
                  }else if ( lc.equals( "testnd" )){
                   
                    ((DHTTransportUDPImpl)transport).testNetworkAlive( false );
                   
                  }else if ( lc.equals( "testna" )){
                   
                    ((DHTTransportUDPImpl)transport).testNetworkAlive( true );
       
                  }else{
                   
                    int pos = c.indexOf( ' ' );
                   
                    if ( pos != -1 ){
                     
                      String  lhs = lc.substring(0,pos);
                      String  rhs = c.substring(pos+1);
                     
                      if ( lhs.equals( "set" )){
                       
                        pos  = rhs.indexOf( '=' );
                       
                        if ( pos != -1 ){
                         
                          DHTPlugin.this.put(
                              rhs.substring(0,pos).getBytes(),
                              "DHT Plugin: set",
                              rhs.substring(pos+1).getBytes(),
                              (byte)0,
                              log_polistener );
                        }
                      }else if ( lhs.equals( "get" )){
                       
                        DHTPlugin.this.get(
                          rhs.getBytes(), "DHT Plugin: get", (byte)0, 1, 10000, true, false, log_polistener );
 
                      }else if ( lhs.equals( "query" )){
                       
                        DHTPlugin.this.get(
                          rhs.getBytes(), "DHT Plugin: get", DHTPlugin.FLAG_STATS, 1, 10000, true, false, log_polistener );

                      }else if ( lhs.equals( "punch" )){

                        Map  originator_data = new HashMap();
                       
                        originator_data.put( "hello", "mum" );

                        DHTNATPuncher puncher = dht.getNATPuncher();
                       
                        if ( puncher != null ){
                       
                          puncher.punch( "Test", transport.getLocalContact(), null, originator_data );
                        }
                      }else if ( lhs.equals( "stats" )){
                       
                        try{
                          pos = rhs.lastIndexOf( ":" );
                         
                          DHTTransportContact  contact;
                         
                          if ( pos == -1 ){
                         
                            contact = transport.getLocalContact();
                           
                          }else{
                           
                            String  host = rhs.substring(0,pos);
                            int    port = Integer.parseInt( rhs.substring(pos+1));
                           
                            contact =
                                transport.importContact(
                                    new InetSocketAddress( host, port ),
                                    transport.getProtocolVersion());
                          }
                         
                          log.log( "Stats request to " + contact.getName());
                         
                          DHTTransportFullStats stats = contact.getStats();
                           
                          log.log( "Stats:" + (stats==null?"<null>":stats.getString()));
                           
                          DHTControlActivity[] activities = dht.getControl().getActivities();
                           
                          for (int j=0;j<activities.length;j++){
                             
                            log.log( "    act:" + activities[j].getString());
                          }
                     
                        }catch( Throwable e ){
                         
                          Debug.printStackTrace(e);
                        }
                      }
                    }
                  }
                }
              }
            };
                     
          t.start();
        }
      });
   
    reseed.addListener(
        new ParameterListener()
        {
          public void
          parameterChanged(
            Parameter  param )
          {
            reseed.setEnabled( false );           

            AEThread2 t =
              new AEThread2( "DHT:reseeder", true )
              {
                public void
                run()
                {
                  try{
                    String  ip   = reseed_ip.getValue().trim();

                    if ( dhts == null ){
                     
                      return;
                    }
                 
                    int    port = reseed_port.getValue();
                 
                    for (int i=0;i<dhts.length;i++){
                     
                      DHTPluginImpl  dht = dhts[i];
                   
                      if ( ip.length() == 0 || port == 0 ){
                       
                        dht.checkForReSeed( true );
                       
                      }else{
                       
                        if ( dht.importSeed( ip, port ) != null ){
                         
                          dht.integrateDHT( false, null );
                        }
                      }
                    }
                   
                  }finally{
View Full Code Here

Examples of com.aelitis.azureus.core.dht.DHT

           
            DHTPlugin dht_plugin = (DHTPlugin)dht_pi.getPlugin();
           
            if ( dht_plugin.isEnabled()){
             
              DHT dht = dht_plugin.getDHT( DHT.NW_MAIN );
             
              if ( dht == null ){
               
                dht = dht_plugin.getDHT( DHT.NW_CVS );
              }
             
              if ( dht != null ){
               
                puncher = dht.getNATPuncher();
              }
            }
          }
        }
       
View Full Code Here

Examples of com.spidercache.dht.DHT

   * Logic for bootstrapping:
   *
   */
  private void nodeStart(){
   
    D = new DHT("SpiderCache DHT", DHTPort, MessagePort, null, 0);
    DS = new DiscoveryService(D, DHTPort);
    NA = new NodeAnnouncer(DS);
    cachepath = "/home/snark/cache";
   
  }
View Full Code Here

Examples of com.spidercache.dht.DHT

public class AddGetTest {

  @Test
  public void testAddGet() {
    TestObject test = new TestObject("Testing!");
    DHT node1 = new DHT("Node 5001", 5001, 5101, "127.0.0.1", 5001);
    DHT node2 = new DHT("Node 5002", 5002, 5102, "127.0.0.1", 5001);
    node1.put("test", test);
      try {
        assertEquals(test, (TestObject) node2.get("test"));
      } catch (RoutingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

Examples of org.ardverk.dht.DHT

    boolean success = false;
    try {
      for (int i = 0; i < count; i++) {
        int prt = port+i;
       
        DHT dht = factory.newDHT(prt);
       
        dht.bind(new DatagramTransport(
            new BencodeMessageCodec(), prt));
        dhts.add(dht);
      }
      success = true;
    } finally {
View Full Code Here

Examples of org.ardverk.dht.DHT

    if (dhts.size() <= 1) {
      throw new IllegalArgumentException();
    }
   
    // Bootstrap everyone from the first DHT
    DHT first = dhts.get(0);
    List<DHTFuture<BootstrapEntity>> futures1
      = bootstrap(first.getIdentity(), dhts, 1, dhts.size()-1);
   
    // The RouteTable is all messed up! Clear it and bootstrap
    // the first DHT from the others.
    ((DefaultRouteTable)first.getRouteTable()).clear();
    TestCase.assertEquals(1, first.getRouteTable().size());
   
    List<DHTFuture<BootstrapEntity>> futures2
      = bootstrap(dhts.get(1).getIdentity(), dhts, 0, 1);
   
    futures2.addAll(futures1);
View Full Code Here

Examples of org.ardverk.dht.DHT

          new XorComparator(lookupId));
      for (DHT dht : dhts) {
        expected.add(dht.getIdentity().getId());
      }
     
      DHT first = dhts.get(0);
     
      NodeConfig config = new NodeConfig();
      config.setLookupTimeout(20L, TimeUnit.SECONDS);
     
      DHTFuture<NodeEntity> future
        = first.discover(lookupId, config);
      NodeEntity entity = future.get();
      TestCase.assertEquals(lookupId, entity.getId());
     
      Contact[] contacts = entity.getContacts();
      Contact[] closest = entity.getClosest();
     
      // The Contacts in the response should be in the same order
      // as our DHT instances!
      int k = first.getRouteTable().getK();
      for (int i = 0; i < k && i < contacts.length; i++) {
        KUID contactId = contacts[i].getId();
        KUID closestId = closest[i].getId();
       
        KUID expectedId = expected.pollFirst();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.