dk.netarkivet.harvester.harvesting.monitor
Class HarvestMonitorServer

java.lang.Object
  extended by dk.netarkivet.harvester.distribute.HarvesterMessageHandler
      extended by dk.netarkivet.harvester.harvesting.monitor.HarvestMonitorServer
All Implemented Interfaces:
CleanupIF, HarvesterMessageVisitor, javax.jms.MessageListener

public class HarvestMonitorServer
extends HarvesterMessageHandler
implements javax.jms.MessageListener, CleanupIF

Listens for CrawlProgressMessages on the proper JMS channel, and stores information to be presented in the monitoring console.


Field Summary
static ChannelID CRAWL_PROGRESS_CHANNEL_ID
          The JMS channel on which to listen for CrawlProgressMessages.
static ChannelID FRONTIER_CHANNEL_ID
          The JMS channel on which to listen for FrontierReportMessages.
 
Method Summary
 void cleanup()
          Close down the HarvestMonitorServer singleton.
static int getAutoRefreshDelay()
          Returns the delay in seconds after which a harvest monitor webpage should refresh itself.
 java.lang.String getChartFilePath(long jobId)
          Returns the path of the chart image file, relative to the webapp directory.
 InMemoryFrontierReport getFrontierExhaustedQueues(long jobId)
          Retrieves the latest frontier extract report stored for the given job ID, that contains only exhausted queues.
 InMemoryFrontierReport getFrontierReport(long jobId)
          Retrieves the latest frontier report stored for the given job ID.
 InMemoryFrontierReport getFrontierRetiredQueues(long jobId)
          Retrieves the latest frontier extract report stored for the given job ID, that contains only retired queues.
static HarvestMonitorServer getInstance()
           
static StartedJobInfo getMostRecentRunningJobInfo(long jobId)
          Returns the most recent running job info record available for the given job ID.
static StartedJobInfo[] getMostRecentRunningJobInfos(long jobId)
          Returns a configurable number of the most recent running job info records available for the given job ID.
 void setChartLocale(long jobId, java.util.Locale loc)
          Sets the chart generator locale.
 void visit(CrawlProgressMessage msg)
          This method should be overridden and implemented by a sub class if message handling is wanted.
 void visit(FrontierReportMessage msg)
          This method should be overridden and implemented by a sub class if message handling is wanted.
 void visit(JobEndedMessage msg)
          Cleans up the database on transitions to status DONE and FAILED.
 
Methods inherited from class dk.netarkivet.harvester.distribute.HarvesterMessageHandler
onMessage, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jms.MessageListener
onMessage
 

Field Detail

CRAWL_PROGRESS_CHANNEL_ID

public static final ChannelID CRAWL_PROGRESS_CHANNEL_ID
The JMS channel on which to listen for CrawlProgressMessages.


FRONTIER_CHANNEL_ID

public static final ChannelID FRONTIER_CHANNEL_ID
The JMS channel on which to listen for FrontierReportMessages.

Method Detail

cleanup

public void cleanup()
Close down the HarvestMonitorServer singleton. This removes the HarvestMonitorServer as listener to the JMS scheduler and frontier channels, closes the persistence container, and resets the singleton.

Specified by:
cleanup in interface CleanupIF
See Also:
CleanupIF.cleanup()

getInstance

public static HarvestMonitorServer getInstance()
Returns:
the singleton instance for this class.

visit

public void visit(CrawlProgressMessage msg)
Description copied from class: HarvesterMessageHandler
This method should be overridden and implemented by a sub class if message handling is wanted.

Specified by:
visit in interface HarvesterMessageVisitor
Overrides:
visit in class HarvesterMessageHandler
Parameters:
msg - a CrawlProgressMessage

visit

public void visit(JobEndedMessage msg)
Cleans up the database on transitions to status DONE and FAILED.

Specified by:
visit in interface HarvesterMessageVisitor
Overrides:
visit in class HarvesterMessageHandler
Parameters:
msg - a JobEndedMessage

getAutoRefreshDelay

public static final int getAutoRefreshDelay()
Returns the delay in seconds after which a harvest monitor webpage should refresh itself. This delay is set by overriding the value of the HarvesterSettings.HARVEST_MONITOR_REFRESH_INTERVAL property.

Returns:
the delay in seconds after which a harvest monitor webpage should refresh itself

getMostRecentRunningJobInfos

public static StartedJobInfo[] getMostRecentRunningJobInfos(long jobId)
Returns a configurable number of the most recent running job info records available for the given job ID.

Parameters:
jobId -
Returns:
the most recent running job info records available for the given job ID.
See Also:
HarvesterSettings.HARVEST_MONITOR_DISPLAYED_HISTORY_SIZE

getMostRecentRunningJobInfo

public static StartedJobInfo getMostRecentRunningJobInfo(long jobId)
Returns the most recent running job info record available for the given job ID.

Parameters:
jobId -
Returns:
the most recent running job info records available for the given job ID.

visit

public void visit(FrontierReportMessage msg)
Description copied from class: HarvesterMessageHandler
This method should be overridden and implemented by a sub class if message handling is wanted.

Specified by:
visit in interface HarvesterMessageVisitor
Overrides:
visit in class HarvesterMessageHandler
Parameters:
msg - a FrontierReportMessage

getFrontierReport

public InMemoryFrontierReport getFrontierReport(long jobId)
Retrieves the latest frontier report stored for the given job ID.

Parameters:
jobId - the job id
Returns:
a frontier report

getFrontierRetiredQueues

public InMemoryFrontierReport getFrontierRetiredQueues(long jobId)
Retrieves the latest frontier extract report stored for the given job ID, that contains only retired queues.

Parameters:
jobId - the job id
Returns:
a frontier report that contains only retired queues.

getFrontierExhaustedQueues

public InMemoryFrontierReport getFrontierExhaustedQueues(long jobId)
Retrieves the latest frontier extract report stored for the given job ID, that contains only exhausted queues.

Parameters:
jobId - the job id
Returns:
a frontier report that contains only exhausted queues.

getChartFilePath

public java.lang.String getChartFilePath(long jobId)
Returns the path of the chart image file, relative to the webapp directory. If no chart is available, returns a default empty image.

Parameters:
jobId - the job id
Returns:
the path of the chart image file, relative to the webapp directory.

setChartLocale

public void setChartLocale(long jobId,
                           java.util.Locale loc)
Sets the chart generator locale.

Parameters:
jobId - the job ID
loc - the local identifier, e.g. 'fr', 'dk', etc.