Package org.gudy.azureus2.plugins.peers

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


  {
    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

     
      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

       
        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

               
              }
               
              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

   
    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

          });
      }else{
       
          // fix up newly added peers to current peer manager
       
        PeerManager  existing_pm = download.getPeerManager();
       
        if ( existing_pm != null ){
         
          for (int i=0;i<peers.size();i++){
           
View Full Code Here

 
          for (int i=0;i<downloads.length;i++){
           
            Download  download = downloads[i];
           
            PeerManager pm = download.getPeerManager();
           
            if ( pm == null ){
             
              continue;
            }
           
            Peer[]   peers = pm.getPeers();
           
            for (int j=0;j<peers.length;j++){
             
              Peer  p = peers[j];
             
View Full Code Here

                    if ( !testDownload.isForceStart()){
                     
                      testDownload.setForceStart( true );
                    }
                   
                    PeerManager pm = testDownload.getPeerManager();
                   
                    if ( pm != null ){
                     
                      Peer[] peers = pm.getPeers();
                     
                      for ( int i=0;i<peers.length;i++){
                       
                        Peer peer = peers[i];
                       
View Full Code Here

           
            download_ok = true;
           
          }else{
           
            PeerManager pm = download.getPeerManager();
           
            if ( pm != null ){
             
              PeerManagerStats stats = pm.getStats();
             
              int connected_seeds   = stats.getConnectedSeeds();
              int connected_leechers  = stats.getConnectedLeechers();
             
             
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.peers.PeerManager

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.