atg.endeca.index.admin
Class InMemoryJobQueue

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.endeca.index.admin.InMemoryJobQueue
All Implemented Interfaces:
JobQueue, atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener

public class InMemoryJobQueue
extends GenericService
implements JobQueue, Schedulable

A simple component which implements JobQueue interface.

It stores IndexingJob object in memory only. So after server restarts, the job queue will be empty. The component tries to start indexing jobs when a running indexing job finishes. It also allows restarting of indexing jobs from the queue periodically (by specifying the schedule property).

Created: January 20 2012

See Also:
JobQueue, SimpleIndexingAdmin

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  ScheduledJob mScheduledJob
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
InMemoryJobQueue()
           
 
Method Summary
protected  javax.servlet.Servlet createAdminServlet()
          Creates and returns a new Servlet that will administer this service.
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 void doStopService()
          This is called when a Service is required to shut down.
 void enqueueJob(IndexingJob pJob, boolean pPriorityJob)
          Add an indexing job to the queue.
 java.lang.String getJobId(IndexingJob pJob)
          Generated internal ID for a job.
 IndexingJob[] getQueuedJobs()
          Returns an array of queued indexing jobs.
 Schedule getSchedule()
          Returns property schedule.
 ScheduledJob getScheduledJob()
          Returns property scheduledJob.
 Scheduler getScheduler()
          Returns property scheduler.
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          Restarts all queued index jobs.
 void processJobQueue()
          Tries to restart all queued jobs in separate thread (to avoid any blocking issues).
 void removeJob(IndexingJob pJob)
          Removes indexing job from the queue.
 void setSchedule(Schedule pSchedule)
          Sets property schedule.
 void setScheduler(Scheduler pScheduler)
          Sets property scheduler.
protected  void stopScheduledJob()
          Stop the specified scheduled job and log any exception.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mScheduledJob

protected ScheduledJob mScheduledJob
Constructor Detail

InMemoryJobQueue

public InMemoryJobQueue()
Method Detail

setScheduler

public void setScheduler(Scheduler pScheduler)
Sets property scheduler. The scheduler used to enqueue the queued jobs.


getScheduler

public Scheduler getScheduler()
Returns property scheduler. The scheduler used to enqueue the queued jobs.


setSchedule

public void setSchedule(Schedule pSchedule)
Sets property schedule. The schedule to use for restarting the queued jobs.


getSchedule

public Schedule getSchedule()
Returns property schedule. The schedule to use for restarting the queued jobs.


getScheduledJob

public ScheduledJob getScheduledJob()
Returns property scheduledJob. The scheduled job used to restart the queued jobs.


enqueueJob

public void enqueueJob(IndexingJob pJob,
                       boolean pPriorityJob)
                throws atg.repository.search.indexing.IndexingException
Add an indexing job to the queue.

Specified by:
enqueueJob in interface JobQueue
Parameters:
pJob - an indexing job to add
pPriorityJob - true if the job should be dequeued first
Throws:
atg.repository.search.indexing.IndexingException

getQueuedJobs

public IndexingJob[] getQueuedJobs()
Returns an array of queued indexing jobs.

Specified by:
getQueuedJobs in interface JobQueue

getJobId

public java.lang.String getJobId(IndexingJob pJob)
Generated internal ID for a job.

Parameters:
pJob - an indexing job
Returns:
String unique ID of a job

removeJob

public void removeJob(IndexingJob pJob)
Removes indexing job from the queue.

Specified by:
removeJob in interface JobQueue
Parameters:
pJob - a job to be removed

processJobQueue

public void processJobQueue()
Tries to restart all queued jobs in separate thread (to avoid any blocking issues).

Specified by:
processJobQueue in interface JobQueue

performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
Restarts all queued index jobs. The method is called by schedule or after finishing another indexing job.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - calling the job
pJob - the ScheduledJob

stopScheduledJob

protected void stopScheduledJob()
Stop the specified scheduled job and log any exception.


doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
Description copied from class: GenericService
This is called when a Service is required to shut down. The Service should respond by stopping any processes that it has started.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if the Service had a problem shutting down

createAdminServlet

protected javax.servlet.Servlet createAdminServlet()
Description copied from class: GenericService
Creates and returns a new Servlet that will administer this service. By default, this creates a ServiceAdminServlet, but subclasses may create their own servlets.

Overrides:
createAdminServlet in class GenericService