atg.endeca.index.admin
Class SimpleIndexingAdmin

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.endeca.index.admin.SimpleIndexingAdmin
All Implemented Interfaces:
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 SimpleIndexingAdmin
extends GenericService
implements Schedulable

A simple admin component for kicking off indexing. Current a given instance only manages one IndexingJobDefinition.

The indexing job is defined via the phaseToPriorityAndTasks property. An indexing job is made up of indexing phases, which in turn create indexing tasks.

Created: November 23 2011

See Also:
IndexingJob, IndexingPhase, IndexingTask

Field Summary
static java.lang.String CLASS_VERSION
          Class version string from source code control system.
protected  java.lang.Object JOB_CONTROL_LOCK
          Used when starting a job.
protected  ScheduledJob mBaselineScheduledJob
           
protected  ScheduledJob mPartialScheduledJob
           
protected  long mRetryInMs
           
 
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
SimpleIndexingAdmin()
           
 
Method Summary
 void clearAffectedByCADeploymentFlag()
          Clears property affectedByCADeployment.
protected  IndexingJob constructIndexingJob(boolean pBaseline)
          Construct an indexing job, including adding subtasks.
protected  javax.servlet.Servlet createAdminServlet()
          Creates and returns a new Servlet that will administer this service.
 boolean doesIndexIndexingOutputConfigPath(java.lang.String pPath)
          Return whether this simple admin indexes the specified indexing output config path.
 void doStartService()
          Parse our definition now, and validate after Nucleus start.
 void doStopService()
          This is called when a Service is required to shut down.
 java.lang.Thread getActiveIndexingThread()
          Returns property activeIndexingThread.
 int getAdminAutoRefreshSeconds()
          Returns property adminAutoRefreshSeconds.
 Schedule getBaselineSchedule()
          Returns property baselineSchedule.
 ScheduledJob getBaselineScheduledJob()
          Returns property partialScheduledJob.
 java.lang.String getBaselineScheduledJobName()
          Returns property baselineScheduledJobName.
 Indexable[] getIndexables()
          Returns property indexables.
 IndexingJob getIndexingJob()
          Returns property indexingJob.
 IndexingJobDefinition getIndexingJobDefinition()
          Returns property getIndexingJobDefinition.
 java.util.Set<java.lang.String> getIndexingOutputConfigPaths()
          Returns property indexingOutputConfigPaths.
 JobQueue getJobQueue()
          Returns property jobQueue.
 java.lang.String getLocalSynchronizationInvokerPath()
          Returns property localSynchronizationInvokerPath.
 Schedule getPartialSchedule()
          Returns property partialSchedule.
 ScheduledJob getPartialScheduledJob()
          Returns property partialScheduledJob.
 java.lang.String getPartialScheduledJobName()
          Returns property partialScheduledJobName.
 java.lang.String[] getPhaseToPrioritiesAndTasks()
          Returns property phaseToPrioritiesAndTasks.
 long getRetryInMs()
          Returns property retryInMs.
 Scheduler getScheduler()
          Returns property scheduler.
 int getScheduleThreadMethod()
          Returns property scheduleThreadMethod.
 javax.transaction.TransactionManager getTransactionManager()
          Returns property transactionManager.
 boolean indexBaseline()
          Do a full, baseline index.
protected  boolean indexBaseline(IndexingJob pJob, boolean pUseJobQueue)
          Do a full, baseline index.
 boolean indexPartial()
          Do a partial, incremental index.
protected  boolean indexPartial(IndexingJob pJob, boolean pUseJobQueue)
          Do a partial, incremental index.
 boolean isActivelyIndexing()
          Whether we are actively indexing.
 boolean isAffectedByCADeployment()
          Returns property affectedByCADeployment.
 boolean isDeferRunningJobsOnCADeploymentStarts()
          Returns property deferRunningJobsOnCADeploymentStarts.
 boolean isEnableScheduledIndexing()
          Returns property enableScheduledIndexing.
 boolean isOnCADeploymentChangesIndexInBackground()
          Returns property onCADeploymentChangesIndexInBackground.
 boolean isRunTasksWithinPhaseInParallel()
          Returns property runTasksWithinPhaseInParallel.
 void onCADeploymentChanges(java.util.Set<java.lang.String> pAffectedIOCPaths)
          This is invoked by the LocalSynchronizationInvokerService when the IndexingDeploymentListener invokes.
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          This is called when a scheduled job tied to this object occurs.
 void setActiveIndexingThread(java.lang.Thread pActiveIndexingThread)
          Sets property activeIndexingThread.
 void setAdminAutoRefreshSeconds(int pAdminAutoRefreshSeconds)
          Sets property adminAutoRefreshSeconds.
 void setBaselineSchedule(Schedule pBaselineSchedule)
          Sets property baselineSchedule.
 void setBaselineScheduledJobName(java.lang.String pBaselineScheduledJobName)
          Sets property baselineScheduledJobName.
 void setDeferRunningJobsOnCADeploymentStarts(boolean pDeferRunningJobsOnCADeploymentStarts)
          Sets property deferRunningJobsOnCADeploymentStarts.
 void setEnableScheduledIndexing(boolean pEnableScheduledIndexing)
          Sets property enableScheduledIndexing.
protected  void setIndexables(Indexable[] pIndexables)
          Sets property indexables.
 void setIndexingJob(IndexingJob pIndexingJob)
          Sets property indexingJob.
 void setIndexingJobDefinition(IndexingJobDefinition pIndexingJobDefinition)
          Sets property getIndexingJobDefinition.
 void setJobQueue(JobQueue pJobQueue)
          Sets property jobQueue.
 void setLocalSynchronizationInvokerPath(java.lang.String pLocalSynchronizationInvokerPath)
          Sets property localSynchronizationInvokerPath.
 void setOnCADeploymentChangesIndexInBackground(boolean pOnCADeploymentChangesIndexInBackground)
          Sets property onCADeploymentChangesIndexInBackground.
 void setPartialSchedule(Schedule pPartialSchedule)
          Sets property partialSchedule.
 void setPartialScheduledJobName(java.lang.String pPartialScheduledJobName)
          Sets property partialScheduledJobName.
 void setPhaseToPrioritiesAndTasks(java.lang.String[] pPhaseToPrioritiesAndTasks)
          Sets property phaseToPrioritiesAndTasks.
 void setRetryInMs(long pRetryInMs)
          Sets property mRetryInMs.
 void setRunTasksWithinPhaseInParallel(boolean pRunTasksWithinPhaseInParallel)
          Sets property runTasksWithinPhaseInParallel.
 void setScheduler(Scheduler pScheduler)
          Sets property scheduler.
 void setScheduleThreadMethod(int pScheduleThreadMethod)
          Sets property scheduleThreadMethod.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets property transactionManager.
 java.lang.Thread startIndexingJobInBackground(boolean pBaseline)
          Start an indexing job in its own thread.
protected  void startScheduledJobs()
          Start any scheduled jobs, if configured to do so.
protected  void stopScheduledJob(ScheduledJob pJob)
          Stop the specified scheduled job and log any exception.
protected  void stopScheduledJobs()
          Stop any scheduled jobs by removing them from the scheduler.
protected  void updateIndexingOutputConfigPaths(IndexingJob pIndexingJob)
          Update the indexingOutputConfigPaths property based on the passed in IndexingJob.
 
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 final java.lang.String CLASS_VERSION
Class version string from source code control system.

See Also:
Constant Field Values

JOB_CONTROL_LOCK

protected java.lang.Object JOB_CONTROL_LOCK
Used when starting a job.


mBaselineScheduledJob

protected ScheduledJob mBaselineScheduledJob

mPartialScheduledJob

protected ScheduledJob mPartialScheduledJob

mRetryInMs

protected long mRetryInMs
Constructor Detail

SimpleIndexingAdmin

public SimpleIndexingAdmin()
Method Detail

setIndexables

protected void setIndexables(Indexable[] pIndexables)
Sets property indexables. List of things that can be indexed, and will be invoked via indexBaseline and indexPartial


getIndexables

public Indexable[] getIndexables()
Returns property indexables. List of things that can be indexed, and will be invoked via indexBaseline and indexPartial


setIndexingJobDefinition

public void setIndexingJobDefinition(IndexingJobDefinition pIndexingJobDefinition)
Sets property getIndexingJobDefinition. Our indexing job definition, created from the phaseToPriorityAndTasks property.


getIndexingJobDefinition

public IndexingJobDefinition getIndexingJobDefinition()
Returns property getIndexingJobDefinition. Our indexing job definition, created from the phaseToPriorityAndTasks property.


setActiveIndexingThread

public void setActiveIndexingThread(java.lang.Thread pActiveIndexingThread)
Sets property activeIndexingThread. The currently active indexing thread, if any.


getActiveIndexingThread

public java.lang.Thread getActiveIndexingThread()
Returns property activeIndexingThread. The currently active indexing thread, if any.


isActivelyIndexing

public boolean isActivelyIndexing()
Whether we are actively indexing.


setPhaseToPrioritiesAndTasks

public void setPhaseToPrioritiesAndTasks(java.lang.String[] pPhaseToPrioritiesAndTasks)
Sets property phaseToPrioritiesAndTasks. A list of strings where each string should be of the form "${phaseName}=${priority}:{commaSeparatedListOfIndexableComponents}." One can append a task to phase via "${phaseName}+=${indexableComponentToAppend}". One can remove a phase via "-${phaseName}" and delete a task via "${phaseName}=-${indexableComponentToDelete}". Note that deletions happen via string comparison, not component equality.


getPhaseToPrioritiesAndTasks

public java.lang.String[] getPhaseToPrioritiesAndTasks()
Returns property phaseToPrioritiesAndTasks. A list of strings where each string should be of the form "${phaseName}=${priority}:{commaSeparatedListOfIndexableComponents}." One can append a task to phase via "${phaseName}+=${indexableComponentToAppend}". One can remove a phase via "-${phaseName}" and delete a task via "${phaseName}=-${indexableComponentToDelete}". Note that deletions happen via string comparison, not component equality.


setIndexingJob

public void setIndexingJob(IndexingJob pIndexingJob)
Sets property indexingJob. The current or most recently run indexing job. Note that this value may be changed without warning by another thread.


getIndexingJob

public IndexingJob getIndexingJob()
Returns property indexingJob. The current or most recently run indexing job. Note that this value may be changed without warning by another thread.


setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets property transactionManager. Transaction manager. Needed by ThreadDispatcher.


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns property transactionManager. Transaction manager. Needed by ThreadDispatcher.


setRunTasksWithinPhaseInParallel

public void setRunTasksWithinPhaseInParallel(boolean pRunTasksWithinPhaseInParallel)
Sets property runTasksWithinPhaseInParallel. Whether to run phases within a given task in parallel. Defaults to true, but setting to false can be useful.


isRunTasksWithinPhaseInParallel

public boolean isRunTasksWithinPhaseInParallel()
Returns property runTasksWithinPhaseInParallel. Whether to run phases within a given task in parallel. Defaults to true, but setting to false can be useful.


setAdminAutoRefreshSeconds

public void setAdminAutoRefreshSeconds(int pAdminAutoRefreshSeconds)
Sets property adminAutoRefreshSeconds. Number of seconds between auto-refresh of job status in the HTML admin.


getAdminAutoRefreshSeconds

public int getAdminAutoRefreshSeconds()
Returns property adminAutoRefreshSeconds. Number of seconds between auto-refresh of job status in the HTML admin.


setLocalSynchronizationInvokerPath

public void setLocalSynchronizationInvokerPath(java.lang.String pLocalSynchronizationInvokerPath)
Sets property localSynchronizationInvokerPath. Path of our LocalSynchronizationInvokerService.


getLocalSynchronizationInvokerPath

public java.lang.String getLocalSynchronizationInvokerPath()
Returns property localSynchronizationInvokerPath. Path of our LocalSynchronizationInvokerService.


getIndexingOutputConfigPaths

public java.util.Set<java.lang.String> getIndexingOutputConfigPaths()
Returns property indexingOutputConfigPaths. The set of indexing output config paths this admin service refers to.


setOnCADeploymentChangesIndexInBackground

public void setOnCADeploymentChangesIndexInBackground(boolean pOnCADeploymentChangesIndexInBackground)
Sets property onCADeploymentChangesIndexInBackground. Whether to trigger an index in background when onCADeploymentChanges is invoked.


isOnCADeploymentChangesIndexInBackground

public boolean isOnCADeploymentChangesIndexInBackground()
Returns property onCADeploymentChangesIndexInBackground. Whether to trigger an index in background when onCADeploymentChanges is invoked.


setScheduler

public void setScheduler(Scheduler pScheduler)
Sets property scheduler. The scheduler used for partial and baseline scheduled jobs, if any.


getScheduler

public Scheduler getScheduler()
Returns property scheduler. The scheduler used for partial and baseline scheduled jobs, if any.


setScheduleThreadMethod

public void setScheduleThreadMethod(int pScheduleThreadMethod)
Sets property scheduleThreadMethod. The thread method to use for scheduled jobs. The default is REUSE_THREAD.


getScheduleThreadMethod

public int getScheduleThreadMethod()
Returns property scheduleThreadMethod. The thread method to use for scheduled jobs. The default is REUSE_THREAD.


setBaselineSchedule

public void setBaselineSchedule(Schedule pBaselineSchedule)
Sets property baselineSchedule. The schedule to use for baseline indexing.


getBaselineSchedule

public Schedule getBaselineSchedule()
Returns property baselineSchedule. The schedule to use for baseline indexing.


setBaselineScheduledJobName

public void setBaselineScheduledJobName(java.lang.String pBaselineScheduledJobName)
Sets property baselineScheduledJobName. Name of the baseline scheduled job.


getBaselineScheduledJobName

public java.lang.String getBaselineScheduledJobName()
Returns property baselineScheduledJobName. Name of the baseline scheduled job.


getBaselineScheduledJob

public ScheduledJob getBaselineScheduledJob()
Returns property partialScheduledJob. The scheduled job used to invoke a partial index.


setPartialSchedule

public void setPartialSchedule(Schedule pPartialSchedule)
Sets property partialSchedule. The schedule to use for partial indexing.


getPartialSchedule

public Schedule getPartialSchedule()
Returns property partialSchedule. The schedule to use for partial indexing.


setPartialScheduledJobName

public void setPartialScheduledJobName(java.lang.String pPartialScheduledJobName)
Sets property partialScheduledJobName. Name of the partial scheduled job.


getPartialScheduledJobName

public java.lang.String getPartialScheduledJobName()
Returns property partialScheduledJobName. Name of the partial scheduled job.


getPartialScheduledJob

public ScheduledJob getPartialScheduledJob()
Returns property partialScheduledJob. The scheduled job used to invoke a partial index.


setEnableScheduledIndexing

public void setEnableScheduledIndexing(boolean pEnableScheduledIndexing)
Sets property enableScheduledIndexing. Whether to enable period indexing.


isEnableScheduledIndexing

public boolean isEnableScheduledIndexing()
Returns property enableScheduledIndexing. Whether to enable period indexing.


getRetryInMs

public long getRetryInMs()
Returns property retryInMs. The time in milliseconds after which this job will be retried in case of an exception. Negative value indicates no retry. No job retried more than once.


setRetryInMs

public void setRetryInMs(long pRetryInMs)
Sets property mRetryInMs. The time in milliseconds after which this job will be retried in case of an exception. Negative value indicates no retry. No job retried more than once.


setJobQueue

public void setJobQueue(JobQueue pJobQueue)
Sets property jobQueue. A component which allows to organize a queue of indexing jobs.


getJobQueue

public JobQueue getJobQueue()
Returns property jobQueue. A component which allows to organize a queue of indexing jobs.


setDeferRunningJobsOnCADeploymentStarts

public void setDeferRunningJobsOnCADeploymentStarts(boolean pDeferRunningJobsOnCADeploymentStarts)
Sets property deferRunningJobsOnCADeploymentStarts.

Parameters:
pDeferRunningJobsOnCADeploymentStarts - true means that a running indexing job should be deferred (canceled and queued) when a CA deployment starts; false a running indexing process should be finished independently of CA deployments.

isDeferRunningJobsOnCADeploymentStarts

public boolean isDeferRunningJobsOnCADeploymentStarts()
Returns property deferRunningJobsOnCADeploymentStarts.

Returns:
true means that a running indexing job should be deferred (canceled and queued) when a CA deployment starts; false a running indexing process will be finished independently of CA deployments.

isAffectedByCADeployment

public boolean isAffectedByCADeployment()
Returns property affectedByCADeployment.


clearAffectedByCADeploymentFlag

public void clearAffectedByCADeploymentFlag()
Clears property affectedByCADeployment.


onCADeploymentChanges

public void onCADeploymentChanges(java.util.Set<java.lang.String> pAffectedIOCPaths)
This is invoked by the LocalSynchronizationInvokerService when the IndexingDeploymentListener invokes. Only triggers an index if pAffectedIOCPaths includes one of the IndexingDeploymentListener index by this instances job definition.

Parameters:
pAffectedIOCPaths - the array of affected indexing output config paths.

indexBaseline

public boolean indexBaseline()
                      throws atg.repository.search.indexing.IndexingException
Do a full, baseline index.

Throws:
atg.repository.search.indexing.IndexingException

indexBaseline

protected boolean indexBaseline(IndexingJob pJob,
                                boolean pUseJobQueue)
                         throws atg.repository.search.indexing.IndexingException
Do a full, baseline index.

Throws:
atg.repository.search.indexing.IndexingException

indexPartial

public boolean indexPartial()
                     throws atg.repository.search.indexing.IndexingException
Do a partial, incremental index.

Throws:
atg.repository.search.indexing.IndexingException

indexPartial

protected boolean indexPartial(IndexingJob pJob,
                               boolean pUseJobQueue)
                        throws atg.repository.search.indexing.IndexingException
Do a partial, incremental index.

Throws:
atg.repository.search.indexing.IndexingException

constructIndexingJob

protected IndexingJob constructIndexingJob(boolean pBaseline)
                                    throws atg.repository.search.indexing.IndexingException
Construct an indexing job, including adding subtasks.

Parameters:
pBaseline - whether this is a baseline index.
Throws:
atg.repository.search.indexing.IndexingException

startScheduledJobs

protected void startScheduledJobs()
Start any scheduled jobs, if configured to do so.


stopScheduledJob

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

Parameters:
pJob - the scheduled job to stop.

stopScheduledJobs

protected void stopScheduledJobs()
Stop any scheduled jobs by removing them from the scheduler.


performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
This is called when a scheduled job tied to this object occurs.

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

doStartService

public void doStartService()
                    throws ServiceException
Parse our definition now, and validate after Nucleus start.

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

updateIndexingOutputConfigPaths

protected void updateIndexingOutputConfigPaths(IndexingJob pIndexingJob)
Update the indexingOutputConfigPaths property based on the passed in IndexingJob.

Parameters:
pIndexingJob - the IndexingJob whose tasks should be consulted when updating the the indexingOutputConfigPaths property.

doesIndexIndexingOutputConfigPath

public boolean doesIndexIndexingOutputConfigPath(java.lang.String pPath)
Return whether this simple admin indexes the specified indexing output config path.

Parameters:
pPath - the absolute Nucleus path of the IndexingOutputConfig in question.

startIndexingJobInBackground

public java.lang.Thread startIndexingJobInBackground(boolean pBaseline)
Start an indexing job in its own thread.

Parameters:
pBaseline - whether this is a baseline index.

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