org.archive.hcc
Class ClusterControllerBean

java.lang.Object
  extended by org.archive.hcc.ClusterControllerBean
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter

public class ClusterControllerBean
extends java.lang.Object
implements javax.management.DynamicMBean, javax.management.NotificationEmitter, javax.management.MBeanRegistration

As the main workhorse of the package, the ClusterControllerBean provides a unified view of any number of Heritrix instances and all related objects within a JNDI scope.

Author:
Daniel Bernstein (dbernstein@archive.org)

Constructor Summary
ClusterControllerBean()
          Creates a cluster controller bean.
 
Method Summary
protected  javax.management.ObjectName addCrawler(javax.management.ObjectName newCrawler)
           
 void addNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)
           
protected  void attachMBeanServerDelegateNotificationListener(java.net.InetSocketAddress address, javax.management.NotificationListener listener)
          Attaches a notification listener to the remote mbean server delegate at the specified address..
 javax.management.ObjectName createCrawler()
          Creates a new crawler on the least loaded machine on the cluster.
protected  void dereferenceContainer(Container c)
          Unhooks container from the bus.
 void destroy()
          Disconnects the cluster controller from the network.
 void destroyAllCrawlers()
           
protected  boolean equals(javax.management.ObjectName a, javax.management.ObjectName b, java.lang.String key)
           
 javax.management.ObjectName findCrawlServiceJobParent(java.lang.String jobUid, java.lang.String host, java.lang.Integer port)
           
 java.lang.Object getAttribute(java.lang.String attribute)
           
 javax.management.AttributeList getAttributes(java.lang.String[] attributes)
           
 javax.management.ObjectName getCurrentCrawlJob(javax.management.ObjectName mother)
          Returns the current job object name associated with the specified crawler.
 int getMaxInstances(java.lang.String hostname, java.lang.Integer port)
          Returns the maximum number of instances allowed for this container.
 javax.management.MBeanInfo getMBeanInfo()
           
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
           
 java.lang.Integer getTotalCrawlerCount()
           
protected  void handleContainerRemoved(javax.management.ObjectName name)
           
protected  void handleCrawlerCreated(javax.management.ObjectName newCrawler)
           
protected  void handleCrawlerRemoved(javax.management.ObjectName name)
           
protected  void handleJobAdded(javax.management.ObjectName job)
           
protected  void handleJobRemoved(javax.management.ObjectName job)
           
 void init()
          Initializes the cluster controller.
 java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
           
 javax.management.ObjectName[] listCrawlers()
           
static void main(java.lang.String[] args)
           
 boolean pauseAllJobs()
           
 void postDeregister()
           
 void postRegister(java.lang.Boolean registrationDone)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
           
protected  void refreshRegistry()
           
protected  void registerAddress(java.net.InetSocketAddress isa)
           
protected  void removeMBeanServerNotificationListener(java.net.InetSocketAddress address)
           
 void removeNotificationListener(javax.management.NotificationListener listener)
           
 void removeNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)
           
protected  java.util.List<Container> resolveLeastLoadedContainers()
           
 boolean resumeAllPausedJobs()
           
protected  java.util.List<javax.management.ObjectName> retrieveContainerListFromJndi()
           
 void setAttribute(javax.management.Attribute attribute)
           
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
           
 void setMaxInstances(java.lang.String hostname, java.lang.Integer port, java.lang.Integer maxInstances)
          Sets the maximum number of instances that may run on a specified container defined by a host and port.
protected  void synchronizeContainer(javax.management.ObjectName c)
          Synchronizes the state of an individual container.
protected  java.util.Map<javax.management.ObjectName,Container> synchronizeContainers(java.util.Map<javax.management.ObjectName,Container> containers, java.util.List<javax.management.ObjectName> freshContainers)
          Synchronizes the container list with the fresh list (fresh meaning, last polled from jndi), removing those that went away, and adding any newly discovered containers.
protected  void synchronizeMBean(javax.management.ObjectName name)
          synchronizes state of beans according to their types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterControllerBean

public ClusterControllerBean()
Creates a cluster controller bean. This object uses a two step initialization pattern. Therefore you must call init() before invoking any options.

Method Detail

getTotalCrawlerCount

public java.lang.Integer getTotalCrawlerCount()
Returns:
Returns the total count of all crawlers within the cluster.

findCrawlServiceJobParent

public javax.management.ObjectName findCrawlServiceJobParent(java.lang.String jobUid,
                                                             java.lang.String host,
                                                             java.lang.Integer port)

getCurrentCrawlJob

public javax.management.ObjectName getCurrentCrawlJob(javax.management.ObjectName mother)
Returns the current job object name associated with the specified crawler. Returns null if no job was running.

Parameters:
mother -
Returns:

getMaxInstances

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

Parameters:
hostname -
port -
Returns:

setMaxInstances

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

Parameters:
hostname -
port -
maxInstances -

createCrawler

public javax.management.ObjectName createCrawler()
                                          throws javax.management.MBeanException
Creates a new crawler on the least loaded machine on the cluster.

Returns:
ObjectName of created crawler.
Throws:
javax.management.MBeanException

resolveLeastLoadedContainers

protected java.util.List<Container> resolveLeastLoadedContainers()
Returns:
A list of available (ie not fully loaded) containers sorted from least loaded to most loaded. If no containers are available, returns null.

listCrawlers

public javax.management.ObjectName[] listCrawlers()
Returns:
Returns a list of all crawler instances within the hcc's jndi scope.

destroyAllCrawlers

public void destroyAllCrawlers()

pauseAllJobs

public boolean pauseAllJobs()

resumeAllPausedJobs

public boolean resumeAllPausedJobs()

init

public void init()
Initializes the cluster controller.


destroy

public void destroy()
Disconnects the cluster controller from the network. It unhooks the controller without acting on the remote instances.


handleJobRemoved

protected void handleJobRemoved(javax.management.ObjectName job)

handleJobAdded

protected void handleJobAdded(javax.management.ObjectName job)

equals

protected boolean equals(javax.management.ObjectName a,
                         javax.management.ObjectName b,
                         java.lang.String key)

handleContainerRemoved

protected void handleContainerRemoved(javax.management.ObjectName name)

handleCrawlerRemoved

protected void handleCrawlerRemoved(javax.management.ObjectName name)

retrieveContainerListFromJndi

protected final java.util.List<javax.management.ObjectName> retrieveContainerListFromJndi()
Returns:
Returns a list of containers registered with the jndi service.

refreshRegistry

protected final void refreshRegistry()

synchronizeContainers

protected final java.util.Map<javax.management.ObjectName,Container> synchronizeContainers(java.util.Map<javax.management.ObjectName,Container> containers,
                                                                                           java.util.List<javax.management.ObjectName> freshContainers)
Synchronizes the container list with the fresh list (fresh meaning, last polled from jndi), removing those that went away, and adding any newly discovered containers.

Parameters:
containers -
freshContainers -
Returns:
Map of container object names.

attachMBeanServerDelegateNotificationListener

protected void attachMBeanServerDelegateNotificationListener(java.net.InetSocketAddress address,
                                                             javax.management.NotificationListener listener)
Attaches a notification listener to the remote mbean server delegate at the specified address..

Parameters:
address -
listener -

registerAddress

protected void registerAddress(java.net.InetSocketAddress isa)
                        throws java.io.IOException
Throws:
java.io.IOException

dereferenceContainer

protected void dereferenceContainer(Container c)
Unhooks container from the bus.

Parameters:
c - Container to remove.

removeMBeanServerNotificationListener

protected void removeMBeanServerNotificationListener(java.net.InetSocketAddress address)

synchronizeContainer

protected void synchronizeContainer(javax.management.ObjectName c)
Synchronizes the state of an individual container. This means that the container is polled for instances of mbeans, listeners are attached, to the remote mbeans,

Parameters:
c - Container to check.

synchronizeMBean

protected void synchronizeMBean(javax.management.ObjectName name)
synchronizes state of beans according to their types. E.g. Heritrix Service beans are added if it hasn't already been created.

Parameters:
name -

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
Specified by:
getAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attributes)
Specified by:
getAttributes in interface javax.management.DynamicMBean

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
Specified by:
getMBeanInfo in interface javax.management.DynamicMBean

invoke

public java.lang.Object invoke(java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Specified by:
invoke in interface javax.management.DynamicMBean
Throws:
javax.management.MBeanException
javax.management.ReflectionException

setAttribute

public void setAttribute(javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.MBeanException,
                         javax.management.ReflectionException
Specified by:
setAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException
javax.management.MBeanException
javax.management.ReflectionException

setAttributes

public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Specified by:
setAttributes in interface javax.management.DynamicMBean

addNotificationListener

public void addNotificationListener(javax.management.NotificationListener listener,
                                    javax.management.NotificationFilter filter,
                                    java.lang.Object handback)
                             throws java.lang.IllegalArgumentException
Specified by:
addNotificationListener in interface javax.management.NotificationBroadcaster
Throws:
java.lang.IllegalArgumentException

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster

removeNotificationListener

public void removeNotificationListener(javax.management.NotificationListener listener,
                                       javax.management.NotificationFilter filter,
                                       java.lang.Object handback)
                                throws javax.management.ListenerNotFoundException
Specified by:
removeNotificationListener in interface javax.management.NotificationEmitter
Throws:
javax.management.ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(javax.management.NotificationListener listener)
                                throws javax.management.ListenerNotFoundException
Specified by:
removeNotificationListener in interface javax.management.NotificationBroadcaster
Throws:
javax.management.ListenerNotFoundException

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

addCrawler

protected javax.management.ObjectName addCrawler(javax.management.ObjectName newCrawler)

handleCrawlerCreated

protected void handleCrawlerCreated(javax.management.ObjectName newCrawler)

main

public static void main(java.lang.String[] args)


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