public class DirectSchedulerFactory extends Object implements ISchedulerFactory
A singleton implementation of
.
ISchedulerFactory
Here are some examples of using this class:
To create a scheduler that does not write anything to the database (is not
persistent), you can call createVolatileScheduler:
DirectSchedulerFactory.getInstance ().createVolatileScheduler (10); // 10
// threads
// * //
// don't
// forget
// to
// start
// the
// scheduler:
// DirectSchedulerFactory.getInstance().getScheduler().start();
Several create methods are provided for convenience. All create methods eventually end up calling the create method with all the parameters:
public void createScheduler(String schedulerName, String schedulerInstanceId, ThreadPool threadPool, JobStore jobStore, String rmiRegistryHost, int rmiRegistryPort)
Here is an example of using this method:
* *
// create the thread pool SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads, Thread.NORM_PRIORITY); threadPool.initialize(); * // create the job store JobStore jobStore = new RAMJobStore();
DirectSchedulerFactory.getInstance().createScheduler("My Quartz Scheduler", "My Instance", threadPool, jobStore, "localhost", 1099); * // don't forget to start the scheduler: DirectSchedulerFactory.getInstance().getScheduler("My Quartz Scheduler", "My Instance").start();
You can also use a JDBCJobStore instead of the RAMJobStore:
DBConnectionManager.getInstance ()
.addConnectionProvider ("someDatasource", new JNDIConnectionProvider ("someDatasourceJNDIName"));
JobStoreTX jdbcJobStore = new JobStoreTX ();
jdbcJobStore.setDataSource ("someDatasource");
jdbcJobStore.setPostgresStyleBlobs (true);
jdbcJobStore.setTablePrefix ("QRTZ_");
jdbcJobStore.setInstanceId ("My Instance");
IJobStore,
IThreadPool| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_INSTANCE_ID |
static String |
DEFAULT_SCHEDULER_NAME |
| Modifier | Constructor and Description |
|---|---|
protected |
DirectSchedulerFactory()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
createScheduler(IThreadPool threadPool,
IJobStore jobStore)
Creates a scheduler using the specified thread pool and job store.
|
void |
createScheduler(String schedulerName,
String schedulerInstanceId,
IThreadPool threadPool,
IJobStore jobStore)
Same as
createScheduler(IThreadPool threadPool, IJobStore jobStore),
with the addition of specifying the scheduler name and instance ID. |
void |
createScheduler(String schedulerName,
String schedulerInstanceId,
IThreadPool threadPool,
IJobStore jobStore,
long idleWaitTime)
Creates a scheduler using the specified thread pool and job store and binds
it to RMI.
|
void |
createScheduler(String schedulerName,
String schedulerInstanceId,
IThreadPool threadPool,
IJobStore jobStore,
Map<String,ISchedulerPlugin> schedulerPluginMap,
long idleWaitTime)
Creates a scheduler using the specified thread pool, job store, and
plugins, and binds it to RMI.
|
void |
createScheduler(String schedulerName,
String schedulerInstanceId,
IThreadPool threadPool,
IThreadExecutor threadExecutor,
IJobStore jobStore,
Map<String,ISchedulerPlugin> schedulerPluginMap,
long idleWaitTime)
Creates a scheduler using the specified thread pool, job store, and
plugins, and binds it to RMI.
|
void |
createScheduler(String schedulerName,
String schedulerInstanceId,
IThreadPool threadPool,
IThreadExecutor threadExecutor,
IJobStore jobStore,
Map<String,ISchedulerPlugin> schedulerPluginMap,
long idleWaitTime,
int maxBatchSize,
long batchTimeWindow)
Creates a scheduler using the specified thread pool, job store, and
plugins, and binds it to RMI.
|
void |
createVolatileScheduler(int nMaxThreads)
Creates an in memory job store (
) The
thread priority is set to Thread.NORM_PRIORITY |
com.helger.commons.collection.impl.ICommonsCollection<IScheduler> |
getAllSchedulers()
Returns a handle to all known Schedulers (made by any StdSchedulerFactory
instance.).
|
static DirectSchedulerFactory |
getInstance() |
IScheduler |
getScheduler()
Returns a handle to the Scheduler produced by this factory.
|
IScheduler |
getScheduler(String schedName)
Returns a handle to the Scheduler with the given name, if it exists.
|
public static final String DEFAULT_INSTANCE_ID
public static final String DEFAULT_SCHEDULER_NAME
@Nonnull public static DirectSchedulerFactory getInstance()
public void createVolatileScheduler(int nMaxThreads)
throws SchedulerException
RAMJobStore) The
thread priority is set to Thread.NORM_PRIORITYnMaxThreads - The number of threads in the thread poolSchedulerException - if initialization failed.public void createScheduler(IThreadPool threadPool, IJobStore jobStore) throws SchedulerException
getScheduler()threadPool - The thread pool for executing jobsjobStore - The type of job storeSchedulerException - if initialization failedpublic void createScheduler(String schedulerName, String schedulerInstanceId, IThreadPool threadPool, IJobStore jobStore) throws SchedulerException
createScheduler(IThreadPool threadPool, IJobStore jobStore),
with the addition of specifying the scheduler name and instance ID. This
scheduler can only be retrieved via
getScheduler(String)schedulerName - The name for the scheduler.schedulerInstanceId - The instance ID for the scheduler.threadPool - The thread pool for executing jobsjobStore - The type of job storeSchedulerException - if initialization failedpublic void createScheduler(String schedulerName, String schedulerInstanceId, IThreadPool threadPool, IJobStore jobStore, long idleWaitTime) throws SchedulerException
schedulerName - The name for the scheduler.schedulerInstanceId - The instance ID for the scheduler.threadPool - The thread pool for executing jobsjobStore - The type of job storeidleWaitTime - The idle wait time in milliseconds. You can specify "-1" for the
default value, which is currently 30000 ms.SchedulerException - if initialization failedpublic void createScheduler(String schedulerName, String schedulerInstanceId, IThreadPool threadPool, IJobStore jobStore, Map<String,ISchedulerPlugin> schedulerPluginMap, long idleWaitTime) throws SchedulerException
schedulerName - The name for the scheduler.schedulerInstanceId - The instance ID for the scheduler.threadPool - The thread pool for executing jobsjobStore - The type of job storeschedulerPluginMap - Map from a String plugin names to
ISchedulerPlugins. Can
use "null" if no plugins are required.idleWaitTime - The idle wait time in milliseconds. You can specify "-1" for the
default value, which is currently 30000 ms.SchedulerException - if initialization failedpublic void createScheduler(String schedulerName, String schedulerInstanceId, IThreadPool threadPool, IThreadExecutor threadExecutor, IJobStore jobStore, Map<String,ISchedulerPlugin> schedulerPluginMap, long idleWaitTime) throws SchedulerException
schedulerName - The name for the scheduler.schedulerInstanceId - The instance ID for the scheduler.threadPool - The thread pool for executing jobsthreadExecutor - The thread executor for executing jobsjobStore - The type of job storeschedulerPluginMap - Map from a String plugin names to
ISchedulerPlugins. Can
use "null" if no plugins are required.idleWaitTime - The idle wait time in milliseconds. You can specify "-1" for the
default value, which is currently 30000 ms.SchedulerException - if initialization failedpublic void createScheduler(String schedulerName, String schedulerInstanceId, IThreadPool threadPool, IThreadExecutor threadExecutor, IJobStore jobStore, Map<String,ISchedulerPlugin> schedulerPluginMap, long idleWaitTime, int maxBatchSize, long batchTimeWindow) throws SchedulerException
schedulerName - The name for the scheduler.schedulerInstanceId - The instance ID for the scheduler.threadPool - The thread pool for executing jobsthreadExecutor - The thread executor for executing jobsjobStore - The type of job storeschedulerPluginMap - Map from a String plugin names to
ISchedulerPlugins. Can
use "null" if no plugins are required.idleWaitTime - The idle wait time in milliseconds. You can specify "-1" for the
default value, which is currently 30000 ms.maxBatchSize - The maximum batch size of triggers, when acquiring thembatchTimeWindow - The time window for which it is allowed to "pre-acquire" triggers to
fireSchedulerException - if initialization failedpublic IScheduler getScheduler() throws SchedulerException
Returns a handle to the Scheduler produced by this factory.
you must call createRemoteScheduler or createScheduler methods before calling getScheduler()
getScheduler in interface ISchedulerFactorySchedulerException - if there is a problem with the underlying Scheduler.public IScheduler getScheduler(String schedName) throws SchedulerException
Returns a handle to the Scheduler with the given name, if it exists.
getScheduler in interface ISchedulerFactorySchedulerExceptionpublic com.helger.commons.collection.impl.ICommonsCollection<IScheduler> getAllSchedulers() throws SchedulerException
Returns a handle to all known Schedulers (made by any StdSchedulerFactory instance.).
getAllSchedulers in interface ISchedulerFactorySchedulerExceptionCopyright © 2016–2021 Philip Helger. All rights reserved.