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: 2010-10-12 00:39:07 +0000 (Tue, 12 Oct 2010) $, $Revision: 6967 $
Author:
stack

Field Summary
protected  ObjectIdentityCache<java.lang.String,CrawlHost> hosts
          hostname -> CrawlHost.
protected  ObjectIdentityCache<java.lang.String,CrawlServer> servers
          hostname[:port] -> CrawlServer.
protected  SettingsHandler settingsHandler
           
 
Constructor Summary
protected ServerCache()
          Constructor.
  ServerCache(CrawlController c)
          Create a ServerCache that uses the given CrawlController to initialize the maps of servers and hosts.
  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)
           
 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, creating if necessary.
 
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 ObjectIdentityCache<java.lang.String,CrawlServer> servers
hostname[:port] -> CrawlServer. Set in the initialization.


hosts

protected ObjectIdentityCache<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
Create a ServerCache that uses the given CrawlController to initialize the maps of servers and hosts.

Parameters:
c -
Throws:
java.lang.Exception
Method Detail

getServerFor

public CrawlServer getServerFor(java.lang.String serverKey)
Get the CrawlServer associated with name, creating if necessary.

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

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.

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-2011 Internet Archive. All Rights Reserved.