Examples of DownloadScrapeResult


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

        pw.println"<vuze:size>" + torrent.getSize()+ "</vuze:size>" );
        pw.println"<vuze:assethash>" + hash_str + "</vuze:assethash>" );
                       
        pw.println( "<vuze:downloadurl>" + magnet_url + "</vuze:downloadurl>" );
   
        DownloadScrapeResult scrape = download.getLastScrapeResult();
       
        if ( scrape != null && scrape.getResponseType() == DownloadScrapeResult.RT_SUCCESS ){
         
          pw.println"<vuze:seeds>" + scrape.getSeedCount() + "</vuze:seeds>" );
          pw.println"<vuze:peers>" + scrape.getNonSeedCount() + "</vuze:peers>" );
        }
       
        pw.println( "</item>" );
      }
     
View Full Code Here

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

        url += URLEncoder.encode( arg, "UTF-8" );
     
        pw.println( "<vuze:downloadurl>" + escape( url ) + "</vuze:downloadurl>" );
   
        DownloadScrapeResult scrape = download.getLastScrapeResult();
       
        if ( scrape != null && scrape.getResponseType() == DownloadScrapeResult.RT_SUCCESS ){
         
          pw.println"<vuze:seeds>" + scrape.getSeedCount() + "</vuze:seeds>" );
          pw.println"<vuze:peers>" + scrape.getNonSeedCount() + "</vuze:peers>" );
        }
       
        pw.println( "</item>" );
      }
     
View Full Code Here

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

            }
          });
           
       
        download.setScrapeResult(
          new DownloadScrapeResult()
          {
            public Download
            getDownload()
            {
              return( download );
View Full Code Here

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

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

        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

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

                // 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

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

            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

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

        });

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

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

                  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
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.