Package com.aelitis.azureus.core.tracker

Examples of com.aelitis.azureus.core.tracker.TrackerPeerSource


    boolean  found_tracker  = false;
    boolean  update_ok     = false;
   
    for ( Object o: sources ){
 
      TrackerPeerSource ps = (TrackerPeerSource)o;
   
      if ( ps.getType() == TrackerPeerSource.TP_TRACKER ){
       
        found_tracker = true;
      }
     
      int  state = ps.getStatus();
           
      if (   (   state == TrackerPeerSource.ST_ONLINE ||
            state == TrackerPeerSource.ST_QUEUED ||
            state == TrackerPeerSource.ST_ERROR ) &&
          !ps.isUpdating() &&
          ps.canManuallyUpdate()){
       
        update_ok = true;
       
        break;
      }
    }
   
    if ( found_tracker ){
      final MenuItem update_item = new MenuItem( menu, SWT.PUSH);
 
      Messages.setLanguageText(update_item, "GeneralView.label.trackerurlupdate");
     
      update_item.setEnabled( update_ok );
     
      update_item.addListener(
        SWT.Selection,
        new TableSelectedRowsListener(tv)
        {
          public void
          run(
            TableRowCore row )
          {
            for ( Object o: sources ){
             
              TrackerPeerSource ps = (TrackerPeerSource)o;
 
              if ( ps.canManuallyUpdate()){
               
                ps.manualUpdate();
              }
            }
          }
        });
     
View Full Code Here


     
      url_strs[i] = urls[i].toExternalForm();
    }
   
    return(
      new TrackerPeerSource()
      {
        private StatusSummary    _summary;
        private boolean        enabled;
        private long        fixup_time;
       
View Full Code Here

             
              continue;
            }
           
            tps.add(
              new TrackerPeerSource()
              {
                private TrackerPeerSource _delegate;
               
                 private TRTrackerAnnouncer    ta;
                  private long          ta_fixup;

                  private long    last_scrape_time;
                  private int[]    last_scrape;
                 
                private TrackerPeerSource
                fixup()
                {
                  long  now = SystemTime.getMonotonousTime();
                 
                  if ( now - ta_fixup > 1000 ){
                   
                    TRTrackerAnnouncer current_ta = getTrackerClient();
                   
                    if ( current_ta == ta ){
                     
                      if ( current_ta != null && _delegate == null ){
                       
                        _delegate = current_ta.getTrackerPeerSource( set );
                      }
                    }else{
                     
                      if ( current_ta == null ){
                       
                        _delegate = null;
                       
                      }else{
                       
                        _delegate = current_ta.getTrackerPeerSource( set );
                      }
                     
                      ta = current_ta;
                    }
                   
                    ta_fixup  = now;
                  }
                 
                  return( _delegate );
                }
               
                protected int[]
                getScrape()
                {
                  long now = SystemTime.getMonotonousTime();
                 
                  if ( now - last_scrape_time > 30*1000 || last_scrape == null ){

                    TRTrackerScraper  scraper = globalManager.getTrackerScraper();

                    int  max_peers = -1;
                    int max_seeds = -1;
                   
                    for ( URL u: urls ){
                   
                      TRTrackerScraperResponse resp = scraper.peekScrape(torrent, u );
                     
                      if ( resp != null ){
                       
                        if ( !resp.isDHTBackup()){
                         
                          int peers = resp.getPeers();
                          int seeds = resp.getSeeds();
                         
                          if ( peers > max_peers ){
                         
                            max_peers = peers;
                          }
                         
                          if ( seeds > max_seeds ){
                           
                            max_seeds = seeds;
                          }
                        }
                      }
                    }
                   
                    last_scrape = new int[]{ max_seeds, max_peers };
                   
                    last_scrape_time = now;
                  }
                 
                  return( last_scrape );
                }
               
                public int
                getType()
                {
                  return( TrackerPeerSource.TP_TRACKER );
                }
               
                public String
                getName()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( urls[0].toExternalForm());
                  }
                 
                  return( delegate.getName());
                }
               
                public int
                getStatus()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( ST_STOPPED );
                  }
                 
                  return( delegate.getStatus());
                }
               
                public String
                getStatusString()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( null );
                  }
                 
                  return( delegate.getStatusString());
                }
               
                public int
                getSeedCount()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( getScrape()[0] );
                  }
                 
                  int seeds = delegate.getSeedCount();
                 
                  if ( seeds < 0 ){
                   
                    seeds = getScrape()[0];
                  }
                 
                  return( seeds );
                }
               
                public int
                getLeecherCount()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( getScrape()[1] );
                  }
                 
                  int leechers = delegate.getLeecherCount();
                 
                  if ( leechers < 0 ){
                   
                    leechers = getScrape()[1];
                  }
                 
                  return( leechers );           
                }
 
                public int
                getPeers()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( -1 );
                  }
                 
                  return( delegate.getPeers());             
                }

                public int
                getInterval()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( -1 );
                  }
                 
                  return( delegate.getInterval());             
                }
               
                public int
                getMinInterval()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( -1 );
                  }
                 
                  return( delegate.getMinInterval());             
                }
               
                public boolean
                isUpdating()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( false );
                  }
                 
                  return( delegate.isUpdating());             
                }
               
                public int
                getSecondsToUpdate()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( -1 );
                  }
                 
                  return( delegate.getSecondsToUpdate());
                }
               
                public boolean
                canManuallyUpdate()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                   
                    return( false );
                  }
                 
                  return( delegate.canManuallyUpdate());
                }
               
                public void
                manualUpdate()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate != null ){
                   
                    delegate.manualUpdate();
                  }
                }
              });
          }
         
            // cache peer source
         
          tps.add(
              new TrackerPeerSourceAdapter()
              {
                private TrackerPeerSource _delegate;
               
                 private TRTrackerAnnouncer    ta;
                 private boolean          enabled;
                  private long          ta_fixup;

                private TrackerPeerSource
                fixup()
                {
                  long  now = SystemTime.getMonotonousTime();
                 
                  if ( now - ta_fixup > 1000 ){
                   
                    TRTrackerAnnouncer current_ta = getTrackerClient();
                   
                    if ( current_ta == ta ){
                     
                      if ( current_ta != null && _delegate == null ){
                       
                        _delegate = current_ta.getCacheTrackerPeerSource();
                      }
                    }else{
                     
                      if ( current_ta == null ){
                       
                        _delegate = null;
                       
                      }else{
                       
                        _delegate = current_ta.getCacheTrackerPeerSource();
                      }
                     
                      ta = current_ta;
                    }
                   
                    enabled = controller.isPeerSourceEnabled( PEPeerSource.PS_BT_TRACKER );
                   
                    ta_fixup  = now;
                  }
                 
                  return( _delegate );
                }
               
                public int
                getType()
                {
                  return( TrackerPeerSource.TP_TRACKER );
                }
               
                public String
                getName()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null ){
                 
                    return( MessageText.getString( "tps.tracker.cache" ));
                  }
                 
                  return( delegate.getName());
                }
               
                public int
                getStatus()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( !enabled ){
                   
                    return( ST_DISABLED );
                  }
                 
                  if ( delegate == null ){
                 
                    return( ST_STOPPED );
                  }
                 
                  return( ST_ONLINE );
                }
 
                public int
                getPeers()
                {
                  TrackerPeerSource delegate = fixup();
                 
                  if ( delegate == null || !enabled ){
                 
                    return( -1 );
                  }
                 
                  return( delegate.getPeers());             
                }
              });
          }
       
            // http seeds
         
          try{
            ExternalSeedPlugin esp = DownloadManagerController.getExternalSeedPlugin();
           
            if ( esp != null ){
                         
            tps.add( esp.getTrackerPeerSource( PluginCoreUtils.wrap( this ) ));
           }
          }catch( Throwable e ){
          }
         
            // dht
         
          try{
           
          PluginInterface dht_pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(DHTTrackerPlugin.class);
 
              if ( dht_pi != null ){
               
                tps.add(((DHTTrackerPlugin)dht_pi.getPlugin()).getTrackerPeerSource( PluginCoreUtils.wrap( this )));
              }
        }catch( Throwable e ){
          }
         
          // LAN
       
        try{
         
          PluginInterface lt_pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(LocalTrackerPlugin.class);
 
          if ( lt_pi != null ){
           
                tps.add(((LocalTrackerPlugin)lt_pi.getPlugin()).getTrackerPeerSource( PluginCoreUtils.wrap( this )));
         
          }
         
        }catch( Throwable e ){
         
        }
       
          // Plugin
       
        try{
       
          tps.add(((DownloadImpl)PluginCoreUtils.wrap( this )).getTrackerPeerSource());
         
        }catch( Throwable e ){
         
        }
       
          // PEX...
       
        tps.add(
          new TrackerPeerSourceAdapter()
          {
            private PEPeerManager    _pm;
            private TrackerPeerSource  _delegate;
           
            private TrackerPeerSource
            fixup()
            {
              PEPeerManager pm = getPeerManager();
             
              if ( pm == null ){
               
                _delegate   = null;
                _pm      = null;
               
              }else if ( pm != _pm ){
               
                _pm  = pm;
               
                _delegate = pm.getTrackerPeerSource();
              }
             
              return( _delegate );
            }
           
            public int
            getType()
            {
              return( TP_PEX );
            }
           
            public int
            getStatus()
            {
              TrackerPeerSource delegate = fixup();
             
              if ( delegate == null ){
               
                return( ST_STOPPED );
               
              }else{
               
                return( delegate.getStatus());
              }
            }
           
            public String
            getName()
            {
              TrackerPeerSource delegate = fixup();
             
              if ( delegate == null ){
               
                return( "" );
               
              }else{
               
                return( delegate.getName());
             
            }
           
            public int
            getPeers()
            {
              TrackerPeerSource delegate = fixup();
             
              if ( delegate == null ){
               
                return( -1 );
               
              }else{
               
                return( delegate.getPeers());
             
            }
          });
       
          // incoming
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    int value = (ps==null)?TrackerPeerSource.TP_UNKNOWN:ps.getType();

    if (!cell.setSortValue(value) && cell.isValid()){
   
      return;
    }
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    int status;
   
    if ( ps == null ){
     
      status = TrackerPeerSource.ST_UNKNOWN;
     
    }else{
     
      if ( ps.isUpdating()){
       
        status = TrackerPeerSource.ST_UPDATING;
       
      }else{
       
        status = ps.getStatus();
      }
    }

    String str = js_resources[status];
   
    if ( status == TrackerPeerSource.ST_ERROR ){
     
      String extra = ps.getStatusString();
   
      if ( extra != null ){
       
        str += ": " + extra;
      }
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    String name = (ps==null)?"":ps.getName();

    if (!cell.setSortValue(name) && cell.isValid()){
   
      return;
    }
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    int value = (ps==null)?-1:ps.getPeers();

    if (!cell.setSortValue(value) && cell.isValid()){
   
      return;
    }
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    int value = (ps==null)?-1:ps.getSeedCount();

    if (!cell.setSortValue(value) && cell.isValid()){
   
      return;
    }
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    int secs;
   
    if ( ps == null ){
     
      secs = -1;
     
    }else{
     
      int  state = ps.getStatus();
     
      if (   (   state == TrackerPeerSource.ST_ONLINE ||
            state == TrackerPeerSource.ST_ERROR ) &&
          !ps.isUpdating()){
       
        secs = ps.getSecondsToUpdate();
       
      }else{
       
        secs = -1;
      }
View Full Code Here

  public void
  refresh(
    TableCell cell )
  {
    TrackerPeerSource ps = (TrackerPeerSource)cell.getDataSource();
   
    int value = (ps==null)?-1:ps.getLeecherCount();

    if (!cell.setSortValue(value) && cell.isValid()){
   
      return;
    }
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.tracker.TrackerPeerSource

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.