Package org.gudy.azureus2.plugins.ddb

Examples of org.gudy.azureus2.plugins.ddb.DistributedDatabaseContact


  protected void
  showDHTStats(
    ConsoleInput  ci )
  {
    try{
      PluginInterface  def = ci.azureus_core.getPluginManager().getDefaultPluginInterface();
     
      PluginInterface dht_pi =
        def.getPluginManager().getPluginInterfaceByClass(DHTPlugin.class );
     
      if ( dht_pi == null ){
     
        ci.out.println( "\tDHT isn't present" );
       
        return;
      }
     
      DHTPlugin  dht_plugin = (DHTPlugin)dht_pi.getPlugin();
     
      if ( dht_plugin.getStatus() != DHTPlugin.STATUS_RUNNING ){
       
        ci.out.println( "\tDHT isn't running yet (disabled or initialising)" );
       
View Full Code Here


    // Proably need to wait for core to be running to make sure dht plugin is fully avail
    AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
      public void azureusCoreRunning(AzureusCore core) {
        PluginManager pm = core.getPluginManager();
        connection_manager = PluginInitializer.getDefaultInterface().getConnectionManager();
        PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);
        if (dht_pi != null) {
          dhtPlugin = (DHTPlugin) dht_pi.getPlugin();
        }
      }
    });
  }
View Full Code Here

                  }else{
                   
                    torrent.setAdditionalListProperty( "httpseeds", webseeds );
                  }
     
                  PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(ExternalSeedPlugin.class);
                 
                  if ( pi != null ){
                   
                    ExternalSeedPlugin ext_seed_plugin = (ExternalSeedPlugin)pi.getPlugin();
                   
                    ext_seed_plugin.downloadChanged( PluginCoreUtils.wrap( dms[0] ));
                  }
           
                }catch (Throwable e){
View Full Code Here

  public MainStatusBar() {
    numberFormat = NumberFormat.getInstance();
    // Proably need to wait for core to be running to make sure dht plugin is fully avail
    AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
      public void azureusCoreRunning(AzureusCore core) {
        PluginManager pm = core.getPluginManager();
        connection_manager = PluginInitializer.getDefaultInterface().getConnectionManager();
        PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);
        if (dht_pi != null) {
          dhtPlugin = (DHTPlugin) dht_pi.getPlugin();
        }
      }
    });
View Full Code Here

                     
                      break;
                    }
                   
                    try{
                      DistributedDatabaseContact ddb_contact = ddb.importContact( contact.getAddress());
                     
                      if ( tryTest( bt_tester, ddb_contact )){
                       
                        synchronized( ok ){
                         
                          ok[0]++;
                        }
                      }
                    }catch( Throwable e ){
                     
                      listener.logError( "Contact import for " + contact.getName() + " failed", e );
                    }
                  }
                }finally{
                 
                  sem.release();
                }
              }
            }.start();
          }
         
          for (int i=0;i<num_threads;i++){
           
            sem.reserve();
          }
         
          listener.log( "Searching complete, " + ok[0] + " targets found" );
        }
      }else{
       
        String[]  bits = test_address.split( ":" );
       
        if ( bits.length != 2 ){
         
          log( "Invalid address - use <host>:<port> " );
         
          return( bt_tester );
        }
       
        InetSocketAddress address = new InetSocketAddress( bits[0].trim(), Integer.parseInt( bits[1].trim()));
        
        DistributedDatabaseContact contact = ddb.importContact( address );

        tryTest( bt_tester, contact );
      }
    }catch( Throwable e ){
     
View Full Code Here

            continue;
          }
        }
       
        DistributedDatabaseContact  contact;
        boolean            live_contact;
       
        try{
          potential_contacts_mon.enter();
         
          // System.out.println( "rem=" + remaining + ",pot=" + potential_contacts.size() + ",out=" + outstanding[0] );
         
          if ( potential_contacts.size() == 0 ){
           
            if ( outstanding[0] == 0 ){
           
              break;
             
            }else{
             
              continue;
            }
          }else{
         
            Object[]  entry = (Object[])potential_contacts.remove(0);
           
            live_contact   = ((Boolean)entry[0]).booleanValue();
            contact     = (DistributedDatabaseContact)entry[1];
          }
         
        }finally{
         
          potential_contacts_mon.exit();
        }
         
        // System.out.println( "magnetDownload: " + contact.getName() + ", live = " + live_contact );
       
        if ( !live_contact ){
         
          listener.reportActivity( getMessageText( "report.tunnel", contact.getName()));

          contact.openTunnel();
        }
       
        try{
          listener.reportActivity( getMessageText( "report.downloading", contact.getName()));
         
          DistributedDatabaseValue  value =
            contact.read(
                new DistributedDatabaseProgressListener()
                {
                  public void
                  reportSize(
                    long  size )
                  {
                    listener.reportSize( size );
                  }
                  public void
                  reportActivity(
                    String  str )
                  {
                    listener.reportActivity( str );
                  }
                 
                  public void
                  reportCompleteness(
                    int    percent )
                  {
                    listener.reportCompleteness( percent );
                  }
                },
                db.getStandardTransferType( DistributedDatabaseTransferType.ST_TORRENT ),
                db.createKey ( hash , "Torrent download content for '" + ByteFormatter.encodeString( hash ) + "'"),
                timeout );
                   
          if ( value != null ){
           
              // let's verify the torrent
           
            byte[]  data = (byte[])value.getValue(byte[].class);

            try{
              TOTorrent torrent = TOTorrentFactory.deserialiseFromBEncodedByteArray( data );
             
              if ( Arrays.equals( hash, torrent.getHash())){
             
                listener.reportContributor( contact.getAddress());
           
                return( data );
               
              }else{
               
View Full Code Here

             
              final int[]      done = {0};
             
              for (int i=0;i<ddb_contacts.size();i++){
               
                final DistributedDatabaseContact c = ddb_contacts.get( i );
                               
                new AEThread2( "RCM:rems", true )
                {
                  public void
                  run()
View Full Code Here

      // prevents someone without the hash from downloading the torrent
   
    try{
      byte[]  search_key = ((DDBaseKeyImpl)key).getBytes();
     
      Download   download = null;
       
      PluginInterface pi = PluginInitializer.getDefaultInterface();
                 
      String  search_sha1 = pi.getUtilities().getFormatters().encodeBytesToString( search_key );
     
      if ( ta_sha1 == null ){
       
        ta_sha1 = pi.getTorrentManager().getPluginAttribute( "DDBaseTTTorrent::sha1");
      }
       
        // gotta look for the sha1(hash)
     
      Download[]  downloads = pi.getDownloadManager().getDownloads();
     
      for (int i=0;i<downloads.length;i++){
       
        Download  dl = downloads[i];
       
        if ( dl.getTorrent() == null ){
         
          continue;
        }
       
        String  sha1 = dl.getAttribute( ta_sha1 );
       
        if ( sha1 == null ){
         
          sha1 = pi.getUtilities().getFormatters().encodeBytesToString(
                new SHA1Simple().calculateHash( dl.getTorrent().getHash()));
         
          dl.setAttribute( ta_sha1, sha1 );
        }
       
        if ( sha1.equals( search_sha1 )){
         
          download  = dl;
                   
          break;
        }
      }
       
      if ( download == null ){
       
        synchronized( this ){
         
          if ( external_downloads != null ){
           
            for (int i=0;i<external_downloads.size();i++){
             
              Download  dl = (Download)external_downloads.get(i);
             
              if ( dl.getTorrent() == null ){
               
                continue;
              }
             
              String  sha1 = dl.getAttribute( ta_sha1 );
             
              if ( sha1 == null ){
               
                sha1 = pi.getUtilities().getFormatters().encodeBytesToString(
                      new SHA1Simple().calculateHash( dl.getTorrent().getHash()));
               
                dl.setAttribute( ta_sha1, sha1 );
              }
             
              if ( sha1.equals( search_sha1 )){
               
                download  = dl;
View Full Code Here

      ShareItem  item = (ShareItem)items.get(i);
       
        try{
        Torrent  t = item.getTorrent();
                  
        Download  download = dm.getDownload( t );
       
        if ( download == null ){
                   
          continue;
        }
       
        int  dl_state = download.getState();
       
        if (   dl_state == Download.ST_ERROR ){
         
        }else if ( dl_state != Download.ST_STOPPED ){
         
View Full Code Here

          try{
            Torrent  t = item.getTorrent();
           
            TrackerTorrent  tracker_torrent = tracker.getTorrent( t );
           
            Download  download = dm.getDownload( t );
           
            if ( tracker_torrent == null || download == null ){
                             
              continue;
            }
           
            int  dl_state = download.getState();
           
            if (   dl_state == Download.ST_ERROR ){
             
            }else if ( dl_state != Download.ST_STOPPED ){
             
              if ( do_stop ){
               
                try{
                  download.stop();
                }catch( Throwable e ){
                }
               
                try{
                  tracker_torrent.stop();
                }catch( Throwable e ){
                }
              }
             
            }else{
             
              if ( !do_stop ){
               
                try{
                  download.restart();
                }catch( Throwable e ){
                }
               
                try{
                  tracker_torrent.start();
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.ddb.DistributedDatabaseContact

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.