This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event.git
commit e1b60efc22388d41906f47f6ef37ff2457574e1a Author: Stefan Egli <[email protected]> AuthorDate: Wed Jul 5 15:03:52 2017 +0000 SLING-6739 : embedding sling.event.api 1.0.0 and explicitly exporting event.jobs, event.jobs.consumer, event.jobs.jmx git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1800888 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 22 +- src/main/java/org/apache/sling/event/jobs/Job.java | 351 --------------------- .../org/apache/sling/event/jobs/JobBuilder.java | 161 ---------- .../org/apache/sling/event/jobs/JobManager.java | 223 ------------- .../sling/event/jobs/NotificationConstants.java | 106 ------- .../java/org/apache/sling/event/jobs/Queue.java | 97 ------ .../sling/event/jobs/QueueConfiguration.java | 111 ------- .../org/apache/sling/event/jobs/ScheduleInfo.java | 89 ------ .../apache/sling/event/jobs/ScheduledJobInfo.java | 89 ------ .../org/apache/sling/event/jobs/Statistics.java | 112 ------- .../apache/sling/event/jobs/TopicStatistics.java | 87 ----- .../sling/event/jobs/consumer/JobConsumer.java | 133 -------- .../event/jobs/consumer/JobExecutionContext.java | 144 --------- .../event/jobs/consumer/JobExecutionResult.java | 71 ----- .../sling/event/jobs/consumer/JobExecutor.java | 104 ------ .../sling/event/jobs/consumer/package-info.java | 23 -- .../apache/sling/event/jobs/jmx/QueuesMBean.java | 28 -- .../sling/event/jobs/jmx/StatisticsMBean.java | 34 -- .../apache/sling/event/jobs/jmx/package-info.java | 23 -- .../org/apache/sling/event/jobs/package-info.java | 23 -- 20 files changed, 13 insertions(+), 2018 deletions(-) diff --git a/pom.xml b/pom.xml index c059694..9ff4cc7 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,11 @@ org.apache.felix.inventory;resolution:=optional, * </Import-Package> + <Export-Package> + org.apache.sling.event.jobs, + org.apache.sling.event.jobs.consumer, + org.apache.sling.event.jobs.jmx + </Export-Package> <DynamicImport-Package> javax.servlet, javax.servlet.http, @@ -80,7 +85,8 @@ <Embed-Dependency> jackrabbit-jcr-commons;inline="org/apache/jackrabbit/util/ISO9075.*|org/apache/jackrabbit/util/ISO8601.*|org/apache/jackrabbit/util/XMLChar.*", org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/PropertiesUtil.*", - quartz;inline="org/quartz/CronExpression.*|org/quartz/ValueSet.*" + quartz;inline="org/quartz/CronExpression.*|org/quartz/ValueSet.*", + org.apache.sling.event.api </Embed-Dependency> </instructions> </configuration> @@ -362,12 +368,10 @@ <version>1</version> <scope>test</scope> </dependency> -<!-- SLING-6739 : update once sling.event.api is released (and then remove identical packages in this bundle) - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.event.api</artifactId> - <version>1.0.0</version> - <type>bundle</type> - </dependency> - --> </dependencies> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.event.api</artifactId> + <version>1.0.0</version> + </dependency> + </dependencies> </project> diff --git a/src/main/java/org/apache/sling/event/jobs/Job.java b/src/main/java/org/apache/sling/event/jobs/Job.java deleted file mode 100644 index 710e730..0000000 --- a/src/main/java/org/apache/sling/event/jobs/Job.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - 1 * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import java.util.Calendar; -import java.util.Set; - -import org.osgi.annotation.versioning.ProviderType; - - -/** - * A job - * - * - * Property Types - * - * In general all scalar types and all serializable classes are supported as - * property types. However, in order for deseralizing classes these must be - * exported. Serializable classes are not searchable in the query either. - * Due to the above mentioned potential problems, it is advisable to not use - * custom classes as job properties, but rather use out of the box supported - * types in combination with collections. - * - * A resource provider might convert numbers to a different type, JCR is well-known - * for this behavior as it only supports long but neither integer nor short. - * Therefore if you are dealing with numbers, use the {@link #getProperty(String, Class)} - * method to get the correct type instead of directly casting it. - * - * @since 1.2 - */ -@ProviderType -public interface Job { - - /** - * The name of the job queue processing this job. - * This property is set by the job handling when the job is processed. - * If this property is set by the client creating the job it's value is ignored - */ - String PROPERTY_JOB_QUEUE_NAME = "event.job.queuename"; - - /** - * The property to track the retry count for jobs. Value is of type Integer. - * On first execution the value of this property is zero. - * This property is managed by the job handling. - * If this property is set by the client creating the job it's value is ignored - */ - String PROPERTY_JOB_RETRY_COUNT = "event.job.retrycount"; - - /** - * The property to track the retry maximum retry count for jobs. Value is of type Integer. - * This property is managed by the job handling. - * If this property is set by the client creating the job it's value is ignored - */ - String PROPERTY_JOB_RETRIES = "event.job.retries"; - - /** - * This property is set by the job handling and contains a calendar object - * specifying the date and time when this job has been created. - * If this property is set by the client creating the job it's value is ignored - */ - String PROPERTY_JOB_CREATED = "slingevent:created"; - - /** - * This property is set by the job handling and contains the Sling instance ID - * of the instance where this job has been created. - */ - String PROPERTY_JOB_CREATED_INSTANCE = "slingevent:application"; - - /** - * This property is set by the job handling and contains the Sling instance ID - * of the instance where this job should be processed. - */ - String PROPERTY_JOB_TARGET_INSTANCE = "event.job.application"; - - /** - * This property is set by the job handling and contains a calendar object - * specifying the date and time when this job has been started. - * This property is only set if the job is currently in processing - * If this property is set by the client creating the job it's value is ignored - */ - String PROPERTY_JOB_STARTED_TIME = "event.job.started.time"; - - /** - * The property to set a retry delay. Value is of type Long and specifies milliseconds. - * This property can be used to override the retry delay from the queue configuration. - * But it should only be used very rarely as the queue configuration should be the one - * in charge. - */ - String PROPERTY_JOB_RETRY_DELAY = "event.job.retrydelay"; - - /** - * This property contains the optional output log of a job consumer. - * The value of this property is a string array. - * This property is read-only and can't be specified when the job is created. - * @since 1.3 - */ - String PROPERTY_JOB_PROGRESS_LOG = "slingevent:progressLog"; - - /** - * This property contains the optional ETA for a job. - * The value of this property is a {@link Calendar} object. - * This property is read-only and can't be specified when the job is created. - * @since 1.3 - */ - String PROPERTY_JOB_PROGRESS_ETA = "slingevent:progressETA"; - - /** - * This property contains optional progress information about a job, - * the number of steps the job consumer will perform. Each step is - * assumed to consume roughly the same amount if time. - * The value of this property is an integer. - * This property is read-only and can't be specified when the job is created. - * @since 1.3 - */ - String PROPERTY_JOB_PROGRESS_STEPS = "slingevent:progressSteps"; - - /** - * This property contains optional progress information about a job, - * the number of completed steps. - * The value of this property is an integer. - * This property is read-only and can't be specified when the job is created. - * @since 1.3 - */ - String PROPERTY_JOB_PROGRESS_STEP = "slingevent:progressStep"; - - /** - * This property contains the optional result message of a job consumer. - * The value of this property is a string. - * This property is read-only and can't be specified when the job is created. - * @since 1.3 - */ - String PROPERTY_RESULT_MESSAGE = "slingevent:resultMessage"; - - /** - * This property contains the finished date once a job is marked as finished. - * The value of this property is a {@link Calendar} object. - * This property is read-only and can't be specified when the job is created. - * @since 1.3 - */ - String PROPERTY_FINISHED_DATE = "slingevent:finishedDate"; - - /** - * This is an optional property containing a human readable title for - * the job - * @since 1.3 - */ - String PROPERTY_JOB_TITLE = "slingevent:jobTitle"; - - /** - * This is an optional property containing a human readable description for - * the job - * @since 1.3 - */ - String PROPERTY_JOB_DESCRIPTION = "slingevent:jobDescription"; - - /** - * The current job state. - * @since 1.3 - */ - enum JobState { - QUEUED, // waiting in queue after adding or for restart after failing - ACTIVE, // job is currently in processing - SUCCEEDED, // processing finished successfully - STOPPED, // processing was stopped by a user - GIVEN_UP, // number of retries reached - ERROR, // processing signaled CANCELLED or throw an exception - DROPPED // dropped jobs - }; - - /** - * The job topic. - * @return The job topic - */ - String getTopic(); - - /** - * Unique job ID. - * @return The unique job ID. - */ - String getId(); - - /** - * Get the value of a property. - * @param name The property name - * @return The value of the property or <code>null</code> - */ - Object getProperty(String name); - - /** - * Get all property names. - * @return A set of property names. - */ - Set<String> getPropertyNames(); - - /** - * Get a named property and convert it into the given type. - * This method does not support conversion into a primitive type or an - * array of a primitive type. It should return <code>null</code> in this - * case. - * - * @param name The name of the property - * @param type The class of the type - * @param <T> The class of the type - * @return Return named value converted to type T or <code>null</code> if - * non existing or can't be converted. - */ - <T> T getProperty(String name, Class<T> type); - - /** - * Get a named property and convert it into the given type. - * This method does not support conversion into a primitive type or an - * array of a primitive type. It should return the default value in this - * case. - * - * @param name The name of the property - * @param defaultValue The default value to use if the named property does - * not exist or cannot be converted to the requested type. The - * default value is also used to define the type to convert the - * value to. If this is <code>null</code> any existing property is - * not converted. - * @param <T> The class of the type - * @return Return named value converted to type T or the default value if - * non existing or can't be converted. - */ - <T> T getProperty(String name, T defaultValue); - - /** - * On first execution the value of this property is zero. - * This property is managed by the job handling. - * @return The retry count. - */ - int getRetryCount(); - - /** - * The property to track the retry maximum retry count for jobs. - * This property is managed by the job handling. - * @return The number of retries. - */ - int getNumberOfRetries(); - - /** - * The name of the job queue processing this job. - * This property is set by the job handling when the job is processed. - * @return The queue name or <code>null</code> - */ - String getQueueName(); - - /** - * This property is set by the job handling and contains the Sling instance ID - * of the instance where this job should be processed. - * @return The sling ID or <code>null</code> - */ - String getTargetInstance(); - - /** - * This property is set by the job handling and contains a calendar object - * specifying the date and time when this job has been started. - * This property is only set if the job is currently in processing - * @return The time the processing started or {@code null}. - */ - Calendar getProcessingStarted(); - - /** - * This property is set by the job handling and contains a calendar object - * specifying the date and time when this job has been created. - * @return The time the job was created. - */ - Calendar getCreated(); - - /** - * This property is set by the job handling and contains the Sling instance ID - * of the instance where this job has been created. - * @return The instance id the job was created on - */ - String getCreatedInstance(); - - /** - * Get the job state - * @return The job state. - * @since 1.3 - */ - JobState getJobState(); - - /** - * If the job is cancelled or succeeded, this method will return the finish date. - * @return The finish date or <code>null</code> - * @since 1.3 - */ - Calendar getFinishedDate(); - - /** - * This method returns the message from the last job processing, regardless - * whether the processing failed, succeeded or was cancelled. The message - * is optional and can be set by a job consumer. - * @return The result message or <code>null</code> - * @since 1.3 - */ - String getResultMessage(); - - /** - * This method returns the optional progress log from the last job - * processing. The log is optional and can be set by a job consumer. - * @return The log or <code>null</code> - * @since 1.3 - */ - String[] getProgressLog(); - - /** - * If the job is in processing, return the optional progress step - * count if available. The progress information is optional and - * can be set by a job consumer. - * @return The progress step count or <code>-1</code>. - * @since 1.3 - */ - int getProgressStepCount(); - - /** - * If the job is in processing, return the optional information - * about the finished steps. This progress information is optional - * and can be set by a job consumer. - * In combination with {@link #getProgressStepCount()} this can - * be used to calculate a progress bar. - * @return The number of the finished progress step or <code>0</code> - * @since 1.3 - */ - int getFinishedProgressStep(); - - /** - * If the job is in processing, return the optional ETA for this job. - * The progress information is optional and can be set by a job consumer. - * @since 1.3 - * @return The estimated ETA or <code>null</code> - */ - Calendar getProgressETA(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/JobBuilder.java b/src/main/java/org/apache/sling/event/jobs/JobBuilder.java deleted file mode 100644 index 1455a61..0000000 --- a/src/main/java/org/apache/sling/event/jobs/JobBuilder.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * This is a builder interface to build jobs and scheduled jobs. - * Instances of this class can be retrieved using {@link JobManager#createJob(String)} - * - * @since 1.3 - */ -@ProviderType -public interface JobBuilder { - - /** - * Set the optional configuration properties for the job. - * @param props The properties of the job. All values must be {@code java.io.Serializable}. - * @return The job builder to continue building. - */ - JobBuilder properties(final Map<String, Object> props); - - /** - * Add the job. - * @return The job or <code>null</code> - * @see JobManager#addJob(String, Map) - */ - Job add(); - - /** - * Add the job. - * @param errors Optional list which will be filled with error messages. - * @return The job or <code>null</code> - * @see JobManager#addJob(String, Map) - */ - Job add(final List<String> errors); - - /** - * Schedule the job - * @return A schedule builder to schedule the jobs - */ - ScheduleBuilder schedule(); - - /** - * This is a builder interface for creating schedule information - */ - public interface ScheduleBuilder { - - /** - * Suspend this scheduling by default. - * Invoking this method several times has the same effect as calling it just once. - * @return The schedule builder to continue building. - */ - ScheduleBuilder suspend(); - - /** - * Schedule the job hourly at the given minute. - * If the minutes argument is less than 0 or higher than 59, the job can't be scheduled. - * @param minute Between 0 and 59. - * @return The schedule builder to continue building. - */ - ScheduleBuilder hourly(final int minute); - - /** - * Schedule the job daily at the given time. - * If a value less than zero for hour or minute is specified or a value higher than 23 for hour or - * a value higher than 59 for minute than the job can't be scheduled. - * @param hour Hour of the day ranging from 0 to 23. - * @param minute Minute of the hour ranging from 0 to 59. - * @return The schedule builder to continue building. - */ - ScheduleBuilder daily(final int hour, final int minute); - - /** - * Schedule the job weekly, the time needs to be specified in addition. - * If a value lower than 1 or higher than 7 is used for the day, the job can't be scheduled. - * If a value less than zero for hour or minute is specified or a value higher than 23 for hour or - * a value higher than 59 for minute than the job can't be scheduled. - * @param day Day of the week, 1:Sunday, 2:Monday, ... 7:Saturday. - * @param hour Hour of the day ranging from 0 to 23. - * @param minute Minute of the hour ranging from 0 to 59. - * @return The schedule builder to continue building. - */ - ScheduleBuilder weekly(final int day, final int hour, final int minute); - - /** - * Schedule the job monthly, the time needs to be specified in addition. - * If a value lower than 1 or higher than 28 is used for the day, the job can't be scheduled. - * If a value less than zero for hour or minute is specified or a value higher than 23 for hour or - * a value higher than 59 for minute than the job can't be scheduled. - * @param day Day of the month from 1 to 28. - * @param hour Hour of the day ranging from 0 to 23. - * @param minute Minute of the hour ranging from 0 to 59. - * @return The schedule builder to continue building. - */ - ScheduleBuilder monthly(final int day, final int hour, final int minute); - - /** - * Schedule the job yearly, the time needs to be specified in addition. - * If a value lower than 1 or higher than 12 is used for the month, the job can't be scheduled. - * If a value lower than 1 or higher than 28 is used for the day, the job can't be scheduled. - * If a value less than zero for hour or minute is specified or a value higher than 23 for hour or - * a value higher than 59 for minute than the job can't be scheduled. - * @param month Month of the year from 1 to 12. - * @param day Day of the month from 1 to 28. - * @param hour Hour of the day ranging from 0 to 23. - * @param minute Minute of the hour ranging from 0 to 59. - * @return The schedule builder to continue building. - */ - ScheduleBuilder yearly(final int month, final int day, final int hour, final int minute); - - /** - * Schedule the job for a specific date. - * If no date or a a date in the past is provided, the job can't be scheduled. - * @param date The date - * @return The schedule builder to continue building. - */ - ScheduleBuilder at(final Date date); - - /** - * Schedule the job for according to the cron expression. - * If no expression is specified, the job can't be scheduled. - * @param expression The cron expression - * @return The schedule builder to continue building. - */ - ScheduleBuilder cron(final String expression); - - /** - * Finally add the job to the schedule - * @return Returns the info object if the job could be scheduled, <code>null</code>otherwise. - */ - ScheduledJobInfo add(); - - /** - * Finally add the job to the schedule - * @param errors Optional list which will be filled with error messages. - * @return Returns the info object if the job could be scheduled, <code>null</code>otherwise. - */ - ScheduledJobInfo add(final List<String> errors); - } -} \ No newline at end of file diff --git a/src/main/java/org/apache/sling/event/jobs/JobManager.java b/src/main/java/org/apache/sling/event/jobs/JobManager.java deleted file mode 100644 index 105b611..0000000 --- a/src/main/java/org/apache/sling/event/jobs/JobManager.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import java.util.Collection; -import java.util.Map; - -import org.osgi.annotation.versioning.ProviderType; - - -/** - * The job manager is the heart of the job processing. - * <p> - * The job manager allows to create new jobs, search for - * jobs and get statistics about the current state. - * <p> - * The terminology used in the job manager is slightly - * different from common terminology: - * Each job has a topic and a topic is associated with - * a queue. Queues can be created through configuration - * and each queue can process one or more topics. - * - * @since 3.0 - */ -@ProviderType -public interface JobManager { - - /** - * Return statistics information about all queues. - * @return The statistics. - */ - Statistics getStatistics(); - - /** - * Return statistics information about job topics. - * @return The statistics for all topics. - */ - Iterable<TopicStatistics> getTopicStatistics(); - - /** - * Return a queue with a specific name (if running) - * @param name The queue name - * @return The queue or <code>null</code> - */ - Queue getQueue(String name); - - /** - * Return an iterator for all available queues. - * @return An iterator for all queues. - */ - Iterable<Queue> getQueues(); - - /** - * The requested job types for the query. - * This can either be all (unfinished) jobs, all activated (started) or all queued jobs. - */ - enum QueryType { - ALL, // all means all active and all queued - ACTIVE, - QUEUED, - HISTORY, // returns the complete history of cancelled and succeeded jobs (if available) - CANCELLED, // history of cancelled jobs (STOPPED, GIVEN_UP, ERROR, DROPPED) - SUCCEEDED, // history of succeeded jobs - STOPPED, // history of stopped jobs - GIVEN_UP, // history of given up jobs - ERROR, // history of jobs signaled CANCELLED or throw an exception - DROPPED // history of dropped jobs - } - - /** - * Add a new job - * - * If the topic is <code>null</code> or illegal, no job is created and <code>null</code> is returned. - * If properties are provided, all of them must be serializable. If there are non serializable - * objects in the properties, no job is created and <code>null</code> is returned. - * A job topic is a hierarchical name separated by dashes, each part has to start with a letter, - * allowed characters are letters, numbers and the underscore. - * - * The returned job object is a snapshot of the job state taken at the time of creation. Updates - * to the job state are not reflected and the client needs to get a new job object using the job id. - * - * If the queue for processing this job is configured to drop the job, <code>null</code> is returned - * as well. - * - * @param topic The required job topic. - * @param properties Optional job properties. The properties must be serializable. - * @return The new job - or <code>null</code> if the job could not be created. - * @since 1.2 - */ - Job addJob(String topic, Map<String, Object> properties); - - /** - * Return a job based on the unique id. - * - * The returned job object is a snapshot of the job state taken at the time of the call. Updates - * to the job state are not reflected and the client needs to get a new job object using the job id. - * - * @param jobId The unique identifier from {@link Job#getId()} - * @return A job or <code>null</code> - * @since 1.2 - */ - Job getJobById(String jobId); - - /** - * Removes the job even if it is currently in processing. - * - * If the job exists and is not in processing, it gets removed from the processing queue. - * If the job exists and is in processing, it is removed from the persistence layer, - * however processing is not stopped. - * - * @param jobId The unique identifier from {@link Job#getId()} - * @return <code>true</code> if the job could be removed or does not exist anymore. - * <code>false</code> otherwise. - * @since 1.2 - */ - boolean removeJobById(String jobId); - - /** - * Find a job - either queued or active. - * - * This method searches for a job with the given topic and filter properties. If more than one - * job matches, the first one found is returned which could be any of the matching jobs. - * - * The returned job object is a snapshot of the job state taken at the time of the call. Updates - * to the job state are not reflected and the client needs to get a new job object using the job id. - * - * @param topic Topic is required. - * @param template The map acts like a template. The searched job - * must match the template (AND query). - * @return A job or <code>null</code> - * @since 1.2 - */ - Job getJob(String topic, Map<String, Object> template); - - /** - * Return all jobs of a given type. - * - * Based on the type parameter, either the history of jobs can be returned or unfinished jobs. The type - * parameter can further specify which category of jobs should be returned: for the history either - * succeeded jobs, cancelled jobs or both in combination can be returned. For unfinished jobs, either - * queued jobs, started jobs or the combination can be returned. - * If the history is returned, the result set is sorted in descending order, listening the newest entry - * first. For unfinished jobs, the result set is sorted in ascending order. - * - * The returned job objects are a snapshot of the jobs state taken at the time of the call. Updates - * to the job states are not reflected and the client needs to get new job objects. - * - * @param type Required parameter for the type. See above. - * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned. - * @param limit A positive number indicating the maximum number of jobs returned by the iterator. A value - * of zero or less indicates that all jobs should be returned. - * @param templates A list of filter property maps. Each map acts like a template. The searched job - * must match the template (AND query). By providing several maps, different filters - * are possible (OR query). - * @return A collection of jobs - the collection might be empty. - * @since 1.2 - */ - Collection<Job> findJobs(QueryType type, String topic, long limit, Map<String, Object>... templates); - - /** - * Stop a job. - * When a job is stopped and the job consumer supports stopping the job processing, it is up - * to the job consumer how the stopping is handled. The job can be marked as finished successful, - * permanently failed or being retried. - * @param jobId The job id - * @since 1.3 - */ - void stopJobById(String jobId); - - /** - * Retry a cancelled job. - * If a job has failed permanently it can be requeued with this method. The job will be - * removed from the history and put into the queue again. The new job will get a new job id. - * For all other jobs calling this method has no effect and it simply returns <code>null</code>. - * @param jobId The job id. - * @return If the job is requeued, the new job object otherwise <code>null</code> - */ - Job retryJobById(String jobId); - - /** - * Fluent API to create, start and schedule new jobs - * @param topic Required topic - * @return A job builder - * @since 1.3 - */ - JobBuilder createJob(final String topic); - - /** - * Return all available job schedules. - * @return A collection of scheduled job infos - * @since 1.3 - */ - Collection<ScheduledJobInfo> getScheduledJobs(); - - /** - * Return all matching available job schedules. - * @param topic Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned. - * @param limit A positive number indicating the maximum number of jobs returned by the iterator. A value - * of zero or less indicates that all jobs should be returned. - * @param templates A list of filter property maps. Each map acts like a template. The searched job - * must match the template (AND query). By providing several maps, different filters - * are possible (OR query). - * @return All matching scheduled job infos. - * @since 1.4 - */ - Collection<ScheduledJobInfo> getScheduledJobs(String topic, long limit, Map<String, Object>... templates); -} diff --git a/src/main/java/org/apache/sling/event/jobs/NotificationConstants.java b/src/main/java/org/apache/sling/event/jobs/NotificationConstants.java deleted file mode 100644 index 58c7c55..0000000 --- a/src/main/java/org/apache/sling/event/jobs/NotificationConstants.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - - -/** - * This class contains constants for event notifications. - * - * Notifications for jobs can only be received on the instance where the job - * action is taking place. They are not send to other instances using - * remove events. - * - * @since 1.3 - */ -public abstract class NotificationConstants { - - /** - * Asynchronous notification event when a job is started. - * The property {@link #NOTIFICATION_PROPERTY_JOB_TOPIC} contains the job topic, - * the property {@link #NOTIFICATION_PROPERTY_JOB_ID} contains the unique job id. - * The time stamp of the event (as a Long) is available from the property - * {@link org.osgi.service.event.EventConstants#TIMESTAMP}. - * The payload of the job is available as additional job specific properties. - */ - public static final String TOPIC_JOB_STARTED = "org/apache/sling/event/notification/job/START"; - - /** - * Asynchronous notification event when a job is finished. - * The property {@link #NOTIFICATION_PROPERTY_JOB_TOPIC} contains the job topic, - * the property {@link #NOTIFICATION_PROPERTY_JOB_ID} contains the unique job id. - * The time stamp of the event (as a Long) is available from the property - * {@link org.osgi.service.event.EventConstants#TIMESTAMP}. - * The payload of the job is available as additional job specific properties. - */ - public static final String TOPIC_JOB_FINISHED = "org/apache/sling/event/notification/job/FINISHED"; - - /** - * Asynchronous notification event when a job failed. - * If a job execution fails, it is rescheduled for another try. - * The property {@link #NOTIFICATION_PROPERTY_JOB_TOPIC} contains the job topic, - * the property {@link #NOTIFICATION_PROPERTY_JOB_ID} contains the unique job id. - * The time stamp of the event (as a Long) is available from the property - * {@link org.osgi.service.event.EventConstants#TIMESTAMP}. - * The payload of the job is available as additional job specific properties. - */ - public static final String TOPIC_JOB_FAILED = "org/apache/sling/event/notification/job/FAILED"; - - /** - * Asynchronous notification event when a job is cancelled. - * If a job execution is cancelled it is not rescheduled. - * The property {@link #NOTIFICATION_PROPERTY_JOB_TOPIC} contains the job topic, - * the property {@link #NOTIFICATION_PROPERTY_JOB_ID} contains the unique job id. - * The time stamp of the event (as a Long) is available from the property - * {@link org.osgi.service.event.EventConstants#TIMESTAMP}. - * The payload of the job is available as additional job specific properties. - */ - public static final String TOPIC_JOB_CANCELLED = "org/apache/sling/event/notification/job/CANCELLED"; - - /** - * Asynchronous notification event when a job is permanently removed. - * The property {@link #NOTIFICATION_PROPERTY_JOB_TOPIC} contains the job topic, - * the property {@link #NOTIFICATION_PROPERTY_JOB_ID} contains the unique job id. - * The payload of the job is available as additional job specific properties. - */ - public static final String TOPIC_JOB_REMOVED = "org/apache/sling/event/notification/job/REMOVED"; - - /** - * Asynchronous notification event when a job is added. - * The property {@link #NOTIFICATION_PROPERTY_JOB_TOPIC} contains the job topic, - * the property {@link #NOTIFICATION_PROPERTY_JOB_ID} contains the unique job id. - * @since 1.6 - */ - public static final String TOPIC_JOB_ADDED = "org/apache/sling/event/notification/job/ADDED"; - - /** - * Property containing the job topic. Value is of type String. - * @see Job#getTopic() - */ - public static final String NOTIFICATION_PROPERTY_JOB_TOPIC = "event.job.topic"; - - /** - * Property containing the unique job ID. Value is of type String. - * @see Job#getId() - */ - public static final String NOTIFICATION_PROPERTY_JOB_ID = "slingevent:eventId"; - - private NotificationConstants() { - // avoid instantiation - } -} \ No newline at end of file diff --git a/src/main/java/org/apache/sling/event/jobs/Queue.java b/src/main/java/org/apache/sling/event/jobs/Queue.java deleted file mode 100644 index 2134aba..0000000 --- a/src/main/java/org/apache/sling/event/jobs/Queue.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import org.osgi.annotation.versioning.ProviderType; - - -/** - * This is a job queue processing job events. - * @since 3.0 - */ -@ProviderType -public interface Queue { - - /** - * Get the queue name. - * @return The queue name - */ - String getName(); - - /** - * Return statistics information about this queue. - * @return The queue statistics - */ - Statistics getStatistics(); - - /** - * Get the corresponding configuration. - * @return The queue configuration - */ - QueueConfiguration getConfiguration(); - - /** - * Suspend the queue - when a queue is suspended it stops processing - * jobs - however already started jobs are finished (but not rescheduled). - * Depending on the queue implementation, the queue is only suspended - * for a specific time. - * A queue can be resumed with {@link #resume()}. - */ - void suspend(); - - /** - * Resume a suspended queue. {@link #suspend()}. If the queue is not - * suspended, calling this method has no effect. - * Depending on the queue implementation, if a job failed a job queue might - * sleep for a configured time, before a new job is processed. By calling this - * method, the job queue can be woken up and force an immediate reprocessing. - * This feature is only supported by ordered queues at the moment. If a queue - * does not support this feature, calling this method has only an effect if - * the queue is really suspended. - */ - void resume(); - - /** - * Is the queue currently suspended? - * @return {code true} if the queue is supsended - */ - boolean isSuspended(); - - /** - * Remove all outstanding jobs and delete them. This actually cancels - * all outstanding jobs. - */ - void removeAll(); - - /** - * Return some information about the current state of the queue. This - * method is meant to see the internal state of the queue for debugging - * or monitoring purposes. - * @return Additional state info - */ - String getStateInfo(); - - /** - * For monitoring purposes and possible extensions from the different - * queue types. This method allows to query state information. - * @param key The key for the state - * @return The state or {@code null}. - */ - Object getState(final String key); -} diff --git a/src/main/java/org/apache/sling/event/jobs/QueueConfiguration.java b/src/main/java/org/apache/sling/event/jobs/QueueConfiguration.java deleted file mode 100644 index 8990289..0000000 --- a/src/main/java/org/apache/sling/event/jobs/QueueConfiguration.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import org.osgi.annotation.versioning.ProviderType; - - -/** - * The configuration of a queue. - * @since 3.0 - */ -@ProviderType -public interface QueueConfiguration { - - /** The queue type. */ - static enum Type { - UNORDERED, // unordered, parallel processing (push) - ORDERED, // ordered, FIFO (push) - TOPIC_ROUND_ROBIN // unordered, parallel processing, executed based on topic (push) - } - - /** - * The thread priority. - * @since 1.3 - */ - static enum ThreadPriority { - NORM, - MIN, - MAX - } - - /** - * Return the retry delay in ms - * @return The retry delay - */ - long getRetryDelayInMs(); - - /** - * Return the max number of retries, -1 for endless retry! - * @return Max number of retries - */ - int getMaxRetries(); - - /** - * Return the queue type. - * @return The queue type - */ - Type getType(); - - /** - * Return the thread priority for the job thread - * @return Thread priority - */ - ThreadPriority getThreadPriority(); - - /** - * Return the max number of parallel processes. - * @return Max parallel processes - */ - int getMaxParallel(); - - /** - * The list of topics this queue is bound to. - * @return All topics for this queue. - */ - String[] getTopics(); - - /** - * Whether successful jobs are kept for a complete history - * @return <code>true</code> if successful jobs are kept. - * @since 1.3 - */ - boolean isKeepJobs(); - - /** - * Return the size for the optional thread pool for this queue. - * @return A positive number or <code>0</code> if the default thread pool - * should be used. - * @since 1.3 - */ - int getOwnThreadPoolSize(); - - /** - * Get the ranking of this configuration. - * @return The ranking - */ - int getRanking(); - - /** - * Prefer to run the job on the same instance it was created on. - * @return {@code true} if running on the creation instance is preferred. - * @since 1.4 - */ - boolean isPreferRunOnCreationInstance(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/ScheduleInfo.java b/src/main/java/org/apache/sling/event/jobs/ScheduleInfo.java deleted file mode 100644 index bb390cb..0000000 --- a/src/main/java/org/apache/sling/event/jobs/ScheduleInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import java.util.Date; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * Scheduling information. - * @since 1.3 - */ -@ProviderType -public interface ScheduleInfo { - - enum ScheduleType { - DATE, // scheduled for a date - HOURLY, // scheduled hourly - DAILY, // scheduled once a day - WEEKLY, // scheduled once a week - MONTHLY, // scheduled once a month - YEARLY, // scheduled once a year, - CRON // scheduled according to the cron expression - } - - /** - * Return the scheduling type - * @return The scheduling type - */ - ScheduleType getType(); - - /** - * Return the scheduled execution date for a schedule of type date. - * @return the scheduled execution date - */ - Date getAt(); - - /** - * If the schedule is a cron expression, return the expression. - * @return The cron expression or <code>null</code> - */ - String getExpression(); - - /** - * If the job is scheduled yearly, returns the month of the year - * @return The day of the year (from 1 to 12) or -1 - */ - int getMonthOfYear(); - - /** - * If the job is scheduled monthly, returns the day of the month - * @return The day of the month (from 1 to 28) or -1 - */ - int getDayOfMonth(); - - /** - * If the job is scheduled weekly, returns the day of the week - * @return The day of the week (from 1 to 7) or -1 - */ - int getDayOfWeek(); - - /** - * Return the hour of the day for daily and weekly scheduled jobs - * @return The hour of the day (from 0 to 23) or -1 - */ - int getHourOfDay(); - - /** - * Return the minute of the hour for daily, weekly and hourly scheduled jobs. - * @return The minute of the hour (from 0 to 59) or -1 - */ - int getMinuteOfHour(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/ScheduledJobInfo.java b/src/main/java/org/apache/sling/event/jobs/ScheduledJobInfo.java deleted file mode 100644 index 4d37c8b..0000000 --- a/src/main/java/org/apache/sling/event/jobs/ScheduledJobInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import java.util.Collection; -import java.util.Date; -import java.util.Map; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * Information about a scheduled job - * @since 1.3 - */ -@ProviderType -public interface ScheduledJobInfo { - - /** - * Get all schedules for this job - * @return A non null and non empty list of schedules. - */ - Collection<ScheduleInfo> getSchedules(); - - /** - * Return the next scheduled execution date. - * @return the next scheduled execution date. - */ - Date getNextScheduledExecution(); - - /** - * Return the job topic. - * @return The job topic - */ - String getJobTopic(); - - /** - * Return the optional job topics. - * @return The job topics or <code>null</code> - */ - Map<String, Object> getJobProperties(); - - /** - * Unschedule this scheduled job. - */ - void unschedule(); - - /** - * Reschedule this job with a new rescheduling information. - * If rescheduling fails (due to wrong arguments), the job - * schedule is left as is. - * @return The schedule builder - */ - JobBuilder.ScheduleBuilder reschedule(); - - /** - * Suspend this job scheduling. - * Job scheduling can be resumed with {@link #resume()}. - * This information is persisted and survives a restart. - */ - void suspend(); - - /** - * Resume job processing. {@link #suspend()}. If the queue is not - * suspended, calling this method has no effect. - */ - void resume(); - - /** - * Is the processing currently suspended? - * @return {@code true} if processing is suspended. - */ - boolean isSuspended(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/Statistics.java b/src/main/java/org/apache/sling/event/jobs/Statistics.java deleted file mode 100644 index 66b8d55..0000000 --- a/src/main/java/org/apache/sling/event/jobs/Statistics.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * Statistic information. - * This information is not preserved between restarts of the service. - * Once a service is restarted, the counters start at zero! - * @since 3.0 - */ -@ProviderType -public interface Statistics { - - /** - * The time this service has been started - * @return The time this service has been started - */ - long getStartTime(); - - /** - * Number of successfully finished jobs. - * @return Number of successfully finished jobs. - */ - long getNumberOfFinishedJobs(); - - /** - * Number of permanently failing or cancelled jobs. - * @return Number of permanently failing or cancelled jobs - */ - long getNumberOfCancelledJobs(); - - /** - * Number of failing jobs. - * @return Number of failing jobs. - */ - long getNumberOfFailedJobs(); - - /** - * Number of already processed jobs. This adds - * {@link #getNumberOfFinishedJobs()}, {@link #getNumberOfCancelledJobs()} - * and {@link #getNumberOfFailedJobs()} - * @return Number of already processed jobs - */ - long getNumberOfProcessedJobs(); - - /** - * Number of jobs currently in processing. - * @return Number of jobs currently in processing. - */ - long getNumberOfActiveJobs(); - - /** - * Number of jobs currently waiting in a queue. - * @return Number of jobs currently waiting in a queue. - */ - long getNumberOfQueuedJobs(); - - /** - * This just adds {@link #getNumberOfActiveJobs()} and {@link #getNumberOfQueuedJobs()} - * @return The number of jobs - */ - long getNumberOfJobs(); - - /** - * The time a job has been started last. - * @return The time a job has been started last. - */ - long getLastActivatedJobTime(); - - /** - * The time a job has been finished/failed/cancelled last. - * @return The time a job has been finished/failed/cancelled last. - */ - long getLastFinishedJobTime(); - - /** - * The average waiting time of a job in the queue. - * @return The average waiting time of a job in the queue. - */ - long getAverageWaitingTime(); - - /** - * The average processing time of a job - this only counts finished jobs. - * @return The average processing time of a job - */ - long getAverageProcessingTime(); - - /** - * Clear all collected statistics and set the starting time to the current time. - * Note that not all fields are cleared, last waiting time or number of active and queued - * jobs is not cleared as these are currently used. - */ - void reset(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/TopicStatistics.java b/src/main/java/org/apache/sling/event/jobs/TopicStatistics.java deleted file mode 100644 index 0fed27a..0000000 --- a/src/main/java/org/apache/sling/event/jobs/TopicStatistics.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * Statistic information about a topic. - * This information is not preserved between restarts of the service. - * Once a service is restarted, the counters start at zero! - * @since 3.0 - */ -@ProviderType -public interface TopicStatistics { - - /** - * The topic this statistics is about. - * @return The topic name - */ - String getTopic(); - - /** - * Number of successfully finished jobs. - * @return Number of successfully finished jobs. - */ - long getNumberOfFinishedJobs(); - - /** - * Number of permanently failing or cancelled jobs. - * @return Number of permanently failing or cancelled jobs. - */ - long getNumberOfCancelledJobs(); - - /** - * Number of failing jobs. - * @return Number of failing jobs. - */ - long getNumberOfFailedJobs(); - - /** - * Number of already processed jobs. This adds - * {@link #getNumberOfFinishedJobs()}, {@link #getNumberOfCancelledJobs()} - * and {@link #getNumberOfFailedJobs()} - * @return Number of already processed jobs. - */ - long getNumberOfProcessedJobs(); - - /** - * The time a job has been started last. - * @return The time a job has been started last. - */ - long getLastActivatedJobTime(); - - /** - * The time a job has been finished/failed/cancelled last. - * @return The time a job has been finished/failed/cancelled last. - */ - long getLastFinishedJobTime(); - - /** - * The average waiting time of a job in the queue. - * @return The average waiting time of a job in the queue. - */ - long getAverageWaitingTime(); - - /** - * The average processing time of a job - this only counts finished jobs. - * @return The average processing time of a job - */ - long getAverageProcessingTime(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/consumer/JobConsumer.java b/src/main/java/org/apache/sling/event/jobs/consumer/JobConsumer.java deleted file mode 100644 index 8e783d1..0000000 --- a/src/main/java/org/apache/sling/event/jobs/consumer/JobConsumer.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs.consumer; - -import org.apache.sling.event.jobs.Job; - -import org.osgi.annotation.versioning.ConsumerType; - - - -/** - * A job consumer consumes a job. - * <p> - * If the job consumer needs more features like providing progress information or adding - * more information of the processing, {@link JobExecutor} should be implemented instead. - * <p> - * A job consumer registers itself with the {@link #PROPERTY_TOPICS} service registration - * property. The value of this property defines which topics a consumer is able to process. - * Each string value of this property is either - * <ul> - * <li>a job topic, or - * <li>a topic category ending with "/*" which means all topics in this category, or - * <li>a topic category ending with "/**" which means all topics in this category and all - * sub categories. This matching is new since version 1.2. - * </ul> - * A consumer registering for just "*" or "**" is not considered. - * <p> - * For example, the value {@code org/apache/sling/jobs/*} matches the topics - * {@code org/apache/sling/jobs/a} and {@code org/apache/sling/jobs/b} but neither - * {@code org/apache/sling/jobs} nor {@code org/apache/sling/jobs/subcategory/a}. A value of - * {@code org/apache/sling/jobs/**} matches the same topics but also all sub topics - * like {@code org/apache/sling/jobs/subcategory/a} or {@code org/apache/sling/jobs/subcategory/a/c/d}. - * <p> - * If there is more than one job consumer or executor registered for a job topic, the selection is as - * follows: - * <ul> - * <li>If there is a single consumer registering for the exact topic, this one is used. - * <li>If there is more than a single consumer registering for the exact topic, the one - * with the highest service ranking is used. If the ranking is equal, the one with - * the lowest service ID is used. - * <li>If there is a single consumer registered for the category, it is used. - * <li>If there is more than a single consumer registered for the category, the service - * with the highest service ranking is used. If the ranking is equal, the one with - * the lowest service ID is used. - * <li>The search continues with consumer registered for deep categories. The nearest one - * is tried next. If there are several, the one with the highest service ranking is - * used. If the ranking is equal, the one with the lowest service ID is used. - * </ul> - * <p> - * If the consumer decides to process the job asynchronously, the processing must finish - * within the current lifetime of the job consumer. If the consumer (or the instance - * of the consumer) dies, the job processing will mark this processing as failed and - * reschedule. - * - * @since 1.0 - */ -@ConsumerType -public interface JobConsumer { - - /** - * The result of the job processing. - */ - enum JobResult { - /** Processing finished successfully. */ - OK, - /** Processing failed but might be retried. */ - FAILED, - /** Processing failed permanently and must not be retried. */ - CANCEL, - /** Processing will be done asynchronously. */ - ASYNC - } - - /** Job property containing an asynchronous handler. */ - String PROPERTY_JOB_ASYNC_HANDLER = ":sling:jobs:asynchandler"; - - /** - * If the consumer decides to process the job asynchronously, this handler - * interface can be used to notify finished processing. The asynchronous - * handler can be retried using the property name {@link #PROPERTY_JOB_ASYNC_HANDLER}. - */ - interface AsyncHandler { - - void failed(); - - void ok(); - - void cancel(); - } - - /** - * Service registration property defining the jobs this consumer is able to process. - * The value is either a string or an array of strings. - */ - String PROPERTY_TOPICS = "job.topics"; - - - /** - * Execute the job. - * <p> - * If the job has been processed successfully, {@link JobResult#OK} should be returned. - * If the job has not been processed completely, but might be rescheduled {@link JobResult#FAILED} - * should be returned. - * If the job processing failed and should not be rescheduled, {@link JobResult#CANCEL} should - * be returned. - * <p> - * If the consumer decides to process the job asynchronously it should return {@link JobResult#ASYNC} - * and notify the job manager by using the {@link AsyncHandler} interface. - * <p> - * If the processing fails with throwing an exception/throwable, the process will not be rescheduled - * and treated like the method would have returned {@link JobResult#CANCEL}. - * - * @param job The job - * @return The job result - */ - JobResult process(Job job); -} diff --git a/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java b/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java deleted file mode 100644 index 9370922..0000000 --- a/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionContext.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs.consumer; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * - * @since 1.1 - */ -@ProviderType -public interface JobExecutionContext { - - /** - * Report an async result. - * @param result Tje job execution result - * @throws IllegalStateException If the job is not processed asynchronously - * or if this method has already been called. - */ - void asyncProcessingFinished(JobExecutionResult result); - - /** - * If a job is stoppable, it should periodically check this method - * and stop processing if the method return <code>true</code>. - * If a job is stopped and the job executor detects this, its up - * to the implementation to decide the result of such a state. - * There might be use cases where the job returns {@link JobExecutionResult#succeeded()} - * although it didn't process everything, or {@link JobExecutionResult#failed()} - * to retry later on or {@link JobExecutionResult#cancelled()}. - * - * @return Whether this job has been stopped from the outside. - */ - boolean isStopped(); - - /** - * Indicate that the job executor is able to report the progress. - * The progress can either be reported by a step count, - * assuming that all steps take roughly the same amount of time. - * Or the progress can be reported by an ETA containing the number - * of seconds the job needs to finish. - * This method should only be called once, consecutive calls - * have no effect. - * By using a step count of 100, the progress can be displayed - * in percentage. - * @param steps Number of total steps or -1 if the number of - * steps is unknown. - * @param eta Number of seconds the process should take or - * -1 of it's not known now. - */ - void initProgress(int steps, long eta); - - /** - * Update the progress by additionally marking the provided - * number of steps as finished. If the total number of finished - * steps is equal or higher to the initial number of steps - * reported in {@link #initProgress(int, long)}, then the - * job progress is assumed to be 100%. - * This method has only effect if {@link #initProgress(int, long)} - * has been called first with a positive number for steps - * @param steps The number of finished steps since the last call. - */ - void incrementProgressCount(int steps); - - /** - * Update the progress to the new ETA. - * This method has only effect if {@link #initProgress(int, long)} - * has been called first. - * @param eta The new ETA - */ - void updateProgress(long eta); - - /** - * Log a message. - * A job consumer can use this method during job processing to add additional information - * about the current state of job processing. - * As calling this method adds a significant overhead it should only - * be used to log a few statements per job processing. If a consumer wants - * to output detailed information about the processing it should persists it - * by itself and not use this method for it. - * The message and the arguments are passed to the {@link java.text.MessageFormat} - * class. - * @param message A message - * @param args Additional arguments - */ - void log(String message, Object...args); - - /** - * Build a result for the processing. - * @return The build for the result - */ - ResultBuilder result(); - - public interface ResultBuilder { - - /** - * Add an optional processing message. - * This message can be viewed using {@link org.apache.sling.event.jobs.Job#getResultMessage()}. - * @param message The message - * @return The builder to continue building the result. - */ - ResultBuilder message(String message); - - /** - * The job processing finished successfully. - * @return The job execution result. - */ - JobExecutionResult succeeded(); - - /** - * The job processing failed and might be retried. - * @return The job execution result. - */ - JobExecutionResult failed(); - - /** - * The job processing failed and might be retried. - * @param retryDelayInMs The new retry delay in ms. - * @return The job execution result - */ - JobExecutionResult failed(long retryDelayInMs); - - /** - * The job processing failed permanently. - * @return The job execution result - */ - JobExecutionResult cancelled(); - } -} diff --git a/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionResult.java b/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionResult.java deleted file mode 100644 index c3da0f0..0000000 --- a/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutionResult.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs.consumer; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * The status of a job after it has been processed by a {@link JobExecutor}. - * The job executor uses the {@link JobExecutionContext} to create a result object. - * - * The result can have three states, succeeded, cancelled or failed whereas - * failed means that the execution is potentially retried. - * - * @since 1.1 - */ -@ProviderType -public interface JobExecutionResult { - - /** - * If this returns true the job processing finished successfully. - * In this case {@link #cancelled()} and {@link #failed()} return - * <code>false</code> - * @return <code>true</code> for a successful processing - */ - boolean succeeded(); - - /** - * If this returns true the job processing failed permanently. - * In this case {@link #succeeded()} and {@link #failed()} return - * <code>false</code> - * @return <code>true</code> for a permanently failed processing - */ - boolean cancelled(); - - /** - * If this returns true the job processing failed but might be - * retried.. - * In this case {@link #cancelled()} and {@link #succeeded()} return - * <code>false</code> - * @return <code>true</code> for a failedl processing - */ - boolean failed(); - - /** - * Return the optional message. - * @return The message or <code>null</code> - */ - String getMessage(); - - /** - * Return the retry delay in ms - * @return The new retry delay (>= 0) or <code>null</code> - */ - Long getRetryDelayInMs(); -} diff --git a/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java b/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java deleted file mode 100644 index b720546..0000000 --- a/src/main/java/org/apache/sling/event/jobs/consumer/JobExecutor.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sling.event.jobs.consumer; - -import org.apache.sling.event.jobs.Job; - -import org.osgi.annotation.versioning.ConsumerType; - -/** - * A job executor consumes a job. - * <p> - * A job executor registers itself with the {@link #PROPERTY_TOPICS} service registration - * property. The value of this property defines which topics an executor is able to process. - * Each string value of this property is either - * <ul> - * <li>a job topic, or - * <li>a topic category ending with "/*" which means all topics in this category, or - * <li>a topic category ending with "/**" which means all topics in this category and all - * sub categories. This matching is new since version 1.2. - * </ul> - * A consumer registering for just "*" or "**" is not considered. - * <p> - * For example, the value {@code org/apache/sling/jobs/*} matches the topics - * {@code org/apache/sling/jobs/a} and {@code org/apache/sling/jobs/b} but neither - * {@code org/apache/sling/jobs} nor {@code org/apache/sling/jobs/subcategory/a}. A value of - * {@code org/apache/sling/jobs/**} matches the same topics but also all sub topics - * like {@code org/apache/sling/jobs/subcategory/a} or {@code org/apache/sling/jobs/subcategory/a/c/d}. - * <p> - * If there is more than one job consumer or executor registered for a job topic, the selection is as - * follows: - * <ul> - * <li>If there is a single consumer registering for the exact topic, this one is used. - * <li>If there is more than a single consumer registering for the exact topic, the one - * with the highest service ranking is used. If the ranking is equal, the one with - * the lowest service ID is used. - * <li>If there is a single consumer registered for the category, it is used. - * <li>If there is more than a single consumer registered for the category, the service - * with the highest service ranking is used. If the ranking is equal, the one with - * the lowest service ID is used. - * <li>The search continues with consumer registered for deep categories. The nearest one - * is tried next. If there are several, the one with the highest service ranking is - * used. If the ranking is equal, the one with the lowest service ID is used. - * </ul> - * <p> - * If the executor decides to process the job asynchronously, the processing must finish - * within the current lifetime of the job executor. If the executor (or the instance - * of the executor) dies, the job processing will mark this processing as failed and - * reschedule. - * - * @since 1.1 - */ -@ConsumerType -public interface JobExecutor { - - /** - * Service registration property defining the jobs this executor is able to process. - * The value is either a string or an array of strings. - */ - String PROPERTY_TOPICS = "job.topics"; - - /** - * Execute the job. - * - * If the job has been processed successfully, a job result of "succeeded" should be returned. This result can - * be generated by calling <code>JobExecutionContext.result().succeeded()</code> - * - * If the job has not been processed completely, but might be rescheduled "failed" should be returned. - * This result can be generated by calling <code>JobExecutionContext.result().failed()</code>. - * - * If the job processing failed and should not be rescheduled, "cancelled" should be returned. - * This result can be generated by calling <code>JobExecutionContext.result().cancelled()</code>. - * - * If the executor decides to process the job asynchronously it should return <code>null</code> - * and notify the job manager by using the {@link JobExecutionContext#asyncProcessingFinished(JobExecutionResult)} - * method of the processing result. - * - * If the processing fails with throwing an exception/throwable, the process will not be rescheduled - * and treated like the method would have returned a "cancelled" result. - * - * Additional information can be added to the result by using the builder pattern available - * from {@link JobExecutionContext#result()}. - * - * @param job The job - * @param context The execution context. - * @return The job execution result or <code>null</code> for asynchronous processing. - */ - JobExecutionResult process(Job job, JobExecutionContext context); -} diff --git a/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java b/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java deleted file mode 100644 index 5237caa..0000000 --- a/src/main/java/org/apache/sling/event/jobs/consumer/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - [email protected]("1.2.1") -package org.apache.sling.event.jobs.consumer; - - diff --git a/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java b/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java deleted file mode 100644 index 9e8af7d..0000000 --- a/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The SF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package org.apache.sling.event.jobs.jmx; - -/** - * A Marker interface to allow the implementation to register as a service with - * the JMX whiteboard. - */ -public interface QueuesMBean { - - String[] getQueueNames(); - -} diff --git a/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java b/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java deleted file mode 100644 index 321f574..0000000 --- a/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The SF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package org.apache.sling.event.jobs.jmx; - -import java.util.Date; - -import org.apache.sling.event.jobs.Statistics; - -public interface StatisticsMBean extends Statistics { - - Date getLastActivatedJobDate(); - - Date getLastFinishedJobDate(); - - Date getStartDate(); - - String getName(); - -} diff --git a/src/main/java/org/apache/sling/event/jobs/jmx/package-info.java b/src/main/java/org/apache/sling/event/jobs/jmx/package-info.java deleted file mode 100644 index 515bde1..0000000 --- a/src/main/java/org/apache/sling/event/jobs/jmx/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - [email protected]("1.0.1") -package org.apache.sling.event.jobs.jmx; - - diff --git a/src/main/java/org/apache/sling/event/jobs/package-info.java b/src/main/java/org/apache/sling/event/jobs/package-info.java deleted file mode 100644 index 6ea3e5c..0000000 --- a/src/main/java/org/apache/sling/event/jobs/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - [email protected]("2.0.1") -package org.apache.sling.event.jobs; - - -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
