Examples of PeerManager


Examples of org.gudy.azureus2.plugins.peers.PeerManager

  }
 
  public int
  getSeedCount()
  {
    PeerManager  pm = download.getPeerManager();
       
    if ( pm != null ){
     
      return( pm.getStats().getConnectedSeeds());
    }
   
    return( 0 );
  }
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

  }
 
  public int
  getNonSeedCount()
  {
    PeerManager  pm = download.getPeerManager();
   
    if ( pm != null ){
     
      return( pm.getStats().getConnectedLeechers());
    }
   
    return( 0 );
  }
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

        // if the peer manager's changed then we always go inactive for a period to wait for
        // download status to stabilise a bit
     
      peer_manager_change_time  = now;
     
      PeerManager existing_manager = current_manager;
     
      if ( current_manager != null ){
       
        current_manager.removeListener( this );
      }
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

     
      for (int i=0;i<downloads.size();i++){
       
        Download  download = (Download)downloads.get(i);
       
        PeerManager pm = download.getPeerManager();
       
        if ( pm == null ){
         
          continue;
        }
       
        Peer[] existing_peers = pm.getPeers( ip.getHostAddress());
     
        boolean  connected = false;
       
        for (int j=0;j<existing_peers.length;j++){
         
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

 
  protected void
  trackPeers(
    final Download    download )
  {
    PeerManager pm = download.getPeerManager();
   
      // not running
   
    if ( pm == null ){
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

  {
    log( "Not tracking peers for " + download.getName());
   
    download.removePeerListener( this );
   
    PeerManager pm = download.getPeerManager();
   
    if ( pm != null ){

      Peer[] peers = pm.getPeers();
     
      for (int i=0;i<peers.length;i++){
       
        Peer  peer = peers[i];
       
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

     
      while( it.hasNext()){
       
        Download download = (Download)it.next();
       
        PeerManager pm = download.getPeerManager();
       
        if ( pm != null ){
         
          Peer[] peers = pm.getPeers();
         
          for (int i=0;i<peers.length;i++){
           
            trackPeer( download, peers[i] );
          }
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

       
        final long  start = SystemTime.getCurrentTime();
         
          // if we're already connected to > NUM_WANT peers then don't bother with the main announce
       
        PeerManager  pm = dl.getPeerManager();
       
          // don't query if this download already has an active DHT operation
       
        boolean  skip  = isActive( dl ) || reg_type == REG_TYPE_NONE;
       
        if ( skip ){
         
          log( dl, "Deferring announce as activity outstanding" );
        }
       
        RegistrationDetails  registration = (RegistrationDetails)registered_downloads.get( dl );

        if ( registration == null ){
         
          Debug.out( "Inconsistent, registration should be non-null" );
         
          continue;
        }
       
        boolean  derived_only = false;
       
        if ( pm != null && !skip ){
         
          int  con = pm.getStats().getConnectedLeechers() + pm.getStats().getConnectedSeeds();
       
          derived_only = con >= NUM_WANT;
        }
       
        if ( !skip ){
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

               
              }
               
              if ( target.getType() == REG_TYPE_DERIVED && peers_for_announce.size() > 0 ){
               
                PeerManager pm = download.getPeerManager();
               
                if ( pm != null ){
                   
                    // try some limited direct injection
                 
                  List<DownloadAnnounceResultPeer>  temp = new ArrayList<DownloadAnnounceResultPeer>( peers_for_announce );
                 
                  Random rand = new Random();
                 
                  for (int i=0;i<DIRECT_INJECT_PEER_MAX && temp.size() > 0; i++ ){
                   
                    DownloadAnnounceResultPeer peer = temp.remove( rand.nextInt( temp.size()));
                   
                    log( download, "Injecting derived peer " + peer.getAddress() + " into " + download.getName());
                   
                    Map<Object,Object>  user_data = new HashMap<Object,Object>();
                                       
                    user_data.put( Peer.PR_PRIORITY_CONNECTION, new Boolean( true ));

                    pm.addPeer(
                        peer.getAddress(),
                        peer.getPort(),
                        peer.getUDPPort(),
                        peer.getProtocol() == DownloadAnnounceResultPeer.PROTOCOL_CRYPT,
                        user_data );
                  }
                }
              }
             
              if (   download_state == Download.ST_DOWNLOADING ||
                  download_state == Download.ST_SEEDING ){
             
                final DownloadAnnounceResultPeer[]  peers = new DownloadAnnounceResultPeer[peers_for_announce.size()];
               
                peers_for_announce.toArray( peers );
               
                download.setAnnounceResult(
                    new DownloadAnnounceResult()
                    {
                      public Download
                      getDownload()
                      {
                        return( download );
                      }
                                           
                      public int
                      getResponseType()
                      {
                        return( DownloadAnnounceResult.RT_SUCCESS );
                      }
                                         
                      public int
                      getReportedPeerCount()
                      {
                        return( peers.length);
                      }
                         
                      public int
                      getSeedCount()
                      {
                        return( seed_count );
                      }
                     
                      public int
                      getNonSeedCount()
                      {
                        return( leecher_count )
                      }
                     
                      public String
                      getError()
                      {
                        return( null );
                      }
                                           
                      public URL
                      getURL()
                      {
                        return( url_to_report );
                      }
                     
                      public DownloadAnnounceResultPeer[]
                      getPeers()
                      {
                        return( peers );
                      }
                     
                      public long
                      getTimeToWait()
                      {
                        return( retry/1000 );
                      }
                     
                      public Map
                      getExtensions()
                      {
                        return( null );
                      }
                    });
              }
               
                // only inject the scrape result if the torrent is decentralised. If we do this for
                // "normal" torrents then it can have unwanted side-effects, such as stopping the torrent
                // due to ignore rules if there are no downloaders in the DHT - bthub backup, for example,
                // isn't scrapable...
             
                // 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];
                   
View Full Code Here

Examples of org.gudy.azureus2.plugins.peers.PeerManager

   
    boolean  is_complete = download.isComplete();
   
    if ( is_complete ){
     
      PeerManager pm = download.getPeerManager();
           
      if ( pm != null ){
     
        PEPeerManager core_pm = PluginCoreUtils.unwrap( pm );
       
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.