FileDocCategorySizeDatePackage
TRTrackerBTScraperImpl.javaAPI DocAzureus 3.0.3.43993Thu Feb 09 19:43:06 GMT 2006org.gudy.azureus2.core3.tracker.client.impl.bt

TRTrackerBTScraperImpl

public class TRTrackerBTScraperImpl extends Object
author
parg

Fields Summary
protected static TRTrackerBTScraperImpl
singleton
protected static org.gudy.azureus2.core3.util.AEMonitor
class_mon
private TRTrackerScraperImpl
scraper
private TrackerChecker
tracker_checker
Constructors Summary
protected TRTrackerBTScraperImpl(TRTrackerScraperImpl _scraper)

		scraper	= _scraper;
		
		tracker_checker = new TrackerChecker( this );
	
Methods Summary
public static org.gudy.azureus2.core3.tracker.client.impl.bt.TRTrackerBTScraperImplcreate(TRTrackerScraperImpl _scraper)


	  
	
			 
	
		try{
			class_mon.enter();
		
			if ( singleton == null ){
			
				singleton =  new TRTrackerBTScraperImpl( _scraper );
			}
			
			return( singleton );
			
		}finally{
			
			class_mon.exit();
		}
	
protected TRTrackerScraperImplgetScraper()

		return( scraper );
	
public voidremove(org.gudy.azureus2.core3.torrent.TOTorrent torrent)

		tracker_checker.removeHash( torrent );
	
public org.gudy.azureus2.core3.tracker.client.TRTrackerScraperResponsescrape(org.gudy.azureus2.core3.torrent.TOTorrent torrent, java.net.URL target_url, boolean force)

		if (torrent == null){
			
			return null;
		}

		if ( force ){
			
			tracker_checker.syncUpdate( torrent, target_url );
		}
		
		TRTrackerScraperResponse	res = tracker_checker.getHashData( torrent, target_url );
		
		// System.out.println( "scrape: " + torrent + " -> " + (res==null?"null":""+res.getSeeds()));
		
		return( res );
	
public org.gudy.azureus2.core3.tracker.client.TRTrackerScraperResponsescrape(org.gudy.azureus2.core3.tracker.client.TRTrackerAnnouncer tracker_client)

		TRTrackerScraperResponse	res = tracker_checker.getHashData( tracker_client );
		
		// System.out.println( "scrape: " + tracker_client + " -> " + (res==null?"null":""+res.getSeeds()));
		
		return( res );
	
public voidsetScrape(org.gudy.azureus2.core3.torrent.TOTorrent torrent, java.net.URL url, org.gudy.azureus2.plugins.download.DownloadScrapeResult result)

		if ( torrent != null && result != null ){
			
			TRTrackerScraperResponseImpl resp =	tracker_checker.getHashData( torrent, url );
			
				// only override details if underlying scrape is failing
			
			if ( resp != null && resp.getStatus() == TRTrackerScraperResponse.ST_ERROR ){
				
				resp.setSeedsPeers( result.getSeedCount(), result.getNonSeedCount());
			
				resp.setScrapeStartTime( result.getScrapeStartTime());
				
					// leave nextScrapeStartTime alone as we still want the existing
					// scraping mechanism to kick in and check the torrent's tracker
				
				resp.setStatus( 
						result.getResponseType()==DownloadScrapeResult.RT_SUCCESS?
								TRTrackerScraperResponse.ST_ONLINE:
								TRTrackerScraperResponse.ST_ERROR,
						result.getStatus() + " (" + result.getURL() + ")"); 
			
				scraper.scrapeReceived( resp );
			}
		}