Class JobManagerConfiguration
- java.lang.Object
-
- org.apache.sling.event.impl.jobs.config.JobManagerConfiguration
-
public class JobManagerConfiguration extends Object
Configuration of the job handling
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceJobManagerConfiguration.Config
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_BACKGROUND_LOAD_DELAYDefault background load delay.static StringDEFAULT_REPOSITORY_PATHDefault resource path for jobs.static StringDEFAULT_SCHEDULED_JOBS_PATHDefault resource path for scheduled jobs.static StringPROPERTY_BACKGROUND_LOAD_DELAYThe background loader waits this time of seconds after startup before loading events from the repository.static StringPROPERTY_REPOSITORY_PATHThe path where all jobs are stored.static StringPROPERTY_SCHEDULED_JOBS_PATHConfiguration property for the scheduled jobs path.
-
Constructor Summary
Constructors Constructor Description JobManagerConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(Map<String,Object> props, JobManagerConfiguration.Config config)Activate this component.voidaddJobToRetryList(org.apache.sling.event.jobs.Job job)voidaddListener(ConfigurationChangeListener service)Add a topology aware listenerprotected voidbindJobProcessingEnabledCondition(org.osgi.service.condition.Condition condition)Handle binding of the job processing condition.List<org.apache.sling.event.jobs.Job>clearJobRetryList()org.apache.sling.api.resource.ResourceResolvercreateResourceResolver()Create a new resource resolver for reading and writing the resource tree.protected voiddeactivate()DeactivatebooleandisableDistribution()StringgetAssginedJobsPath()Get the resource path for all assigned jobs.org.slf4j.LoggergetAuditLogger()The audit logger is logging actions for auditing.intgetHistoryCleanUpRemovedJobs()org.apache.sling.event.jobs.JobgetJobFromRetryList(String jobId)StringgetJobsBasePathWithSlash()StringgetLocalJobsPath()Get the resource path for all jobs assigned to the current instanceorg.slf4j.LoggergetMainLogger()Get main logger.StringgetPreviousVersionAnonPath()StringgetPreviousVersionIdentifiedPath()intgetProgressLogMaxCount()QueueConfigurationManagergetQueueConfigurationManager()StringgetScheduledJobsPath(boolean slash)Get the scheduled jobs pathStringgetStoragePath(String topic, String jobId, boolean isSuccess)Get the storage path for finished jobs.StringgetStoredCancelledJobsPath()StringgetStoredSuccessfulJobsPath()TopologyCapabilitiesgetTopologyCapabilities()Get the current topology capabilities.StringgetUnassignedJobsPath()Get the resource path for all unassigned jobs.StringgetUniqueId(String jobTopic)Get the unique job idStringgetUniquePath(String targetId, String topic, String jobId, Map<String,Object> jobProperties)Create a unique job path (folder and name) for the job.voidhandleTopologyEvent(org.apache.sling.discovery.TopologyEvent event)This method is invoked asynchronously from the TopologyHandler.booleanisActive()Is this component still active?booleanisJob(String jobPath)booleanisJobProcessingEnabled()Check if job processing is enabled.booleanisLocalJob(String jobPath)booleanisStoragePath(String path)Check whether this is a storage path.booleanremoveJobFromRetryList(org.apache.sling.event.jobs.Job job)voidremoveListener(ConfigurationChangeListener service)Remove a topology aware listenerprotected voidunbindJobProcessingEnabledCondition(org.osgi.service.condition.Condition condition)Handle unbinding of the job processing condition.protected voidupdate(Map<String,Object> props, JobManagerConfiguration.Config config)Update with a new configuration
-
-
-
Field Detail
-
DEFAULT_REPOSITORY_PATH
public static final String DEFAULT_REPOSITORY_PATH
Default resource path for jobs.- See Also:
- Constant Field Values
-
DEFAULT_BACKGROUND_LOAD_DELAY
public static final long DEFAULT_BACKGROUND_LOAD_DELAY
Default background load delay.- See Also:
- Constant Field Values
-
DEFAULT_SCHEDULED_JOBS_PATH
public static final String DEFAULT_SCHEDULED_JOBS_PATH
Default resource path for scheduled jobs.- See Also:
- Constant Field Values
-
PROPERTY_REPOSITORY_PATH
public static final String PROPERTY_REPOSITORY_PATH
The path where all jobs are stored.- See Also:
- Constant Field Values
-
PROPERTY_BACKGROUND_LOAD_DELAY
public static final String PROPERTY_BACKGROUND_LOAD_DELAY
The background loader waits this time of seconds after startup before loading events from the repository. (in secs)- See Also:
- Constant Field Values
-
PROPERTY_SCHEDULED_JOBS_PATH
public static final String PROPERTY_SCHEDULED_JOBS_PATH
Configuration property for the scheduled jobs path.- See Also:
- Constant Field Values
-
-
Method Detail
-
bindJobProcessingEnabledCondition
protected void bindJobProcessingEnabledCondition(org.osgi.service.condition.Condition condition)
Handle binding of the job processing condition.- Parameters:
condition- The condition being bound
-
unbindJobProcessingEnabledCondition
protected void unbindJobProcessingEnabledCondition(org.osgi.service.condition.Condition condition)
Handle unbinding of the job processing condition.- Parameters:
condition- The condition being unbound
-
isJobProcessingEnabled
public boolean isJobProcessingEnabled()
Check if job processing is enabled. This only affects whether jobs are processed/executed - jobs can still be assigned, stored, and managed through the API even when processing is disabled.- Returns:
- true if job processing is enabled, false otherwise
-
activate
protected void activate(Map<String,Object> props, JobManagerConfiguration.Config config)
Activate this component.- Parameters:
props- Configuration propertiesconfig- Configuration properties- Throws:
RuntimeException- If the default paths can't be created
-
update
protected void update(Map<String,Object> props, JobManagerConfiguration.Config config)
Update with a new configuration
-
deactivate
protected void deactivate()
Deactivate
-
getHistoryCleanUpRemovedJobs
public int getHistoryCleanUpRemovedJobs()
-
isActive
public boolean isActive()
Is this component still active?- Returns:
- Active?
-
createResourceResolver
public org.apache.sling.api.resource.ResourceResolver createResourceResolver()
Create a new resource resolver for reading and writing the resource tree. The resolver needs to be closed by the client. This ResourceResolver provides read and write access to all resources relevant for the event and job handling.- Returns:
- A resource resolver or
nullif the component is already deactivated. - Throws:
RuntimeException- if the resolver can't be created.
-
getTopologyCapabilities
public TopologyCapabilities getTopologyCapabilities()
Get the current topology capabilities.- Returns:
- The capabilities or
null
-
getQueueConfigurationManager
public QueueConfigurationManager getQueueConfigurationManager()
-
getMainLogger
public org.slf4j.Logger getMainLogger()
Get main logger.- Returns:
- The main logger.
-
getAssginedJobsPath
public String getAssginedJobsPath()
Get the resource path for all assigned jobs.- Returns:
- The path - does not end with a slash.
-
getUnassignedJobsPath
public String getUnassignedJobsPath()
Get the resource path for all unassigned jobs.- Returns:
- The path - does not end with a slash.
-
getLocalJobsPath
public String getLocalJobsPath()
Get the resource path for all jobs assigned to the current instance- Returns:
- The path - does not end with a slash
-
getUniquePath
public String getUniquePath(String targetId, String topic, String jobId, Map<String,Object> jobProperties)
Create a unique job path (folder and name) for the job.
-
isLocalJob
public boolean isLocalJob(String jobPath)
-
isJob
public boolean isJob(String jobPath)
-
getJobsBasePathWithSlash
public String getJobsBasePathWithSlash()
-
getProgressLogMaxCount
public int getProgressLogMaxCount()
-
getPreviousVersionAnonPath
public String getPreviousVersionAnonPath()
-
getPreviousVersionIdentifiedPath
public String getPreviousVersionIdentifiedPath()
-
disableDistribution
public boolean disableDistribution()
-
getStoredCancelledJobsPath
public String getStoredCancelledJobsPath()
-
getStoredSuccessfulJobsPath
public String getStoredSuccessfulJobsPath()
-
getStoragePath
public String getStoragePath(String topic, String jobId, boolean isSuccess)
Get the storage path for finished jobs.- Parameters:
topic- Topic of the finished jobjobId- The job id of the finished job.isSuccess- Whether processing was successful or not- Returns:
- The complete storage path
-
isStoragePath
public boolean isStoragePath(String path)
Check whether this is a storage path.
-
getScheduledJobsPath
public String getScheduledJobsPath(boolean slash)
Get the scheduled jobs path- Parameters:
slash- Iffalsethe path is returned, iftruethe path appended with a slash is returned.- Returns:
- The path for the scheduled jobs
-
handleTopologyEvent
public void handleTopologyEvent(org.apache.sling.discovery.TopologyEvent event)
This method is invoked asynchronously from the TopologyHandler. Therefore this method can't be invoked concurrently- See Also:
TopologyEventListener.handleTopologyEvent(org.apache.sling.discovery.TopologyEvent)
-
addListener
public void addListener(ConfigurationChangeListener service)
Add a topology aware listener- Parameters:
service- Listener to notify about changes.
-
removeListener
public void removeListener(ConfigurationChangeListener service)
Remove a topology aware listener- Parameters:
service- Listener to notify about changes.
-
addJobToRetryList
public void addJobToRetryList(org.apache.sling.event.jobs.Job job)
-
clearJobRetryList
public List<org.apache.sling.event.jobs.Job> clearJobRetryList()
-
removeJobFromRetryList
public boolean removeJobFromRetryList(org.apache.sling.event.jobs.Job job)
-
getJobFromRetryList
public org.apache.sling.event.jobs.Job getJobFromRetryList(String jobId)
-
getAuditLogger
public org.slf4j.Logger getAuditLogger()
The audit logger is logging actions for auditing.- Returns:
- The logger
-
-