it.sauronsoftware.cron4j.Scheduler Java Examples

The following examples show how to use it.sauronsoftware.cron4j.Scheduler. 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: ScheduleFutureImpl.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Creates descriptor for task scheduling. To start scheduling call {@link #schedule(Callable)}.
 *
 * @param sched Cron scheduler.
 * @param ctx Kernal context.
 * @param pat Cron pattern.
 */
ScheduleFutureImpl(Scheduler sched, GridKernalContext ctx, String pat) {
    assert sched != null;
    assert ctx != null;
    assert pat != null;

    this.sched = sched;
    this.ctx = ctx;
    this.pat = pat.trim();

    log = ctx.log(getClass());

    try {
        parsePatternParameters();
    }
    catch (IgniteCheckedException e) {
        onEnd(resLatch, null, e, true);
    }
}
 
Example #2
Source File: JbootCron4jPlugin.java    From jboot with Apache License 2.0 5 votes vote down vote up
void schedule() {
    if (enable) {
        scheduler = new Scheduler();
        if (task instanceof Runnable) {
            scheduler.schedule(cron, (Runnable) task);
        } else if (task instanceof Task) {
            scheduler.schedule(cron, (Task) task);
        } else {
            scheduler = null;
            throw new IllegalStateException("Task 必须是 Runnable、ITask、ProcessTask 或者 Task 类型");
        }
        scheduler.setDaemon(daemon);
    }
}
 
Example #3
Source File: SchedulingService.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
private void startBackuping() {
    logger.debug("Starting the scheduler backup process...");
    backupScheduler = new it.sauronsoftware.cron4j.Scheduler();
    String cronExpr = PASharedProperties.SERVER_BACKUP_PERIOD.getValueAsString();
    backupScheduler.schedule(cronExpr, new SchedulerBackupRunner(this, synchronizationAPI));
    backupScheduler.start();
}
 
Example #4
Source File: SchedulingService.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
public void startHouseKeeping() {
    houseKeepingScheduler = new Scheduler();
    String cronExpr = "* * * * *";
    if (PASchedulerProperties.SCHEDULER_AUTOMATIC_REMOVED_JOB_CRON_EXPR.isSet()) {
        cronExpr = PASchedulerProperties.SCHEDULER_AUTOMATIC_REMOVED_JOB_CRON_EXPR.getValueAsString();
    }
    houseKeepingScheduler.schedule(cronExpr, new HousekeepingRunner());
    houseKeepingScheduler.start();
}
 
Example #5
Source File: NodesHouseKeepingService.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
Scheduler createOrGetCronScheduler() {
    if (this.nodesHouseKeepingScheduler == null) {
        return new Scheduler();
    } else {
        return this.nodesHouseKeepingScheduler;
    }
}
 
Example #6
Source File: RMDBManager.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
public void startHouseKeeping() {
    houseKeepingScheduler = new Scheduler();
    if (PAResourceManagerProperties.RM_HISTORY_MAX_PERIOD.isSet() &&
        PAResourceManagerProperties.RM_HISTORY_MAX_PERIOD.getValueAsLong() > 0 &&
        PAResourceManagerProperties.RM_HISTORY_REMOVAL_CRONPERIOD.isSet()) {
        String cronExpr = PAResourceManagerProperties.RM_HISTORY_REMOVAL_CRONPERIOD.getValueAsString();
        houseKeepingScheduler.schedule(cronExpr, new HousekeepingRunner());
        houseKeepingScheduler.start();
    }

}
 
Example #7
Source File: CronPolicy.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configureCronParametersStartingFromIndex(int index, Object[] policyParameters) {
    try {
        this.cronScheduler = new Scheduler();
        this.nodeAcquision = policyParameters[index++].toString();
        this.nodeRemoval = policyParameters[index++].toString();
        this.preemptive = Boolean.parseBoolean(policyParameters[index++].toString());
        this.forceDeployment = Boolean.parseBoolean(policyParameters[index].toString());
    } catch (Throwable t) {
        throw new IllegalArgumentException(t);
    }
}
 
Example #8
Source File: CronScheduler.java    From jqm with Apache License 2.0 5 votes vote down vote up
private void startScheduler()
{
    s = new Scheduler();
    s.setDaemon(true);

    s.addTaskCollector(this);
    s.start();
    masterScheduler = true;
    jqmlogger.info("Scheduler (cron) has started");
}
 
Example #9
Source File: IgniteScheduleProcessor.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
    sched = new Scheduler();

    sched.start();
}
 
Example #10
Source File: DerbyMetadataServer.java    From chipster with MIT License 4 votes vote down vote up
/**
 * Initialises the server. If underlying embedded Derby SQL database is not initialised, it is 
 * initialised first.
 * 
 * @throws InstantiationException
 * @throws IllegalAccessException
 * @throws ClassNotFoundException
 * @throws SQLException
 * @throws IllegalConfigurationException 
 * @throws IOException 
 */
public DerbyMetadataServer() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, IOException, IllegalConfigurationException {
	
	Configuration configuration = DirectoryLayout.getInstance().getConfiguration();
	
	// initialise connection
	System.setProperty("derby.system.home", DB_ROOT);
	Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); // allows multiple connections in one JVM, but not from multiple JVM's
	
	String strUrl = "jdbc:derby:" + DB_NAME + ";";
	
	File metadataBackupDir = DirectoryLayout.getInstance().getFilebrokerMetadataBackupDir();
	String restorePath = configuration.getString("filebroker", "metadata-restore-path");
	String fullRestorePath = metadataBackupDir + File.separator + restorePath + File.separator + DB_NAME;
	
	if (restorePath != null && !restorePath.isEmpty()) {
		logger.info("restoring metadata database from " + fullRestorePath);
		File dbDir = new File(DB_ROOT, DB_NAME);
		if (dbDir.exists()) {
			throw new IllegalConfigurationException("metadata restore isn't allowed, because the database " + dbDir + " exists already");
		}
		// One way to restore a backup
		// See http://db.apache.org/derby/docs/10.1/adminguide/tadminhubbkup44.html
		strUrl += "restoreFrom=" + fullRestorePath;
	} else {
		strUrl += "create=true";
	}
		
	
	connection = DriverManager.getConnection(strUrl);
	
	// initialise database, if needed
	initialise();

	logger.info("metadata database started");
	
	
	// initialise metadata database backup
	if (configuration.getBoolean("filebroker", "enable-metadata-backups")) {
	
		// get backup configuration
		int metadataBackupKeepCount = configuration.getInt("filebroker", "metadata-backup-keep-count");
		String backupTime = configuration.getString("filebroker", "metadata-backup-time").trim();
		
		// schedule backup tasks
		Scheduler scheduler = new Scheduler();
		scheduler.schedule(backupTime, new MetadataBackupTimerTask(metadataBackupDir, metadataBackupKeepCount));
		scheduler.start();
		
		logger.info("metadata backups enabled at: " + backupTime);
	} else {
		logger.info("metadata backups disabled");
	}	
}