org.archive.crawler.datamodel
Class ServerCache

java.lang.Object
  extended by org.archive.crawler.datamodel.ServerCache

public class ServerCache
extends java.lang.Object

Server and Host cache.

Version:
$Date: 2007-08-28 05:15:25 +0000 (Tue, 28 Aug 2007) $, $Revision: 5439 $
Author:
stack

Field Summary
protected  java.util.Map<java.lang.String,CrawlHost> hosts
          hostname -> CrawlHost.
protected  java.util.Map<java.lang.String,CrawlServer> servers
          hostname[:port] -> CrawlServer.
protected  SettingsHandler settingsHandler
           
 
Constructor Summary
protected ServerCache()
          Constructor.
  ServerCache(CrawlController c)
           
  ServerCache(SettingsHandler sh)
          This constructor creates a ServerCache that is all memory-based using Hashtables.
 
Method Summary
 void cleanup()
          Called when shutting down the cache so we can do clean up.
 boolean containsHost(java.lang.String hostKey)
           
 boolean containsServer(java.lang.String serverKey)
           
protected  CrawlHost createHostFor(java.lang.String hostname)
           
protected  CrawlServer createServerFor(java.lang.String s)
           
 void forAllHostsDo(org.apache.commons.collections.Closure c)
           
 CrawlHost getHostFor(CandidateURI cauri)
          Get the CrawlHost associated with curi.
 CrawlHost getHostFor(java.lang.String hostname)
          Get the CrawlHost associated with name.
 CrawlServer getServerFor(CandidateURI cauri)
          Get the CrawlServer associated with curi.
 CrawlServer getServerFor(java.lang.String serverKey)
          Get the CrawlServer associated with name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

settingsHandler

protected SettingsHandler settingsHandler

servers

protected java.util.Map<java.lang.String,CrawlServer> servers
hostname[:port] -> CrawlServer. Set in the initialization.


hosts

protected java.util.Map<java.lang.String,CrawlHost> hosts
hostname -> CrawlHost. Set in the initialization.

Constructor Detail

ServerCache

protected ServerCache()
Constructor. Shutdown access to the default constructor by making it protected.


ServerCache

public ServerCache(SettingsHandler sh)
            throws java.lang.Exception
This constructor creates a ServerCache that is all memory-based using Hashtables. Used for unit testing only (Use ServerCache(CrawlController) when crawling).

Parameters:
sh -
Throws:
java.lang.Exception

ServerCache

public ServerCache(CrawlController c)
            throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getServerFor

public CrawlServer getServerFor(java.lang.String serverKey)
Get the CrawlServer associated with name.

Parameters:
serverKey - Server name we're to return server for.
Returns:
CrawlServer instance that matches the passed server name.

createServerFor

protected CrawlServer createServerFor(java.lang.String s)

getServerFor

public CrawlServer getServerFor(CandidateURI cauri)
Get the CrawlServer associated with curi.

Parameters:
cauri - CandidateURI we're to get server from.
Returns:
CrawlServer instance that matches the passed CandidateURI.

getHostFor

public CrawlHost getHostFor(java.lang.String hostname)
Get the CrawlHost associated with name.

Parameters:
hostname - Host name we're to return Host for.
Returns:
CrawlHost instance that matches the passed Host name.

createHostFor

protected CrawlHost createHostFor(java.lang.String hostname)

getHostFor

public CrawlHost getHostFor(CandidateURI cauri)
Get the CrawlHost associated with curi.

Parameters:
cauri - CandidateURI we're to return Host for.
Returns:
CandidateURI instance that matches the passed Host name.

containsServer

public boolean containsServer(java.lang.String serverKey)
Parameters:
serverKey - Key to use doing lookup.
Returns:
True if a server instance exists.

containsHost

public boolean containsHost(java.lang.String hostKey)
Parameters:
hostKey - Key to use doing lookup.
Returns:
True if a host instance exists.

cleanup

public void cleanup()
Called when shutting down the cache so we can do clean up.


forAllHostsDo

public void forAllHostsDo(org.apache.commons.collections.Closure c)


Copyright © 2003-2008 Internet Archive. All Rights Reserved.