Java Code Examples for org.quartz.impl.StdSchedulerFactory#getScheduler()

The following examples show how to use org.quartz.impl.StdSchedulerFactory#getScheduler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTaskScheduler.java    From onedev with MIT License 6 votes vote down vote up
public DefaultTaskScheduler() {
	StdSchedulerFactory schedFactory = new StdSchedulerFactory();
	Properties props = new Properties();
	props.setProperty("org.quartz.scheduler.instanceName", "DefaultQuartzScheduler");
	props.setProperty("org.quartz.scheduler.rmi.export", "false");
	props.setProperty("org.quartz.scheduler.rmi.proxy", "false");
       props.setProperty("org.quartz.scheduler.wrapJobExecutionInUserTransaction", "false");
       props.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
       props.setProperty("org.quartz.threadPool.threadCount", "10");
       props.setProperty("org.quartz.jobStore.misfireThreshold", "60000");
       props.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
	try {
		schedFactory.initialize(props);
		quartz = schedFactory.getScheduler();
	} catch (SchedulerException e) {
		throw new RuntimeException(e);
	}
}
 
Example 2
Source File: SolrTrackerScheduler.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
public SolrTrackerScheduler(AlfrescoCoreAdminHandler adminHandler)
{
    // TODO: pick scheduler properties from SOLR config or file ...
    try
    {
        StdSchedulerFactory factory = new StdSchedulerFactory();
        Properties properties = new Properties();
        properties.setProperty("org.quartz.scheduler.instanceName", adminHandler.toString());
        properties.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
        properties.setProperty("org.quartz.threadPool.threadCount", "40");
        properties.setProperty("org.quartz.threadPool.makeThreadsDaemons", "true");
        properties.setProperty("org.quartz.scheduler.makeSchedulerThreadDaemon", "true");
        properties.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
        properties.setProperty("org.quartz.scheduler.skipUpdateCheck","true");
        factory.initialize(properties);
        scheduler = factory.getScheduler();
        scheduler.start();

    }
    catch (SchedulerException e)
    {
        logError("SolrTrackerScheduler", e);
    }
}
 
Example 3
Source File: QuartzInitializer.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void init(SourceBean config) {
	StdSchedulerFactory stdSchedFact = new StdSchedulerFactory();
	Properties properties = new Properties();
	try {
		Thread currThread = Thread.currentThread();
		ClassLoader classLoader = currThread.getContextClassLoader();
		InputStream propIs = classLoader.getResourceAsStream("quartz.properties");
		properties.load(propIs);

		String figuredOutValue = null;

		if (properties.containsKey(PROPERTY_DELEGATE_CLASS)) {
			logger.info("Quartz delegate class set to " + properties.get(PROPERTY_DELEGATE_CLASS));
		} else {
			logger.warn("Property " + PROPERTY_DELEGATE_CLASS + " not set! Trying to figure out what delegate class needs to be used...");
			determineDelegateClass(properties);
		}

		stdSchedFact.initialize(properties);
		Scheduler sched = stdSchedFact.getScheduler();
		sched.start();
	} catch (Exception e) {
		SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "init", "Error while initializing scheduler " + e);
	}
}
 
Example 4
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Scheduler getScheduler() throws Exception {

		if (scheduler == null) {
			schedulFactoty = new StdSchedulerFactory();
			scheduler = schedulFactoty.getScheduler();
		}
		return scheduler;
	}
 
Example 5
Source File: TaskManager.java    From WeCross with Apache License 2.0 5 votes vote down vote up
public TaskManager(TaskFactory taskFactory) {
    this.taskFactory = taskFactory;
    try {
        StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
        Properties props = new Properties();
        props.put(
                StdSchedulerFactory.PROP_THREAD_POOL_CLASS,
                "org.quartz.simpl.SimpleThreadPool");
        props.put("org.quartz.threadPool.threadCount", "1");
        stdSchedulerFactory.initialize(props);
        scheduler = stdSchedulerFactory.getScheduler();
    } catch (SchedulerException e) {
        logger.error("something wrong with getting scheduler: {}", e.getLocalizedMessage());
    }
}
 
Example 6
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void JobInit() throws Exception {
	try {
		if (scheduler != null && scheduler.isStarted())
			return;

		schedulFactoty = new StdSchedulerFactory();
		scheduler = schedulFactoty.getScheduler();
		scheduler.start();
		JobRegist();
	} catch (Exception e) {
		throw e;
	}
}
 
Example 7
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 스케줄러 인스턴스 얻기
 * @throws Exception
 * @return Scheduler
 */
public Scheduler getScheduler() throws Exception {

	if (scheduler == null) {
		schedulerFactory = new StdSchedulerFactory();
		scheduler = schedulerFactory.getScheduler();
	}
	return scheduler;
}
 
Example 8
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 스케줄러 초기화
 * @throws Exception
 * @return void
 */
public void JobInit() throws Exception {
	try {
		if (scheduler != null && scheduler.isStarted())
			return;

		schedulerFactory = new StdSchedulerFactory();
		scheduler = schedulerFactory.getScheduler();
		scheduler.start();
		JobRegist();
	} catch (Exception e) {
		throw e;
	}
}
 
Example 9
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Scheduler getScheduler() throws Exception {

		if (scheduler == null) {
			schedulFactoty = new StdSchedulerFactory();
			scheduler = schedulFactoty.getScheduler();
		}
		return scheduler;
	}
 
Example 10
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void JobInit() throws Exception {
	try {
		if (scheduler != null && scheduler.isStarted())
			return;

		schedulFactoty = new StdSchedulerFactory();
		scheduler = schedulFactoty.getScheduler();
		scheduler.start();
		JobRegist();
	} catch (Exception e) {
		throw e;
	}
}
 
Example 11
Source File: JobScheduler.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public JobScheduler(BimServer bimServer) {
	try {
		Properties properties = new Properties();
		String instanceName = "UniqueName" + Math.random();
		properties.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
		properties.setProperty("org.quartz.threadPool.threadCount", "1");
		properties.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instanceName);
		sf = new StdSchedulerFactory(properties);
		sched = sf.getScheduler();
		sched.getContext().put("bimserver", bimServer);
	} catch (SchedulerException e) {
		LOGGER.error("", e);
	}
}
 
Example 12
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 스케줄러 초기화
 * @throws Exception
 * @return void
 */
public void JobInit() throws Exception {
	try {
		if (scheduler != null && scheduler.isStarted())
			return;

		schedulerFactory = new StdSchedulerFactory();
		scheduler = schedulerFactory.getScheduler();
		scheduler.start();
		JobRegist();
	} catch (Exception e) {
		throw e;
	}
}
 
Example 13
Source File: BaseTest.java    From quartz-redis-jobstore with Apache License 2.0 5 votes vote down vote up
protected void testJobStore(Properties quartzProperties) throws SchedulerException {
    StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
    schedulerFactory.initialize(quartzProperties);

    Scheduler scheduler = schedulerFactory.getScheduler();
    scheduler.start();

    JobDetail job = getJobDetail("testJob1", "testJobGroup1");
    CronTriggerImpl trigger = getCronTrigger("testTrigger1", "testTriggerGroup1", job.getKey(), "0/5 * * * * ?");

    scheduler.scheduleJob(job, trigger);

    JobDetail retrievedJob = jobStore.retrieveJob(job.getKey());
    assertThat(retrievedJob, not(nullValue()));
    assertThat(retrievedJob.getJobDataMap(), hasKey("timeout"));

    CronTriggerImpl retrievedTrigger = (CronTriggerImpl) jobStore.retrieveTrigger(trigger.getKey());
    assertThat(retrievedTrigger, not(nullValue()));
    assertEquals(trigger.getCronExpression(), retrievedTrigger.getCronExpression());

    scheduler.deleteJob(job.getKey());

    assertThat(jobStore.retrieveJob(job.getKey()), nullValue());
    assertThat(jobStore.retrieveTrigger(trigger.getKey()), nullValue());

    scheduler.shutdown();
}
 
Example 14
Source File: JobScheduler.java    From verigreen with Apache License 2.0 5 votes vote down vote up
public void start() {
    
    StdSchedulerFactory sf = new StdSchedulerFactory();
    try {
        _scheduler = sf.getScheduler();
        _scheduler.start();
        scheduleJobs();
    } catch (SchedulerException e) {
        new RuntimeException("Failed starting job scheduler", e);
    }
}
 
Example 15
Source File: TimerComponent.java    From tangyuan2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(String resource) throws Throwable {
	log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
	log.info("timer client component starting, version: " + Version.getVersion());
	log.info("*** Start parsing: " + resource);
	parse(resource);// "config.xml"
	schedulerfactory = new StdSchedulerFactory();
	scheduler = schedulerfactory.getScheduler();
	register();
	scheduler.start();
	log.info("timer client component successfully.");
}
 
Example 16
Source File: TimerSchedulerQuartzIntegrationTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    maintenanceModeService = new MaintenanceModeService(new TimeProvider());
    quartzSchedulerFactory = new StdSchedulerFactory();
    scheduler = quartzSchedulerFactory.getScheduler();
    systemEnvironment = new SystemEnvironment();
    scheduler.start();
}
 
Example 17
Source File: BackupSchedulerTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() throws SchedulerException {
    initMocks(this);
    stdSchedulerFactory = new StdSchedulerFactory();
    scheduler = stdSchedulerFactory.getScheduler();
    backupScheduler = new BackupScheduler(scheduler, goConfigService, serverHealthService, backupService);
}
 
Example 18
Source File: TransientProducerScheduler.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
private Scheduler getScheduler() {
    StdSchedulerFactory factory = new StdSchedulerFactory();
    try {
        factory.initialize(getQuartzProperties());
        return factory.getScheduler();
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
}
 
Example 19
Source File: SchedulerManager.java    From sunbird-lms-service with MIT License 4 votes vote down vote up
/** This method will register the quartz scheduler job. */
public void schedule() {
  ProjectLogger.log(
      "SchedulerManager:schedule: Call to start scheduler jobs - org.sunbird.common.quartz.scheduler.SchedulerManager",
      LoggerEnum.INFO.name());

  try {
    Thread.sleep(240000);
    boolean isEmbedded = false;
    Properties configProp = null;
    String embeddVal = System.getenv(JsonKey.SUNBIRD_QUARTZ_MODE);
    if (JsonKey.EMBEDDED.equalsIgnoreCase(embeddVal)) {
      isEmbedded = true;
    } else {
      configProp = setUpClusterMode();
    }
    if (!isEmbedded && configProp != null) {

      StdSchedulerFactory schedulerFactory = new StdSchedulerFactory(configProp);
      ProjectLogger.log("Quartz scheduler is running in cluster mode.", LoggerEnum.INFO.name());
      scheduler = schedulerFactory.getScheduler("MyScheduler");

      if (null == scheduler) {
        Thread.sleep(5000);
        scheduler = schedulerFactory.getScheduler();
      }

      String schedulerName = scheduler.getSchedulerName();
      ProjectLogger.log(
          "Quartz scheduler is running in cluster mode. scheduler Name is: " + schedulerName,
          LoggerEnum.INFO.name());
    } else {
      ProjectLogger.log("Quartz scheduler is running in embedded mode.", LoggerEnum.INFO.name());
      scheduler = new StdSchedulerFactory().getScheduler();
    }
    String identifier = "NetOps-PC1502295457753";

    scheduleBulkUploadJob(identifier);
    scheduleUpdateUserCountJob(identifier);
    scheduleChannelReg(identifier);
    scheduleShadowUser(identifier);

  } catch (Exception e) {
    ProjectLogger.log(
        "SchedulerManager:schedule: Error in starting scheduler jobs - org.sunbird.common.quartz.scheduler.SchedulerManager "
            + e.getMessage(),
        LoggerEnum.ERROR.name());
  } finally {
    registerShutDownHook();
  }
  ProjectLogger.log(
      "SchedulerManager:schedule: started scheduler jobs - org.sunbird.common.quartz.scheduler.SchedulerManager",
      LoggerEnum.INFO.name());
}
 
Example 20
Source File: QuartzUtils.java    From quartz-web with Apache License 2.0 2 votes vote down vote up
/**
 * 将会删除通用
 * @param properties
 * @return
 * @throws SchedulerException
 */
public static Scheduler createScheduler(Properties properties) throws SchedulerException {
    StdSchedulerFactory stdSchedulerFactory= new StdSchedulerFactory(properties);
    return stdSchedulerFactory.getScheduler();
}