org.archive.hcc.client
Class ClusterControllerClientImpl

java.lang.Object
  extended by org.archive.hcc.client.ClusterControllerClientImpl
All Implemented Interfaces:
ClusterControllerClient

 class ClusterControllerClientImpl
extends java.lang.Object
implements ClusterControllerClient

As the workhorse of the cluster controller client, this class is responsible for connecting to the local or remote ClusterControllerBean via its DynamicMBean interface. It hides all the details of connecting to the remote MBean, ie invocations and notifications.

Author:
Daniel Bernstein (dbernstein@archive.org)

Constructor Summary
ClusterControllerClientImpl()
          Creates a local instance of the ClusterControllerBean and attaches to it.
ClusterControllerClientImpl(java.net.InetSocketAddress address)
          Constructs a client running on a remote machine.
 
Method Summary
 void addCrawlerLifecycleListener(CrawlerLifecycleListener l)
          Adds a crawler lifecycle listener.
 void addCrawlJobListener(CurrentCrawlJobListener l)
          Adds a crawl job listener.
 Crawler createCrawler()
          Creates a new instance of the crawler.
 void destroy()
          Destroys the cluster controller bean which the client is communicating with.
 void destroyAllCrawlers()
          Issues destroy commands to all the crawlers managed by the controller.
 Crawler findCrawlJobParent(java.lang.String uid, java.net.InetSocketAddress address)
          Returns the matching crawler.
 CrawlerImpl findCrawlJobParentInternal(java.lang.String uid, java.net.InetSocketAddress address)
           
 CurrentCrawlJob getCurrentCrawlJob(Crawler crawler)
          Returns the current job running on the specified crawler.
 int getMaxInstances(java.lang.String hostname, int port)
          Returns the maximum number of instances allowed for this container.
 java.util.Collection<Crawler> listCrawlers()
          Lists all the crawler instances in the cluster.
 boolean pauseAllJobs()
           
 void removeCrawlerLifecycleListener(CrawlerLifecycleListener l)
          Removes a crawler lifecycle listener.
 void removeCrawlJobListener(CurrentCrawlJobListener l)
          Removes a crawl job listener.
 boolean resumeAllPausedJobs()
           
 void setMaxInstances(java.lang.String hostname, int port, int maxInstances)
          Sets the maximum number of instances that may run on a specified container defined by a host and port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterControllerClientImpl

ClusterControllerClientImpl(java.net.InetSocketAddress address)
                      throws javax.management.InstanceNotFoundException,
                             java.io.IOException
Constructs a client running on a remote machine.

Parameters:
address -
Throws:
javax.management.InstanceNotFoundException
java.io.IOException

ClusterControllerClientImpl

ClusterControllerClientImpl()
Creates a local instance of the ClusterControllerBean and attaches to it.

Method Detail

addCrawlerLifecycleListener

public void addCrawlerLifecycleListener(CrawlerLifecycleListener l)
Description copied from interface: ClusterControllerClient
Adds a crawler lifecycle listener.

Specified by:
addCrawlerLifecycleListener in interface ClusterControllerClient

removeCrawlerLifecycleListener

public void removeCrawlerLifecycleListener(CrawlerLifecycleListener l)
Description copied from interface: ClusterControllerClient
Removes a crawler lifecycle listener.

Specified by:
removeCrawlerLifecycleListener in interface ClusterControllerClient

addCrawlJobListener

public void addCrawlJobListener(CurrentCrawlJobListener l)
Description copied from interface: ClusterControllerClient
Adds a crawl job listener.

Specified by:
addCrawlJobListener in interface ClusterControllerClient

removeCrawlJobListener

public void removeCrawlJobListener(CurrentCrawlJobListener l)
Description copied from interface: ClusterControllerClient
Removes a crawl job listener.

Specified by:
removeCrawlJobListener in interface ClusterControllerClient

destroyAllCrawlers

public void destroyAllCrawlers()
                        throws ClusterException
Description copied from interface: ClusterControllerClient
Issues destroy commands to all the crawlers managed by the controller.

Specified by:
destroyAllCrawlers in interface ClusterControllerClient
Throws:
ClusterException

pauseAllJobs

public boolean pauseAllJobs()
                     throws ClusterException
Specified by:
pauseAllJobs in interface ClusterControllerClient
Returns:
true if pause was successfully invoked on all running jobs.
Throws:
ClusterException

resumeAllPausedJobs

public boolean resumeAllPausedJobs()
                            throws ClusterException
Specified by:
resumeAllPausedJobs in interface ClusterControllerClient
Returns:
true if resume was successfully invoked on all paused or pausing jobs.
Throws:
ClusterException

findCrawlJobParent

public Crawler findCrawlJobParent(java.lang.String uid,
                                  java.net.InetSocketAddress address)
                           throws ClusterException
Description copied from interface: ClusterControllerClient
Returns the matching crawler.

Specified by:
findCrawlJobParent in interface ClusterControllerClient
Parameters:
uid - A crawl job's id.
address - The remote address of the crawler (ie not the hcc proxied address)
Returns:
The crawler or null if the parent cannot be found.
Throws:
ClusterException

findCrawlJobParentInternal

public CrawlerImpl findCrawlJobParentInternal(java.lang.String uid,
                                              java.net.InetSocketAddress address)
                                       throws ClusterException
Throws:
ClusterException

createCrawler

public Crawler createCrawler()
                      throws InsufficientCrawlingResourcesException,
                             ClusterException
Description copied from interface: ClusterControllerClient
Creates a new instance of the crawler.

Specified by:
createCrawler in interface ClusterControllerClient
Returns:
Throws:
InsufficientCrawlingResourcesException - If no crawling machines have capicity for another crawler instance.
ClusterException

listCrawlers

public java.util.Collection<Crawler> listCrawlers()
                                           throws ClusterException
Description copied from interface: ClusterControllerClient
Lists all the crawler instances in the cluster.

Specified by:
listCrawlers in interface ClusterControllerClient
Returns:
Throws:
ClusterException

destroy

public void destroy()
Description copied from interface: ClusterControllerClient
Destroys the cluster controller bean which the client is communicating with. It doesn't actually affect any objects within the cluster - ie containers, crawlers, and jobs.

Specified by:
destroy in interface ClusterControllerClient

getCurrentCrawlJob

public CurrentCrawlJob getCurrentCrawlJob(Crawler crawler)
                                   throws ClusterException
Description copied from interface: ClusterControllerClient
Returns the current job running on the specified crawler. If the crawler is not found or the crawler is not currently running a job, null will be returned.

Specified by:
getCurrentCrawlJob in interface ClusterControllerClient
Returns:
Throws:
ClusterException

getMaxInstances

public int getMaxInstances(java.lang.String hostname,
                           int port)
                    throws ClusterException
Returns the maximum number of instances allowed for this container. If the container does not exist, -1 is returned.

Specified by:
getMaxInstances in interface ClusterControllerClient
Parameters:
hostname -
port -
Returns:
Throws:
ClusterException

setMaxInstances

public void setMaxInstances(java.lang.String hostname,
                            int port,
                            int maxInstances)
                     throws ClusterException
Sets the maximum number of instances that may run on a specified container defined by a host and port.

Specified by:
setMaxInstances in interface ClusterControllerClient
Parameters:
hostname -
port -
maxInstances -
Throws:
ClusterException


Copyright © 2005-2008 The Internet Archive. All Rights Reserved.