Package com.aelitis.azureus.plugins.dht

Examples of com.aelitis.azureus.plugins.dht.DHTPluginOperationListener


    final DistributedDatabaseListener  listener )
  {
     
    contact.isAlive(
      timeout,
      new DHTPluginOperationListener()
      {
        public void
        starts(
          byte[]        key )
        {
View Full Code Here


        DHTPlugin.FLAG_SINGLE_VALUE,
        max_hits,
        30*1000,
        false,
        false,
        new DHTPluginOperationListener()
        {
          private boolean diversified;
          private int    hits;
         
          private Set<String>  entries = new HashSet<String>();
         
          public void
          starts(
            byte[]        key )
          {
          }
         
          public void
          diversified()
          {
            diversified = true;
          }
         
          public void
          valueRead(
            DHTPluginContact  originator,
            DHTPluginValue    value )
          {
            try{
              Map<String,Object> map = (Map<String,Object>)BDecoder.decode( value.getValue());
             
              String  title = new String((byte[])map.get( "d" ), "UTF-8" );
             
              String  tracker  = null;
             
              byte[]  hash   = (byte[])map.get( "h" );
             
              if ( hash == null ){
               
                tracker = new String((byte[])map.get( "t" ), "UTF-8" );
              }
             
              int  rand = ((Long)map.get( "r" )).intValue();
             
              String  key = title + " % " + rand;
             
              synchronized( entries ){
             
                if ( entries.contains( key )){
                 
                  return;
                }
               
                entries.add( key );
              }
             
              Long  l_size = (Long)map.get( "s" );
             
              long  size = l_size==null?0:l_size.longValue();
             
              Long  cnet     = (Long)map.get( "c" );
              Long  published   = (Long)map.get( "p" );
              Long  leechers   = (Long)map.get( "l" );
              Long  seeds     = (Long)map.get( "z" );
             
              // System.out.println( "p=" + published + ", l=" + leechers + ", s=" + seeds );
             
              int  seeds_leechers;
             
              if ( leechers == null && seeds == null ){
               
                seeds_leechers = -1;
               
              }else if ( leechers == null ){
               
                seeds_leechers = seeds.intValue()<<16;
               
              }else if ( seeds == null ){
               
                seeds_leechers = leechers.intValue()&0xffff;
               
              }else{
               
                seeds_leechers = (seeds.intValue()<<16)|(leechers.intValue()&0xffff);
              }
               
              analyseResponse(
                new DownloadInfo(
                    from_info.getHash(), hash, title, rand, tracker, 1, false, size,
                    published==null?0:published.intValue(),
                    seeds_leechers,
                    (byte)(cnet==null?ContentNetwork.CONTENT_NETWORK_UNKNOWN:cnet.byteValue())),
                null );
             
            }catch( Throwable e ){             
            }
           
            hits++;
          }
         
          public void
          valueWritten(
            DHTPluginContact  target,
            DHTPluginValue    value )
          {
           
          }
         
          public void
          complete(
            byte[]        key,
            boolean        timeout_occurred )
          {
            boolean  do_it;
           
            // System.out.println( from_hash + ": hits=" + hits + ", div=" + diversified );
           
            if ( diversified || hits >= 10 ){
             
              do_it = false;
             
            }else if ( hits <= 5 ){
             
              do_it = true;
                           
            }else{
                         
              do_it = RandomUtils.nextInt( hits - 5 + 1 ) == 0;
            }
             
            if ( do_it ){
             
              try{
                dht_plugin.put(
                    key_bytes,
                    "Content relationship: " +  from_hash + " -> " + to_hash,
                    map_bytes,
                    DHTPlugin.FLAG_ANON,
                    new DHTPluginOperationListener()
                    {
                      public void
                      diversified()
                      {
                      }
View Full Code Here

          DHTPlugin.FLAG_SINGLE_VALUE,
          max_hits,
          60*1000,
          false,
          true,
          new DHTPluginOperationListener()
          {
            private Set<String>  entries = new HashSet<String>();
           
            private RelatedContentManagerListener manager_listener =
              new RelatedContentManagerListener()
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.plugins.dht.DHTPluginOperationListener

Copyright © 2018 www.massapicom. 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.