Class FaultyHarvestControllerServer
- java.lang.Object
-
- dk.netarkivet.harvester.distribute.HarvesterMessageHandler
-
- dk.netarkivet.harvester.tools.dummy.FaultyHarvestControllerServer
-
- All Implemented Interfaces:
CleanupIF
,HarvesterMessageVisitor
,javax.jms.MessageListener
public class FaultyHarvestControllerServer extends HarvesterMessageHandler implements CleanupIF
This class responds to JMS doOneCrawl messages from the HarvestScheduler and waits 10 minutes before failing the job.Initially, it registers its channel with the Scheduler by sending a HarvesterRegistrationRequest and waits for a positive HarvesterRegistrationResponse that its channel is recognized. If not recognized by the Scheduler, the HarvestControllerServer will send a notification about this, and then close down the application. During its operation CrawlStatus messages are sent to the HarvestSchedulerMonitorServer. When responding to the message, it sends a message with status 'STARTED'. When 10 minutes have passed, a message is sent with status 'FAILED'.
Before the 10 minutes starts, the JMS listener is removed to avoid handling more than one doOneCrawlMessage at a time During the 10 minutes, it will send two (instead of one) HarvesterReadyMessages to the scheduler to test issue NAS-2614. The interval between sending HarvesterReadyMessages is defined by the setting 'settings.harvester.harvesting.sendReadyDelay'.
-
-
Field Summary
Fields Modifier and Type Field Description static ChannelID
HARVEST_CHAN_VALID_RESP_ID
The JMS channel on which to listen forHarvesterRegistrationResponse
s.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Will be called on shutdown.void
close()
Release all jms connections.static FaultyHarvestControllerServer
getInstance()
Returns or creates the unique instance of this singleton.void
sendErrorMessage(long jobID, String message, String detailedMessage)
Sends a CrawlStatusMessage for a failed job with the given short message and detailed message.void
visit(DoOneCrawlMessage msg)
Here we receives a DoOneCrawlMessage, waits 10 minutes, and then fails the job.void
visit(HarvesterRegistrationResponse msg)
This method should be overridden and implemented by a sub class if message handling is wanted.
-
-
-
Field Detail
-
HARVEST_CHAN_VALID_RESP_ID
public static final ChannelID HARVEST_CHAN_VALID_RESP_ID
The JMS channel on which to listen forHarvesterRegistrationResponse
s.
-
-
Method Detail
-
getInstance
public static FaultyHarvestControllerServer getInstance() throws IOFailure
Returns or creates the unique instance of this singleton.- Returns:
- The instance
- Throws:
PermissionDenied
- If the serverdir or oldjobsdir can't be createdIOFailure
- if data from old harvests exist, but contain illegal data
-
close
public void close()
Release all jms connections. Close the Controller
-
cleanup
public void cleanup()
Will be called on shutdown.- Specified by:
cleanup
in interfaceCleanupIF
- See Also:
CleanupIF.cleanup()
-
visit
public void visit(HarvesterRegistrationResponse 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 interfaceHarvesterMessageVisitor
- Overrides:
visit
in classHarvesterMessageHandler
- Parameters:
msg
- aHarvesterRegistrationResponse
-
visit
public void visit(DoOneCrawlMessage msg) throws IOFailure, UnknownID, ArgumentNotValid, PermissionDenied
Here we receives a DoOneCrawlMessage, waits 10 minutes, and then fails the job.- Specified by:
visit
in interfaceHarvesterMessageVisitor
- Overrides:
visit
in classHarvesterMessageHandler
- Parameters:
msg
- The crawl job- Throws:
IOFailure
- On trouble harvesting, uploading or processing harvestInfoUnknownID
- if jobID is null in the messageArgumentNotValid
- if the status of the job is not valid - must be SUBMITTEDPermissionDenied
- if the crawldir can't be created- See Also:
for more details
-
sendErrorMessage
public void sendErrorMessage(long jobID, String message, String detailedMessage)
Sends a CrawlStatusMessage for a failed job with the given short message and detailed message.- Parameters:
jobID
- ID of the job that failedmessage
- A short message indicating what went wrongdetailedMessage
- A more detailed message detailing why it went wrong.
-
-