下面列出了怎么用org.quartz.spi.JobStore的API类实例代码及写法,或者点击链接到github查看源代码。
@SuppressWarnings("squid:S00107") //suppress constructor parameter count
@Inject
public QuartzSchedulerSPI(final EventManager eventManager,
final NodeAccess nodeAccess,
final Provider<JobStore> jobStoreProvider,
final Provider<Scheduler> schedulerProvider,
final LastShutdownTimeService lastShutdownTimeService,
final DatabaseStatusDelayedExecutor delayedExecutor,
@Named("${nexus.quartz.recoverInterruptedJobs:-true}") final boolean recoverInterruptedJobs)
{
this.eventManager = checkNotNull(eventManager);
this.nodeAccess = checkNotNull(nodeAccess);
this.jobStoreProvider = checkNotNull(jobStoreProvider);
this.schedulerProvider = checkNotNull(schedulerProvider);
this.lastShutdownTimeService = checkNotNull(lastShutdownTimeService);
this.recoverInterruptedJobs = recoverInterruptedJobs;
this.delayedExecutor = checkNotNull(delayedExecutor);
this.scheduleFactory = new QuartzScheduleFactory();
this.triggerConverter = new QuartzTriggerConverter(this.scheduleFactory);
// FIXME: sort out with refinement to lifecycle below
this.active = true;
}
@Override
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs)
{
Scheduler scheduler = super.instantiate(rsrcs, qs);
JobStore jobStore = rsrcs.getJobStore();
if (jobStore instanceof SchedulerAware)
{
((SchedulerAware) jobStore).setScheduler(scheduler);
}
return scheduler;
}
/**
* Creates an in memory job store (<code>{@link RAMJobStore}</code>)
* The thread priority is set to Thread.NORM_PRIORITY
*
* @param maxThreads
* The number of threads in the thread pool
* @throws SchedulerException
* if initialization failed.
*/
public void createVolatileScheduler(int maxThreads)
throws SchedulerException {
SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads,
Thread.NORM_PRIORITY);
threadPool.initialize();
JobStore jobStore = new RAMJobStore();
this.createScheduler(threadPool, jobStore);
}
@Override
public JobStore get() {
JobStore localRef = jobStore;
if (localRef == null) {
synchronized (this) {
localRef = jobStore;
if (localRef == null) {
jobStore = localRef = createJobStore();
}
}
}
return localRef;
}
private JobStore createJobStore() {
try {
connectionProvider.initialize();
DBConnectionManager.getInstance().addConnectionProvider(QUARTZ_DS, connectionProvider);
JobStoreTX delegate = new JobStoreTX();
delegate.setDataSource(QUARTZ_DS);
delegate.setDriverDelegateClass(getDriverDelegateClass());
return delegate;
}
catch (Exception e) {
log.error("Unable create job store", e);
return null;
}
}
@Inject
public QuartzSchedulerProvider(final NodeAccess nodeAccess,
final Provider<JobStore> jobStore,
final JobFactory jobFactory,
@Named("${nexus.quartz.poolSize:-20}") final int threadPoolSize,
@Named("${nexus.quartz.taskThreadPriority:-5}") final int threadPriority)
{
this.nodeAccess = checkNotNull(nodeAccess);
this.jobStore = checkNotNull(jobStore);
this.jobFactory = checkNotNull(jobFactory);
checkArgument(threadPoolSize > 0, "Invalid thread-pool size: %s", threadPoolSize);
this.threadPoolSize = threadPoolSize;
this.threadPriority = threadPriority;
log.info("Thread-pool size: {}, Thread-pool priority: {}", threadPoolSize, threadPriority);
}
@Override
protected JobStore createJobStore(String name) {
jobStore = new JobStoreJdbcProvider(new ConfigOrientConnectionProvider(database.getInstanceProvider())).get();
jobStore.setInstanceId("SINGLE_NODE_TEST");
jobStore.setInstanceName(name);
return jobStore;
}
@Test
public void testAcquireTriggers() throws Exception {
SchedulerSignaler schedSignaler = new SampleSignaler();
ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
loadHelper.initialize();
JobStore store = createJobStore("testAcquireTriggers");
store.initialize(loadHelper, schedSignaler);
// Setup: Store jobs and triggers.
long MIN = 60 * 1000L;
Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from now.
for (int i=0; i < 10; i++) {
Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job" + i).build();
SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2);
OperableTrigger trigger = (OperableTrigger)TriggerBuilder.newTrigger().withIdentity("job" + i).withSchedule(schedule).forJob(job).startAt(startTime).build();
// Manually trigger the first fire time computation that scheduler would do. Otherwise
// the store.acquireNextTriggers() will not work properly.
Date fireTime = trigger.computeFirstFireTime(null);
Assert.assertEquals(true, fireTime != null);
store.storeJobAndTrigger(job, trigger);
}
// Test acquire one trigger at a time
for (int i=0; i < 10; i++) {
long noLaterThan = (startTime0.getTime() + i * MIN);
int maxCount = 1;
long timeWindow = 0;
List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
Assert.assertEquals(1, triggers.size());
Assert.assertEquals("job" + i, triggers.get(0).getKey().getName());
// Let's remove the trigger now.
store.removeJob(triggers.get(0).getJobKey());
}
}
@Test
public void testAcquireTriggersInBatch() throws Exception {
SchedulerSignaler schedSignaler = new SampleSignaler();
ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
loadHelper.initialize();
JobStore store = createJobStore("testAcquireTriggersInBatch");
store.initialize(loadHelper, schedSignaler);
// Setup: Store jobs and triggers.
long MIN = 60 * 1000L;
Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from now.
for (int i=0; i < 10; i++) {
Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job" + i).build();
SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2);
OperableTrigger trigger = (OperableTrigger)TriggerBuilder.newTrigger().withIdentity("job" + i).withSchedule(schedule).forJob(job).startAt(startTime).build();
// Manually trigger the first fire time computation that scheduler would do. Otherwise
// the store.acquireNextTriggers() will not work properly.
Date fireTime = trigger.computeFirstFireTime(null);
Assert.assertEquals(true, fireTime != null);
store.storeJobAndTrigger(job, trigger);
}
// Test acquire batch of triggers at a time
long noLaterThan = startTime0.getTime() + 10 * MIN;
int maxCount = 7;
// time window needs to be big to be able to pick up multiple triggers when they are a minute apart
long timeWindow = 8 * MIN;
List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
Assert.assertEquals(7, triggers.size());
for (int i=0; i < 7; i++) {
Assert.assertEquals("job" + i, triggers.get(i).getKey().getName());
}
}
@Override
protected JobStore createJobStore(final String name) {
jobStore = new JobStoreJdbcProvider(new ConfigStoreConnectionProvider(sessionRule)).get();
jobStore.setInstanceId("SINGLE_NODE_TEST");
jobStore.setInstanceName(name);
return jobStore;
}
public void init(@Nullable final Integer poolSize, @Nullable final JobFactory factory) throws Exception {
eventManager = new SimpleEventManager();
applicationDirectories = mock(ApplicationDirectories.class);
baseUrlManager = mock(BaseUrlManager.class);
nodeAccess = mock(NodeAccess.class);
lastShutdownTimeService = mock(LastShutdownTimeService.class);
statusDelayedExecutor = mock(DatabaseStatusDelayedExecutor.class);
Module module = binder -> {
Properties properties = new Properties();
properties.put("basedir", util.getBaseDir());
if (poolSize != null) {
properties.put("nexus.quartz.poolSize", poolSize);
}
binder.bind(ParameterKeys.PROPERTIES)
.toInstance(properties);
binder.bind(EventManager.class).toInstance(eventManager);
File workDir = util.createTempDir(util.getTargetDir(), "workdir");
when(applicationDirectories.getWorkDirectory(anyString())).thenReturn(workDir);
binder.bind(ApplicationDirectories.class)
.toInstance(applicationDirectories);
binder.bind(BaseUrlManager.class)
.toInstance(baseUrlManager);
binder.bind(DatabaseInstance.class)
.annotatedWith(Names.named("config"))
.toInstance(databaseInstance);
doAnswer(i -> {
((Runnable) i.getArguments()[0]).run();
return null;
}).when(statusDelayedExecutor).execute(notNull(Runnable.class));
binder.bind(DatabaseStatusDelayedExecutor.class)
.toInstance(statusDelayedExecutor);
when(nodeAccess.getId()).thenReturn("test-12345");
when(nodeAccess.getMemberIds()).thenReturn(ImmutableSet.of("test-12345"));
binder.bind(NodeAccess.class)
.toInstance(nodeAccess);
if (factory != null) {
binder.bind(JobFactory.class).toInstance(factory);
}
binder.bind(LastShutdownTimeService.class).toInstance(lastShutdownTimeService);
when(lastShutdownTimeService.estimateLastShutdownTime()).thenReturn(Optional.empty());
// filtering by feature flag is not supported here yet
binder.bind(JobStore.class).to(JobStoreImpl.class);
};
this.injector = Guice.createInjector(new WireModule(
module, new StateGuardModule(),
new SpaceModule(new URLClassSpace(TaskSchedulerHelper.class.getClassLoader()), BeanScanning.INDEX)
));
injector.injectMembers(this);
}
@Test
public void testMatchers() throws Exception {
SchedulerSignaler schedSignaler = new SampleSignaler();
ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
loadHelper.initialize();
JobStore store = createJobStore("testMatchers");
store.initialize(loadHelper, schedSignaler);
JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job1", "aaabbbccc").build();
store.storeJob(job, true);
SimpleScheduleBuilder schedule = SimpleScheduleBuilder.simpleSchedule();
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trig1", "aaabbbccc").withSchedule(schedule).forJob(job).build();
store.storeTrigger((OperableTrigger) trigger, true);
job = JobBuilder.newJob(MyJob.class).withIdentity("job1", "xxxyyyzzz").build();
store.storeJob(job, true);
schedule = SimpleScheduleBuilder.simpleSchedule();
trigger = TriggerBuilder.newTrigger().withIdentity("trig1", "xxxyyyzzz").withSchedule(schedule).forJob(job).build();
store.storeTrigger((OperableTrigger)trigger, true);
job = JobBuilder.newJob(MyJob.class).withIdentity("job2", "xxxyyyzzz").build();
store.storeJob(job, true);
schedule = SimpleScheduleBuilder.simpleSchedule();
trigger = TriggerBuilder.newTrigger().withIdentity("trig2", "xxxyyyzzz").withSchedule(schedule).forJob(job).build();
store.storeTrigger((OperableTrigger)trigger, true);
Set<JobKey> jkeys = store.getJobKeys(GroupMatcher.anyJobGroup());
Assert.assertEquals("Wrong number of jobs found by anything matcher", 3, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupEquals("xxxyyyzzz"));
Assert.assertEquals("Wrong number of jobs found by equals matcher", 2, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupEquals("aaabbbccc"));
Assert.assertEquals("Wrong number of jobs found by equals matcher", 1, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupStartsWith("aa"));
Assert.assertEquals("Wrong number of jobs found by starts with matcher", 1, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupStartsWith("xx"));
Assert.assertEquals("Wrong number of jobs found by starts with matcher", 2, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupEndsWith("cc"));
Assert.assertEquals("Wrong number of jobs found by ends with matcher", 1, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupEndsWith("zzz"));
Assert.assertEquals("Wrong number of jobs found by ends with matcher", 2, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupContains("bc"));
Assert.assertEquals("Wrong number of jobs found by contains with matcher", 1, jkeys.size());
jkeys = store.getJobKeys(GroupMatcher.jobGroupContains("yz"));
Assert.assertEquals("Wrong number of jobs found by contains with matcher", 2, jkeys.size());
Set<TriggerKey> tkeys = store.getTriggerKeys(GroupMatcher.anyTriggerGroup());
Assert.assertEquals("Wrong number of triggers found by anything matcher", 3, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupEquals("xxxyyyzzz"));
Assert.assertEquals("Wrong number of triggers found by equals matcher", 2, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupEquals("aaabbbccc"));
Assert.assertEquals("Wrong number of triggers found by equals matcher", 1, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupStartsWith("aa"));
Assert.assertEquals("Wrong number of triggers found by starts with matcher", 1, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupStartsWith("xx"));
Assert.assertEquals("Wrong number of triggers found by starts with matcher", 2, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupEndsWith("cc"));
Assert.assertEquals("Wrong number of triggers found by ends with matcher", 1, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupEndsWith("zzz"));
Assert.assertEquals("Wrong number of triggers found by ends with matcher", 2, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupContains("bc"));
Assert.assertEquals("Wrong number of triggers found by contains with matcher", 1, tkeys.size());
tkeys = store.getTriggerKeys(GroupMatcher.triggerGroupContains("yz"));
Assert.assertEquals("Wrong number of triggers found by contains with matcher", 2, tkeys.size());
}
/**
* Creates an in memory job store (<code>{@link RAMJobStore}</code>)
* The thread priority is set to Thread.NORM_PRIORITY
*
* @param maxThreads
* The number of threads in the thread pool
* @throws SchedulerException
* if initialization failed.
*/
public void createVolatileScheduler(int maxThreads)
throws SchedulerException {
SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads,
Thread.NORM_PRIORITY);
threadPool.initialize();
JobStore jobStore = new RAMJobStore();
this.createScheduler(threadPool, jobStore);
}
/**
* Same as
* {@link DirectSchedulerFactory#createScheduler(ThreadPool threadPool, JobStore jobStore)},
* with the addition of specifying the scheduler name and instance ID. This
* scheduler can only be retrieved via
* {@link DirectSchedulerFactory#getScheduler(String)}
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool, JobStore jobStore)
throws SchedulerException {
createScheduler(schedulerName, schedulerInstanceId, threadPool,
jobStore, null, 0, -1, -1);
}
/**
* Creates a scheduler using the specified thread pool and job store and
* binds it to RMI.
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @param rmiRegistryHost
* The hostname to register this scheduler with for RMI. Can use
* "null" if no RMI is required.
* @param rmiRegistryPort
* The port for RMI. Typically 1099.
* @param idleWaitTime
* The idle wait time in milliseconds. You can specify "-1" for
* the default value, which is currently 30000 ms.
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool,
JobStore jobStore, String rmiRegistryHost, int rmiRegistryPort,
long idleWaitTime, long dbFailureRetryInterval)
throws SchedulerException {
createScheduler(schedulerName,
schedulerInstanceId, threadPool,
jobStore, null, // plugins
rmiRegistryHost, rmiRegistryPort,
idleWaitTime, dbFailureRetryInterval,
DEFAULT_JMX_EXPORT, DEFAULT_JMX_OBJECTNAME);
}
/**
* Creates a scheduler using the specified thread pool, job store, and
* plugins, and binds it to RMI.
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @param schedulerPluginMap
* Map from a <code>String</code> plugin names to
* <code>{@link org.quartz.spi.SchedulerPlugin}</code>s. Can use
* "null" if no plugins are required.
* @param rmiRegistryHost
* The hostname to register this scheduler with for RMI. Can use
* "null" if no RMI is required.
* @param rmiRegistryPort
* The port for RMI. Typically 1099.
* @param idleWaitTime
* The idle wait time in milliseconds. You can specify "-1" for
* the default value, which is currently 30000 ms.
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool,
JobStore jobStore, Map<String, SchedulerPlugin> schedulerPluginMap,
String rmiRegistryHost, int rmiRegistryPort,
long idleWaitTime, long dbFailureRetryInterval,
boolean jmxExport, String jmxObjectName)
throws SchedulerException {
createScheduler(schedulerName, schedulerInstanceId, threadPool,
DEFAULT_THREAD_EXECUTOR, jobStore, schedulerPluginMap,
rmiRegistryHost, rmiRegistryPort, idleWaitTime,
dbFailureRetryInterval, jmxExport, jmxObjectName);
}
/**
* Creates a scheduler using the specified thread pool, job store, and
* plugins, and binds it to RMI.
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param threadExecutor
* The thread executor for executing jobs
* @param jobStore
* The type of job store
* @param schedulerPluginMap
* Map from a <code>String</code> plugin names to
* <code>{@link org.quartz.spi.SchedulerPlugin}</code>s. Can use
* "null" if no plugins are required.
* @param rmiRegistryHost
* The hostname to register this scheduler with for RMI. Can use
* "null" if no RMI is required.
* @param rmiRegistryPort
* The port for RMI. Typically 1099.
* @param idleWaitTime
* The idle wait time in milliseconds. You can specify "-1" for
* the default value, which is currently 30000 ms.
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool,
ThreadExecutor threadExecutor,
JobStore jobStore, Map<String, SchedulerPlugin> schedulerPluginMap,
String rmiRegistryHost, int rmiRegistryPort,
long idleWaitTime, long dbFailureRetryInterval,
boolean jmxExport, String jmxObjectName)
throws SchedulerException {
createScheduler(schedulerName, schedulerInstanceId, threadPool,
DEFAULT_THREAD_EXECUTOR, jobStore, schedulerPluginMap,
rmiRegistryHost, rmiRegistryPort, idleWaitTime,
dbFailureRetryInterval, jmxExport, jmxObjectName, DEFAULT_BATCH_MAX_SIZE, DEFAULT_BATCH_TIME_WINDOW);
}
/**
* <p>
* Set the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code>
* to use.
* </p>
*
* @exception IllegalArgumentException
* if jobStore is null.
*/
public void setJobStore(JobStore jobStore) {
if (jobStore == null) {
throw new IllegalArgumentException("JobStore cannot be null.");
}
this.jobStore = jobStore;
}
/**
* Creates a scheduler using the specified thread pool and job store. This
* scheduler can be retrieved via
* {@link DirectSchedulerFactory#getScheduler()}
*
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(ThreadPool threadPool, JobStore jobStore)
throws SchedulerException {
createScheduler(DEFAULT_SCHEDULER_NAME, DEFAULT_INSTANCE_ID,
threadPool, jobStore);
initialized = true;
}
/**
* Same as
* {@link DirectSchedulerFactory#createScheduler(ThreadPool threadPool, JobStore jobStore)},
* with the addition of specifying the scheduler name and instance ID. This
* scheduler can only be retrieved via
* {@link DirectSchedulerFactory#getScheduler(String)}
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool, JobStore jobStore)
throws SchedulerException {
createScheduler(schedulerName, schedulerInstanceId, threadPool,
jobStore, null, 0, -1, -1);
}
/**
* Creates a scheduler using the specified thread pool and job store and
* binds it to RMI.
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @param rmiRegistryHost
* The hostname to register this scheduler with for RMI. Can use
* "null" if no RMI is required.
* @param rmiRegistryPort
* The port for RMI. Typically 1099.
* @param idleWaitTime
* The idle wait time in milliseconds. You can specify "-1" for
* the default value, which is currently 30000 ms.
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool,
JobStore jobStore, String rmiRegistryHost, int rmiRegistryPort,
long idleWaitTime, long dbFailureRetryInterval)
throws SchedulerException {
createScheduler(schedulerName,
schedulerInstanceId, threadPool,
jobStore, null, // plugins
rmiRegistryHost, rmiRegistryPort,
idleWaitTime, dbFailureRetryInterval,
DEFAULT_JMX_EXPORT, DEFAULT_JMX_OBJECTNAME);
}
/**
* Creates a scheduler using the specified thread pool, job store, and
* plugins, and binds it to RMI.
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @param schedulerPluginMap
* Map from a <code>String</code> plugin names to
* <code>{@link org.quartz.spi.SchedulerPlugin}</code>s. Can use
* "null" if no plugins are required.
* @param rmiRegistryHost
* The hostname to register this scheduler with for RMI. Can use
* "null" if no RMI is required.
* @param rmiRegistryPort
* The port for RMI. Typically 1099.
* @param idleWaitTime
* The idle wait time in milliseconds. You can specify "-1" for
* the default value, which is currently 30000 ms.
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(String schedulerName,
String schedulerInstanceId, ThreadPool threadPool,
JobStore jobStore, Map schedulerPluginMap,
String rmiRegistryHost, int rmiRegistryPort,
long idleWaitTime, long dbFailureRetryInterval,
boolean jmxExport, String jmxObjectName)
throws SchedulerException {
createScheduler(schedulerName, schedulerInstanceId, threadPool,
DEFAULT_THREAD_EXECUTOR, jobStore, schedulerPluginMap,
rmiRegistryHost, rmiRegistryPort, idleWaitTime,
dbFailureRetryInterval, jmxExport, jmxObjectName);
}
/**
* <p>
* Set the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code>
* to use.
* </p>
*
* @exception IllegalArgumentException
* if jobStore is null.
*/
public void setJobStore(JobStore jobStore) {
if (jobStore == null) {
throw new IllegalArgumentException("JobStore cannot be null.");
}
this.jobStore = jobStore;
}
/**
* Creates a scheduler using the specified thread pool and job store. This
* scheduler can be retrieved via
* {@link DirectSchedulerFactory#getScheduler()}
*
* @param threadPool
* The thread pool for executing jobs
* @param jobStore
* The type of job store
* @throws SchedulerException
* if initialization failed
*/
public void createScheduler(ThreadPool threadPool, JobStore jobStore)
throws SchedulerException {
createScheduler(DEFAULT_SCHEDULER_NAME, DEFAULT_INSTANCE_ID,
threadPool, jobStore);
}
/**
* <p>
* Get the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code>
* to use.
* </p>
*/
public JobStore getJobStore() {
return jobStore;
}
/**
* <p>
* Get the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code>
* to use.
* </p>
*/
public JobStore getJobStore() {
return jobStore;
}
protected abstract JobStore createJobStore(String name);