当前位置: 首页>>代码示例>>Java>>正文


Java Predictor类代码示例

本文整理汇总了Java中it.sauronsoftware.cron4j.Predictor的典型用法代码示例。如果您正苦于以下问题:Java Predictor类的具体用法?Java Predictor怎么用?Java Predictor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Predictor类属于it.sauronsoftware.cron4j包,在下文中一共展示了Predictor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startScheduler

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
public void startScheduler()
{
	if (_notifications == null)
	{
		LOGGER.info("Scheduler without notificator manager: " + _eventManager.getClass().getSimpleName() + " pattern: " + _pattern);
		return;
	}
	
	final Predictor predictor = new Predictor(_pattern);
	final long nextSchedule = predictor.nextMatchingTime();
	final long timeSchedule = nextSchedule - System.currentTimeMillis();
	if (timeSchedule <= (30 * 1000))
	{
		LOGGER.warning("Wrong reschedule for " + _eventManager.getClass().getSimpleName() + " end up run in " + (timeSchedule / 1000) + " seconds!");
		ThreadPoolManager.getInstance().scheduleEvent(this::startScheduler, timeSchedule + 1000);
		return;
	}
	
	if (_task != null)
	{
		_task.cancel(false);
	}
	
	_task = ThreadPoolManager.getInstance().scheduleEvent(() ->
	{
		run();
		updateLastRun();
		
		if (isRepeating())
		{
			ThreadPoolManager.getInstance().scheduleEvent(this::startScheduler, 1000);
		}
	}, timeSchedule);
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:35,代码来源:EventScheduler.java

示例2: assignReplicationTag

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
/**
 * Assign a tag to new duplicated task because of a REPLICATE or LOOP.
 * 
 * @param replicatedTask
 *            the new duplicated task.
 * @param initiator
 *            the initiator of the duplication.
 * @param loopAction
 *            true if the duplication if after a loop or, false if it is a
 *            replicate.
 * @param action
 *            the duplication action.
 */
private void assignReplicationTag(InternalTask replicatedTask, InternalTask initiator, boolean loopAction,
        FlowAction action) {
    StringBuilder buf = new StringBuilder();

    if (loopAction) {
        buf.append("LOOP-");
        buf.append(InternalTask.getInitialName(initiator.getName()));
        if (initiator.getReplicationIndex() > 0) {
            buf.append("*");
            buf.append(initiator.getReplicationIndex());
        }
    } else {
        buf.append("REPLICATE-");
        buf.append(initiator.getName());
    }

    buf.append("-");

    if (loopAction) {
        String cronExpr = action.getCronExpr();
        if (cronExpr.isEmpty()) {
            buf.append(replicatedTask.getIterationIndex());
        } else {
            // cron task: the replication index is the next date that
            // matches the cron expression
            Date resolvedCron = new Predictor(cronExpr).nextMatchingDate();
            SimpleDateFormat dt = new SimpleDateFormat("dd_MM_YY_HH_mm");
            buf.append(dt.format(resolvedCron));
        }
    } else {
        buf.append(replicatedTask.getReplicationIndex());
    }

    replicatedTask.setTag(buf.toString());
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:49,代码来源:InternalJob.java

示例3: terminateLoopTask

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
public boolean terminateLoopTask(FlowAction action, InternalTask initiator, ChangedTasksInfo changesInfo,
        SchedulerStateUpdate frontend) {
    // find the target of the loop
    InternalTask target = null;
    if (action.getTarget().equals(initiator.getName())) {
        target = initiator;
    } else {
        target = internalJob.findTaskUp(action.getTarget(), initiator);
    }
    boolean replicateForNextLoopIteration = internalJob.replicateForNextLoopIteration(initiator,
                                                                                      target,
                                                                                      changesInfo,
                                                                                      frontend,
                                                                                      action);
    if (replicateForNextLoopIteration && action.getCronExpr() != null) {
        for (TaskId tid : changesInfo.getNewTasks()) {
            InternalTask newTask = internalJob.getIHMTasks().get(tid);
            try {
                Date startAt = (new Predictor(action.getCronExpr())).nextMatchingDate();
                newTask.addGenericInformation(InternalJob.GENERIC_INFO_START_AT_KEY,
                                              ISO8601DateUtil.parse(startAt));
                newTask.setScheduledTime(startAt.getTime());
            } catch (InvalidPatternException e) {
                // this will not happen as the cron expression is
                // already being validated in FlowScript class.
                LOGGER.debug(e.getMessage());
            }
        }
    }
    return replicateForNextLoopIteration;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:32,代码来源:TerminateLoopHandler.java

示例4: assignReplicationTag

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
/**
 * Assign a tag to new duplicated task because of a REPLICATE or LOOP.
 * 
 * @param replicatedTask
 *            the new duplicated task.
 * @param initiator
 *            the initiator of the duplication.
 * @param loopAction
 *            true if the duplication if after a loop or, false if it is a
 *            replicate.
 * @param action
 *            the duplication action.
 */
private void assignReplicationTag(InternalTask replicatedTask, InternalTask initiator, boolean loopAction,
        FlowAction action) {
    StringBuilder buf = new StringBuilder();

    if (loopAction) {
        buf.append("LOOP-");
        buf.append(InternalTask.getInitialName(initiator.getName()));
        if (initiator.getReplicationIndex() > 0) {
            buf.append("*");
            buf.append(initiator.getReplicationIndex());
        }
    } else {
        buf.append("REPLICATE-");
        buf.append(initiator.getName());
    }

    buf.append("-");

    if (loopAction) {
        String cronExpr = action.getCronExpr();
        if ("".equals(cronExpr)) {
            buf.append(replicatedTask.getIterationIndex());
        } else {
            // cron task: the replication index is the next date that
            // matches the cron expression
            Date resolvedCron = (new Predictor(cronExpr)).nextMatchingDate();
            SimpleDateFormat dt = new SimpleDateFormat("dd_MM_YY_HH_mm");
            buf.append(dt.format(resolvedCron));
        }
    } else {
        buf.append(replicatedTask.getReplicationIndex());
    }

    replicatedTask.setTag(buf.toString());
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:49,代码来源:TerminateReplicateTaskHandler.java

示例5: validate

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
@Override
public String validate(String parameterValue, ModelValidatorContext context) throws ValidationException {
    try {
        (new Predictor(parameterValue)).nextMatchingDate();
    } catch (InvalidPatternException e) {
        throw new ValidationException("Expected value should be a valid cron expression, received '" +
                                      parameterValue + "', error: " + e.getMessage(), e);
    }

    return parameterValue;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:12,代码来源:CRONValidator.java

示例6: getNextScheduledTime

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
public static Date getNextScheduledTime(String cronExp, String timeZone){
	Date nextScheduledTime = null;
	if (cronExp!=null && SchedulingPattern.validate(cronExp)) {        	
		Predictor predictor = new Predictor(cronExp);
		predictor.setTimeZone(TimeZone.getTimeZone(timeZone));				
		nextScheduledTime = predictor.nextMatchingDate();
	}
	return nextScheduledTime;		
}
 
开发者ID:smrjan,项目名称:job4j,代码行数:10,代码来源:CronUtil.java

示例7: getNextSchedule

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
public long getNextSchedule()
{
	final Predictor predictor = new Predictor(_pattern);
	return predictor.nextMatchingTime();
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:6,代码来源:EventScheduler.java

示例8: next

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
private Instant next(Instant time)
{
    Predictor predictor = new Predictor(pattern, Date.from(time));
    predictor.setTimeZone(TimeZone.getTimeZone(timeZone));
    return Instant.ofEpochMilli(predictor.nextMatchingTime());
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:7,代码来源:CronScheduler.java

示例9: logNextRun

import it.sauronsoftware.cron4j.Predictor; //导入依赖的package包/类
private void logNextRun() {
	Predictor predictor = new Predictor(cron);
	predictor.setTimeZone(timeZone);
	log.info("next run: {}", dateFormat.format(predictor.nextMatchingTime()));
}
 
开发者ID:lithiumtech,项目名称:flow,代码行数:6,代码来源:CronMain.java


注:本文中的it.sauronsoftware.cron4j.Predictor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。