Package org.gudy.azureus2.plugins.download

Examples of org.gudy.azureus2.plugins.download.DownloadScrapeResult


                     
                      register_reason = "tracker available (announce: " + result.getURL() + ")";               
                    }
                  }else{
                   
                    DownloadScrapeResult result = download.getLastScrapeResult();
                   
                    if result == null ||
                        result.getResponseType() == DownloadScrapeResult.RT_ERROR ||
                        TorrentUtils.isDecentralised(result.getURL())){
                     
                      register_type  = REG_TYPE_FULL;
                     
                      register_reason = "tracker unavailable (scrape)";
                     
                    }else{
                     
                      register_reason = "tracker available (scrape: " + result.getURL() + ")";               
                    }
                  }
                 
                  if ( register_type != REG_TYPE_FULL && track_limited_when_online.getValue()){
                   
                    Boolean  existing = (Boolean)limited_online_tracking.get( download );
                   
                    boolean  track_it = false;
                   
                    if ( existing != null ){
                     
                      track_it = existing.booleanValue();
                     
                    }else{
                     
                      DownloadScrapeResult result = download.getLastScrapeResult();
                     
                      if result != null&&
                          result.getResponseType() == DownloadScrapeResult.RT_SUCCESS ){
                       
                        int  seeds     = result.getSeedCount();
                        int leechers  = result.getNonSeedCount();
                       
                        int  swarm_size = seeds + leechers;
                                               
                        if ( swarm_size <= LIMITED_TRACK_SIZE ){
                         
View Full Code Here


        announce.getResponseType() != DownloadAnnounceResult.RT_SUCCESS ){     
     
      return( -98 );
    }
   
    DownloadScrapeResult scrape = download.getLastScrapeResult();
   
    if (   scrape == null ||
        scrape.getResponseType() != DownloadScrapeResult.RT_SUCCESS ){
     
      return( -97 );
    }
   
    int leechers   = scrape.getNonSeedCount();
    // int seeds    = scrape.getSeedCount();
   
    int  total = leechers;  // parg - changed to just use leecher count rather than seeds+leechers
   
    if ( total >= 2000 ){
View Full Code Here

                // hmm, ok, try being a bit more relaxed about this, inject the scrape if
                // we have any peers.
                               
              boolean  inject_scrape = leecher_count > 0;
             
              DownloadScrapeResult result = download.getLastScrapeResult();
                               
              if result == null ||
                  result.getResponseType() == DownloadScrapeResult.RT_ERROR ){                 
 
              }else{
             
                  // if the currently reported values are the same as the
                  // ones we previously injected then overwrite them
                  // note that we can't test the URL to see if we originated
                  // the scrape values as this gets replaced when a normal
                  // scrape fails :(
                 
                int[]  prev = (int[])scrape_injection_map.get( download );
                 
                if (   prev != null &&
                    prev[0] == result.getSeedCount() &&
                    prev[1] == result.getNonSeedCount()){
                                           
                  inject_scrape  = true;
                }
              }
             
              if ( torrent.isDecentralised() || inject_scrape ){
               
               
                  // make sure that the injected scrape values are consistent
                  // with our currently connected peers
               
                PeerManager  pm = download.getPeerManager();
               
                int  local_seeds   = 0;
                int  local_leechers   = 0;
               
                if ( pm != null ){
                 
                  Peer[]  dl_peers = pm.getPeers();
                 
                  for (int i=0;i<dl_peers.length;i++){
                   
                    Peer  dl_peer = dl_peers[i];
                   
                    if ( dl_peer.getPercentDoneInThousandNotation() == 1000 ){
                     
                      local_seeds++;
                     
                    }else{
                      local_leechers++;
                    }
                  }             
                }
               
                final int f_adj_seeds     = Math.max( seed_count, local_seeds );
                final int f_adj_leechers  = Math.max( leecher_count, local_leechers );
               
                scrape_injection_map.put( download, new int[]{ f_adj_seeds, f_adj_leechers });
 
                try{
                  this_mon.enter();
               
                  int[] run_data = running_downloads.get( download );
                 
                  if ( run_data == null ){
                   
                    run_data = run_data_cache.get( download );
                  }
                 
                  if ( run_data != null ){

                    run_data[1] = f_adj_seeds;
                    run_data[2= f_adj_leechers;
                  }
                }finally{
                 
                  this_mon.exit();
                }
               
                download.setScrapeResult(
                  new DownloadScrapeResult()
                  {
                    public Download
                    getDownload()
                    {
                      return( download );
View Full Code Here

            if ( interesting_pub_max > 0 && interesting_published > interesting_pub_max ){
             
              continue;
            }
           
            DownloadScrapeResult  scrape = (DownloadScrapeResult)scrapes.get( download );
           
            if ( scrape == null ){
             
                // catch it next time round
             
              continue;
            }
           
            if ( scrape.getSeedCount() + scrape.getNonSeedCount() > NUM_WANT ){
             
              continue;
            }
          }
         
          long  target = ((Long)interesting_downloads.get( download )).longValue();
         
          long check_period = TorrentUtils.isDecentralised( torrent.getAnnounceURL())?INTERESTING_DHT_CHECK_PERIOD:INTERESTING_CHECK_PERIOD;
         
          if ( target <= now ){
           
            ready_download        = download;
            ready_download_next_check   = now + check_period;
           
            interesting_downloads.put( download, new Long( ready_download_next_check ));
           
          }else if ( target - now > check_period ){
           
            interesting_downloads.put( download, new Long( now + (target%check_period)));
          }
        }
      }
     
    }finally{
     
      this_mon.exit();
    }
   
    if ( ready_download != null ){
     
      final Download  f_ready_download = ready_download;
     
      final Torrent torrent = ready_download.getTorrent();
     
      if ( dht.isDiversified( torrent.getHash())){
       
        // System.out.println( "presence query for " + f_ready_download.getName() + "-> diversified pre start" );

        try{
          this_mon.enter();

          interesting_downloads.remove( f_ready_download );
         
        }finally{
         
          this_mon.exit();
        }
      }else{
     
        //System.out.println( "presence query for " + ready_download.getName());
       
        final long start     = now;
        final long f_next_check = ready_download_next_check;
       
        dht.gettorrent.getHash(),
              "Presence query for '" + ready_download.getName() + "'",
              (byte)0,
              INTERESTING_AVAIL_MAX,
              ANNOUNCE_TIMEOUT,
              false, false,
              new DHTPluginOperationListener()
              {
                private boolean diversified;
                private int   leechers = 0;
                private int   seeds   = 0;
               
                public void
                diversified()
                {
                  diversified  = true;
                }
               
                public void
                starts(
                  byte[]         key )
                {
                }
               
                public void
                valueRead(
                  DHTPluginContact  originator,
                  DHTPluginValue    value )
                {
                  if (( value.getFlags() & DHTPlugin.FLAG_DOWNLOADING ) == 1 ){

                    leechers++;
                   
                  }else{
                   
                    seeds++;
                  }
                }
               
                public void
                valueWritten(
                  DHTPluginContact  target,
                  DHTPluginValue    value )
                {
                }
               
                public void
                complete(
                  byte[]  key,
                  boolean  timeout_occurred )
                {
                  // System.out.println( "    presence query for " + f_ready_download.getName() + "->" + total + "/div = " + diversified );
 
                  int  total = leechers + seeds;
                 
                  log( torrent,
                      "Presence query: availability="+
                      (total==INTERESTING_AVAIL_MAX?(INTERESTING_AVAIL_MAX+"+"):(total+"")) + ",div=" + diversified +
                      " (elapsed=" + TimeFormatter.formatColonMillis(SystemTime.getCurrentTime() - start) + ")");
                     
                  if ( diversified ){
                   
                    try{
                      this_mon.enter();
 
                      interesting_downloads.remove( f_ready_download );
                     
                    }finally{
                     
                      this_mon.exit();
                    }
                   
                  }else if ( total < INTERESTING_AVAIL_MAX ){
                   
                      // once we're registered we don't need to process this download any
                      // more unless it goes active and then inactive again
                   
                    try{
                      this_mon.enter();
 
                      interesting_downloads.remove( f_ready_download );
                     
                    }finally{
                     
                      this_mon.exit();
                    }
                   
                    interesting_published++;
                   
                    if ( !disable_put ){
                     
                      dht.put(
                        torrent.getHash(),
                        "Presence store '" + f_ready_download.getName() + "'",
                        "0".getBytes()// port 0, no connections
                        (byte)0,
                        new DHTPluginOperationListener()
                        {
                          public void
                          diversified()
                          {
                          }
                         
                          public void
                          starts(
                            byte[]         key )
                          {
                          }
                         
                          public void
                          valueRead(
                            DHTPluginContact  originator,
                            DHTPluginValue    value )
                          {
                          }
                         
                          public void
                          valueWritten(
                            DHTPluginContact  target,
                            DHTPluginValue    value )
                          {
                          }
                         
                          public void
                          complete(
                            byte[]  key,
                            boolean  timeout_occurred )
                          {
                          }
                        });
                    }
                  }
                 
                 
                  try{
                    this_mon.enter();
                 
                    int[] run_data = running_downloads.get( f_ready_download );
                   
                    if ( run_data == null ){
                     
                      run_data = run_data_cache.get( f_ready_download );
                    }
                   
                    if ( run_data != null ){

                      if ( total < INTERESTING_AVAIL_MAX ){
                     
                        run_data[1] = seeds;
                        run_data[2= leechers;
                        run_data[3] = total;
                       
                      }else{
                       
                        run_data[1] = Math.max( run_data[1], seeds );
                        run_data[2] = Math.max( run_data[2], leechers );
                      }
                    }
                  }finally{
                   
                    this_mon.exit();
                  }
                 
                  f_ready_download.setScrapeResult(
                    new DownloadScrapeResult()
                    {
                      public Download
                      getDownload()
                      {
                        return( null );
View Full Code Here

        });

    sem.reserve();
   
    return(
        new DownloadScrapeResult()
        {
          public Download
          getDownload()
          {
            return( null );
View Full Code Here

                  if ( x.getStatus() == TRTrackerAnnouncerResponse.ST_REPORTED_ERROR ){
                    value = new Long(2);
                  }
                }
              }else{
                DownloadScrapeResult x = download.getLastScrapeResult();
                if ( x != null ){
                  if ( x.getResponseType() == DownloadScrapeResult.RT_ERROR ){
                    String status = x.getStatus();
                   
                    if ( status != null && status.length() > 0 ){
                   
                      value = new Long(2);
                    }
                  }
                }
              }
            }
          }else if ( field.equals( "errorString" )){ 
            String str = download.getErrorStateDetails();
           
            if ( str != null && str.length() > 0 ){
              value = str;
            }else{
              value = "";
              TRTrackerAnnouncer tracker_client = core_download.getTrackerClient();
             
              if ( tracker_client != null ){
                TRTrackerAnnouncerResponse x = tracker_client.getBestAnnouncer().getLastResponse();
                if ( x != null ){
                  if ( x.getStatus() == TRTrackerAnnouncerResponse.ST_REPORTED_ERROR ){
                    value = x.getStatusString();
                  }
                }
              }else{
                DownloadScrapeResult x = download.getLastScrapeResult();
                if ( x != null ){
                  if ( x.getResponseType() == DownloadScrapeResult.RT_ERROR ){
                    value = x.getStatus();
                  }
                }
              }
            }
          }else if ( field.equals( "eta" )){
              // infinite -> 215784000
            long eta_secs = stats.getETASecs();
           
            eta_secs = Math.min( eta_secs, 215784000 );
           
            value = new Long( eta_secs );
          }else if ( field.equals( "hashString" )){ 
            value = ByteFormatter.encodeString( t.getHash());
          }else if ( field.equals( "haveUnchecked" )){ 
            value = ZERO;
          }else if ( field.equals( "haveValid" )){
            value = new Long( stats.getDownloaded());
          }else if ( field.equals( "id" )){   
            value = new Long( getID( download ));
          }else if ( field.equals( "trackerSeeds" )){
            DownloadScrapeResult scrape = download.getLastScrapeResult();
            value = new Long( scrape==null?0:scrape.getSeedCount());
          }else if ( field.equals( "trackerLeechers" )){
            DownloadScrapeResult scrape = download.getLastScrapeResult();
            value = new Long( scrape==null?0:scrape.getNonSeedCount());
          }else if ( field.equals( "leechers" )){ 
            if ( pm == null ){
              value = new Long(0);
            }else{
              value = new Long( pm.getNbPeers());
View Full Code Here

                      try{
                        installer.install(
                          sps.toArray( new InstallablePlugin[ sps.size()]),
                          false,
                          properties,
                          new PluginInstallationListener() {
   
                            public void
                            completed()
                            {
                            }
View Full Code Here

              final String  config_key = "recommended.processed." + rp_id;
             
              if ( !plugin_config.getPluginBooleanParameter( config_key, false )){
               
                try{
                  final PluginInstaller installer = plugin_interface.getPluginManager().getPluginInstaller();
                 
                  StandardPlugin[]  sps = installer.getStandardPlugins();
                 
                  for (int j=0;j<sps.length;j++){
                   
                    final StandardPlugin  sp = sps[j];
                   
                    if ( sp.getId().equals( rp_id )){
                   
                      found_one = true;
                     
                      checker.getCheckInstance().addListener(
                        new UpdateCheckInstanceListener()
                        {
                          public void
                          cancelled(
                            UpdateCheckInstance    instance )
                          {                         
                          }
                         
                          public void
                          complete(
                            UpdateCheckInstance    instance )
                          {
                            if ( instance.getUpdates().length == 0 ){
                             
                              installRecommendedPlugin( installer, sp );
                             
                              plugin_config.setPluginParameter( config_key, true );
                            }
                          }
                        });
                     
                      break;
                    }
                  }
                 
                }catch( Throwable e ){
                 
                }
              }
             
              if ( found_one ){
               
                break;
              }
            }
           
            if ( !found_one ){
             
              Set<String>  auto_install = vc.getAutoInstallPluginIDs();
             
              final List<String>  to_do = new ArrayList<String>();
             
              for ( String pid: auto_install ){
               
                if ( plugin_manager.getPluginInterfaceByID( pid, false ) == null ){
                 
                  to_do.add( pid );
                }
              }
             
              if ( to_do.size() > 0 ){
               
                new AEThread2( "pup:autoinst" )
                {
                  public void
                  run()
                  {   
                    try{
                      Thread.sleep( 120*1000 );
                     
                    }catch( Throwable e ){
                     
                      Debug.out( e );
                     
                      return;
                    }
                   
                    UpdateManager update_manager = plugin_interface.getUpdateManager();
                   
                    final List<UpdateCheckInstance>  l_instances = new ArrayList<UpdateCheckInstance>();
                   
                    update_manager.addListener(
                      new UpdateManagerListener()
                      {
                        public void
                        checkInstanceCreated(
                          UpdateCheckInstance  instance )
                        {
                          synchronized( l_instances ){
                           
                            l_instances.add( instance );
                          }
                        }
                      });
                   
                    UpdateCheckInstance[] instances = update_manager.getCheckInstances();
                   
                    l_instances.addAll( Arrays.asList( instances ));
                   
                    long start = SystemTime.getMonotonousTime();
                   
                    while( true ){
                     
                      if ( SystemTime.getMonotonousTime() - start >= 5*60*1000 ){
                       
                        break;
                      }
                     
                      try{
                        Thread.sleep(5000);
                       
                      }catch( Throwable e ){
                       
                        Debug.out( e );
                       
                        return;
                      }
                     
                      if ( l_instances.size() > 0 ){
                     
                        boolean  all_done = true;
                       
                        for ( UpdateCheckInstance instance: l_instances ){
                         
                          if ( !instance.isCompleteOrCancelled()){
                           
                            all_done = false;
                           
                            break;
                          }
                        }
                       
                        if ( all_done ){
                         
                          break;
                        }
                      }
                    }
                   
                    if ( update_manager.getInstallers().length > 0 ){
                     
                      return;
                    }
                   
                    PluginInstaller installer = plugin_interface.getPluginManager().getPluginInstaller();
                   
                    List<InstallablePlugin>  sps = new ArrayList<InstallablePlugin>();
                   
                    for ( String pid: to_do ){
                     
                      try{
                        StandardPlugin sp = installer.getStandardPlugin( pid );
                       
                        if ( sp != null ){
                         
                          log.log( "Auto-installing " + pid );
                         
                          sps.add( sp );
                         
                        }else{
                         
                          log.log( "Standard plugin '" + pid + "' missing" );
                        }
                      }catch( Throwable e ){
                       
                        log.log( "Standard plugin '" + pid + "' missing", e );
                      }
                    } 
                    
                    if ( sps.size() > 0 ){
                     
                      Map<Integer, Object> properties = new HashMap<Integer, Object>();
                 
                      properties.put( UpdateCheckInstance.PT_UI_STYLE, UpdateCheckInstance.PT_UI_STYLE_NONE );
                       
                      properties.put(UpdateCheckInstance.PT_UI_DISABLE_ON_SUCCESS_SLIDEY, true);
 
                      try{
                        installer.install(
                          sps.toArray( new InstallablePlugin[ sps.size()]),
                          false,
                          properties,
                          new PluginInstallationListener() {
   
View Full Code Here

                 
                  StandardPlugin[]  sps = installer.getStandardPlugins();
                 
                  for (int j=0;j<sps.length;j++){
                   
                    final StandardPlugin  sp = sps[j];
                   
                    if ( sp.getId().equals( rp_id )){
                   
                      found_one = true;
                     
                      checker.getCheckInstance().addListener(
                        new UpdateCheckInstanceListener()
                        {
                          public void
                          cancelled(
                            UpdateCheckInstance    instance )
                          {                         
                          }
                         
                          public void
                          complete(
                            UpdateCheckInstance    instance )
                          {
                            if ( instance.getUpdates().length == 0 ){
                             
                              installRecommendedPlugin( installer, sp );
                             
                              plugin_config.setPluginParameter( config_key, true );
                            }
                          }
                        });
                     
                      break;
                    }
                  }
                 
                }catch( Throwable e ){
                 
                }
              }
             
              if ( found_one ){
               
                break;
              }
            }
           
            if ( !found_one ){
             
              Set<String>  auto_install = vc.getAutoInstallPluginIDs();
             
              final List<String>  to_do = new ArrayList<String>();
             
              for ( String pid: auto_install ){
               
                if ( plugin_manager.getPluginInterfaceByID( pid, false ) == null ){
                 
                  to_do.add( pid );
                }
              }
             
              if ( to_do.size() > 0 ){
               
                new AEThread2( "pup:autoinst" )
                {
                  public void
                  run()
                  {   
                    try{
                      Thread.sleep( 120*1000 );
                     
                    }catch( Throwable e ){
                     
                      Debug.out( e );
                     
                      return;
                    }
                   
                    UpdateManager update_manager = plugin_interface.getUpdateManager();
                   
                    final List<UpdateCheckInstance>  l_instances = new ArrayList<UpdateCheckInstance>();
                   
                    update_manager.addListener(
                      new UpdateManagerListener()
                      {
                        public void
                        checkInstanceCreated(
                          UpdateCheckInstance  instance )
                        {
                          synchronized( l_instances ){
                           
                            l_instances.add( instance );
                          }
                        }
                      });
                   
                    UpdateCheckInstance[] instances = update_manager.getCheckInstances();
                   
                    l_instances.addAll( Arrays.asList( instances ));
                   
                    long start = SystemTime.getMonotonousTime();
                   
                    while( true ){
                     
                      if ( SystemTime.getMonotonousTime() - start >= 5*60*1000 ){
                       
                        break;
                      }
                     
                      try{
                        Thread.sleep(5000);
                       
                      }catch( Throwable e ){
                       
                        Debug.out( e );
                       
                        return;
                      }
                     
                      if ( l_instances.size() > 0 ){
                     
                        boolean  all_done = true;
                       
                        for ( UpdateCheckInstance instance: l_instances ){
                         
                          if ( !instance.isCompleteOrCancelled()){
                           
                            all_done = false;
                           
                            break;
                          }
                        }
                       
                        if ( all_done ){
                         
                          break;
                        }
                      }
                    }
                   
                    if ( update_manager.getInstallers().length > 0 ){
                     
                      return;
                    }
                   
                    PluginInstaller installer = plugin_interface.getPluginManager().getPluginInstaller();
                   
                    List<InstallablePlugin>  sps = new ArrayList<InstallablePlugin>();
                   
                    for ( String pid: to_do ){
                     
                      try{
                        StandardPlugin sp = installer.getStandardPlugin( pid );
                       
                        if ( sp != null ){
                         
                          log.log( "Auto-installing " + pid );
                         
View Full Code Here

  public MessageStreamEncoderAdapter( MessageStreamEncoder plug_encoder ) {
    this.plug_encoder = plug_encoder;
  }
 
  public com.aelitis.azureus.core.networkmanager.RawMessage[] encodeMessage( com.aelitis.azureus.core.peermanager.messaging.Message message ) {
    Message plug_msg;
   
    if( message instanceof MessageAdapter ) {  //original message created by plugin, unwrap
      plug_msg = ((MessageAdapter)message).getPluginMessage();
    }
    else {
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.download.DownloadScrapeResult

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.