/** * 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); JobStore jobStore = new RAMJobStore(); this.createScheduler(threadPool, jobStore); }
if(isThreadsInheritGroupOfInitializingThread()) { threadGroup = Thread.currentThread().getThreadGroup(); } else { if (isMakeThreadsDaemons()) { threadGroup.setDaemon(true); if (isThreadsInheritContextClassLoaderOfInitializingThread()) { getLog().info( "Job execution threads will use class loader of thread: " + Thread.currentThread().getName()); Iterator<WorkerThread> workerThreads = createWorkerThreads(count).iterator(); while(workerThreads.hasNext()) { WorkerThread wt = workerThreads.next();
public int getPoolSize() { return getThreadCount(); }
protected List<WorkerThread> createWorkerThreads(int createCount) { workers = new LinkedList<WorkerThread>(); for (int i = 1; i<= createCount; ++i) { String threadPrefix = getThreadNamePrefix(); if (threadPrefix == null) { threadPrefix = schedulerInstanceName + "_Worker"; } WorkerThread wt = new WorkerThread(this, threadGroup, threadPrefix + "-" + i, getThreadPriority(), isMakeThreadsDaemons()); if (isThreadsInheritContextClassLoaderOfInitializingThread()) { wt.setContextClassLoader(Thread.currentThread() .getContextClassLoader()); } workers.add(wt); } return workers; }
getLog().error("Worker thread was interrupt()'ed.", unblock); } catch(Exception e) { getLog().error("Error while executing the Runnable: ", exceptionInRunnable); } catch(Exception e) { if(getPriority() != tp.getThreadPriority()) { setPriority(tp.getThreadPriority()); clearFromBusyWorkersList(this); } else if(ran) { ran = false; makeAvailable(this); getLog().debug("WorkerThread is shut down."); } catch(Exception e) {
/** * 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 void start() throws Exception { if (!started) { System.setProperty("org.terracotta.quartz.skipUpdateCheck", "true"); DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance(); SimpleThreadPool threadPool = new SimpleThreadPool(this.numThreads, Thread.NORM_PRIORITY); threadPool.setThreadNamePrefix("scheduling-worker"); threadPool.initialize(); final String schedulerName = DEFAULT_SCHEDULER_NAME + ":" + this.name; factory.createScheduler(schedulerName, DEFAULT_INSTANCE_ID + ":" + this.name, threadPool, new RAMJobStore()); this.scheduler = factory.getScheduler(schedulerName); this.scheduler.getListenerManager().addTriggerListener(new TriggerListener()); this.scheduler.start(); started = true; log.info("Quartz started"); } }
getLog().error("worker threat got 'interrupt'ed.", unblock); } catch(Exception e) { getLog().error("Error while executing the Runnable: ", exceptionInRunnable); } catch(Exception e) { if(getPriority() != tp.getThreadPriority()) { setPriority(tp.getThreadPriority()); makeAvailable(this); getLog().debug("WorkerThread is shutting down"); } catch(Exception e) {
"WorkerThread-LastJob", prio, isMakeThreadsDaemons(), runnable); busyWorkers.add(wt); workers.add(wt);
getLog().debug("Shutting down threadpool..."); WorkerThread wt = (WorkerThread) busyWorkers.getFirst(); try { getLog().debug( "Waiting for thread " + wt.getName() + " to shut down"); getLog().debug("No executing jobs remaining, all threads stopped."); getLog().debug("Shutdown of threadpool complete.");
protected List<WorkerThread> createWorkerThreads(int createCount) { workers = new LinkedList<WorkerThread>(); for (int i = 1; i<= createCount; ++i) { String threadPrefix = getThreadNamePrefix(); if (threadPrefix == null) { threadPrefix = schedulerInstanceName + "_Worker"; } WorkerThread wt = new WorkerThread(this, threadGroup, threadPrefix + "-" + i, getThreadPriority(), isMakeThreadsDaemons()); if (isThreadsInheritContextClassLoaderOfInitializingThread()) { wt.setContextClassLoader(Thread.currentThread() .getContextClassLoader()); } workers.add(wt); } return workers; }
getLog().error("Worker thread was interrupt()'ed.", unblock); } catch(Exception e) { getLog().error("Error while executing the Runnable: ", exceptionInRunnable); } catch(Exception e) { if(getPriority() != tp.getThreadPriority()) { setPriority(tp.getThreadPriority()); clearFromBusyWorkersList(this); } else if(ran) { ran = false; makeAvailable(this); getLog().debug("WorkerThread is shut down."); } catch(Exception e) {
/** * 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); }
"WorkerThread-LastJob", prio, isMakeThreadsDaemons(), runnable); busyWorkers.add(wt); workers.add(wt);
getLog().debug("Shutting down threadpool..."); WorkerThread wt = (WorkerThread) busyWorkers.getFirst(); try { getLog().debug( "Waiting for thread " + wt.getName() + " to shut down"); getLog().debug("No executing jobs remaining, all threads stopped."); getLog().debug("Shutdown of threadpool complete.");
if(isThreadsInheritGroupOfInitializingThread()) { threadGroup = Thread.currentThread().getThreadGroup(); } else { if (isMakeThreadsDaemons()) { threadGroup.setDaemon(true); if (isThreadsInheritContextClassLoaderOfInitializingThread()) { getLog().info( "Job execution threads will use class loader of thread: " + Thread.currentThread().getName()); Iterator<WorkerThread> workerThreads = createWorkerThreads(count).iterator(); while(workerThreads.hasNext()) { WorkerThread wt = workerThreads.next();
protected List createWorkerThreads(int count) { workers = new LinkedList(); for (int i = 1; i<= count; ++i) { WorkerThread wt = new WorkerThread(this, threadGroup, getThreadNamePrefix() + "-" + i, getThreadPriority(), isMakeThreadsDaemons()); if (isThreadsInheritContextClassLoaderOfInitializingThread()) { wt.setContextClassLoader(Thread.currentThread() .getContextClassLoader()); } workers.add(wt); } return workers; }
getLog().error("Worker thread was interrupt()'ed.", unblock); } catch(Exception e) { getLog().error("Error while executing the Runnable: ", exceptionInRunnable); } catch(Exception e) { if(getPriority() != tp.getThreadPriority()) { setPriority(tp.getThreadPriority()); run = false; clearFromBusyWorkersList(this); } else if(ran) { ran = false; makeAvailable(this); getLog().debug("WorkerThread is shut down."); } catch(Exception e) {
private static void schedulerSetup(boolean enablePersistence) throws SchedulerException { JobStore js; if (enablePersistence) { CConfiguration conf = injector.getInstance(CConfiguration.class); tableUtil = new ScheduleStoreTableUtil(dsFramework, conf); datasetBasedTimeScheduleStore = new DatasetBasedTimeScheduleStore(factory, tableUtil, conf); js = datasetBasedTimeScheduleStore; } else { js = new RAMJobStore(); } SimpleThreadPool threadPool = new SimpleThreadPool(10, Thread.NORM_PRIORITY); threadPool.initialize(); DirectSchedulerFactory.getInstance().createScheduler(DUMMY_SCHEDULER_NAME, "1", threadPool, js); scheduler = DirectSchedulerFactory.getInstance().getScheduler(DUMMY_SCHEDULER_NAME); scheduler.start(); }
/** * 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); JobStore jobStore = new RAMJobStore(); this.createScheduler(threadPool, jobStore); }