use of org.smartdata.server.rule.parser.TimeBasedScheduleInfo in project SSM by Intel-bigdata.
the class RuleQueryExecutor method run.
@Override
public void run() {
if (exited) {
exitSchedule();
}
long rid = ctx.getRuleId();
try {
long startCheckTime = System.currentTimeMillis();
if (ruleManager.isClosed()) {
exitSchedule();
}
RuleInfo info = ruleManager.getRuleInfo(rid);
RuleState state = info.getState();
if (exited || state == RuleState.DELETED || state == RuleState.FINISHED || state == RuleState.DISABLED) {
exitSchedule();
}
TimeBasedScheduleInfo scheduleInfo = tr.getTbScheduleInfo();
if (scheduleInfo.getEndTime() != TimeBasedScheduleInfo.FOR_EVER && // TODO: tricky here, time passed
startCheckTime - scheduleInfo.getEndTime() > 0) {
// TODO: special for scheduleInfo.isOneShot()
LOG.info("Rule " + ctx.getRuleId() + " exit rule executor due to time passed or finished");
ruleManager.updateRuleInfo(rid, RuleState.FINISHED, timeNow(), 0, 0);
exitSchedule();
}
List<String> files = executeFileRuleQuery();
long endCheckTime = System.currentTimeMillis();
int numCmdSubmitted = submitCommands(files, rid);
ruleManager.updateRuleInfo(rid, null, timeNow(), 1, numCmdSubmitted);
if (exited) {
exitSchedule();
}
//System.out.println(this + " -> " + System.currentTimeMillis());
long endProcessTime = System.currentTimeMillis();
if (endProcessTime - startCheckTime > 3000 || LOG.isDebugEnabled()) {
LOG.warn("Rule " + ctx.getRuleId() + " execution took " + (endProcessTime - startCheckTime) + "ms. QueryTime = " + (endCheckTime - startCheckTime) + "ms, SubmitTime = " + (endProcessTime - endCheckTime) + "ms.");
}
} catch (IOException e) {
LOG.error("Rule " + ctx.getRuleId() + " exception", e);
}
}
use of org.smartdata.server.rule.parser.TimeBasedScheduleInfo in project SSM by Intel-bigdata.
the class ExecutorScheduler method addPeriodicityTask.
public void addPeriodicityTask(RuleQueryExecutor re) {
TimeBasedScheduleInfo si = re.getTranslateResult().getTbScheduleInfo();
long now = System.currentTimeMillis();
service.scheduleAtFixedRate(re, si.getStartTime() - now, si.getEvery(), TimeUnit.MILLISECONDS);
}
Aggregations