FileDocCategorySizeDatePackage
TRTrackerDHTScraperImpl.javaAPI DocAzureus 3.0.3.44073Sun Jul 16 03:35:22 BST 2006org.gudy.azureus2.core3.tracker.client.impl.dht

TRTrackerDHTScraperImpl

public class TRTrackerDHTScraperImpl extends Object
author
parg

Fields Summary
protected static TRTrackerDHTScraperImpl
singleton
protected static org.gudy.azureus2.core3.util.AEMonitor
class_mon
private org.gudy.azureus2.core3.tracker.client.impl.TRTrackerScraperImpl
scraper
private Map
responses
Constructors Summary
protected TRTrackerDHTScraperImpl(org.gudy.azureus2.core3.tracker.client.impl.TRTrackerScraperImpl _scraper)

		scraper	= _scraper;
	
Methods Summary
public static org.gudy.azureus2.core3.tracker.client.impl.dht.TRTrackerDHTScraperImplcreate(org.gudy.azureus2.core3.tracker.client.impl.TRTrackerScraperImpl _scraper)

	
	  
	
			 
	
		try{
			class_mon.enter();
		
			if ( singleton == null ){
			
				singleton =  new TRTrackerDHTScraperImpl( _scraper );
			}
			
			return( singleton );
			
		}finally{
			
			class_mon.exit();
		}
	
public voidremove(org.gudy.azureus2.core3.torrent.TOTorrent torrent)

		try{
			responses.remove( torrent.getHashWrapper());
			
		}catch( TOTorrentException e ){
			
			Debug.printStackTrace(e);
		}
	
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 ){

			try{
				return((TRTrackerScraperResponse)responses.get( torrent.getHashWrapper()));
				
			}catch( TOTorrentException e ){
				
				Debug.printStackTrace(e);
			}
		}
		
		return( null );
	
public org.gudy.azureus2.core3.tracker.client.TRTrackerScraperResponsescrape(org.gudy.azureus2.core3.tracker.client.TRTrackerAnnouncer tracker_client)

		TOTorrent	torrent = tracker_client.getTorrent();
		
		if ( torrent != null ){

			try{
				return((TRTrackerScraperResponse)responses.get( torrent.getHashWrapper()));
				
			}catch( TOTorrentException e ){
				
				Debug.printStackTrace(e);
			}
		}
		
		return( null );	
	
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){
			
			try{
				TRTrackerScraperResponseImpl resp = 
					new TRTrackerDHTScraperResponseImpl( torrent.getHashWrapper(), result.getURL());
							
				resp.setSeedsPeers( result.getSeedCount(), result.getNonSeedCount());
				
				resp.setScrapeStartTime( result.getScrapeStartTime());
				
				resp.setNextScrapeStartTime( result.getNextScrapeStartTime());
				
				resp.setStatus( 
						result.getResponseType()==DownloadScrapeResult.RT_SUCCESS?
								TRTrackerScraperResponse.ST_ONLINE:
								TRTrackerScraperResponse.ST_ERROR,
						result.getStatus()); 
			
				responses.put( torrent.getHashWrapper(), resp );
				
				scraper.scrapeReceived( resp );
				
			}catch( TOTorrentException e ){
				
				Debug.printStackTrace(e);
			}
		}