public JobSchedulerImpl readPayload(DataInput dataIn) throws IOException { JobSchedulerImpl result = new JobSchedulerImpl(this.store); result.read(dataIn); return result; }
void loadScheduler(Transaction tx, Map<String, JobSchedulerImpl> schedulers) throws IOException { for (Iterator<Entry<String, JobSchedulerImpl>> i = this.storedSchedulers.iterator(tx); i.hasNext();) { Entry<String, JobSchedulerImpl> entry = i.next(); entry.getValue().load(tx); schedulers.put(entry.getKey(), entry.getValue()); } }
Map.Entry<Long, List<JobLocation>> first = getNextToSchedule(); if (first != null) { List<JobLocation> list = new ArrayList<JobLocation>(first.getValue()); for (final JobLocation job : list) { int repeat = job.getRepeat(); nextExecutionTime = calculateNextExecutionTime(job, currentTime, repeat); long waitTime = nextExecutionTime - currentTime; this.scheduleTime.setWaitTime(waitTime); if (job.isCron() == false) { fireJob(job); if (repeat != 0) { repeat--; removeFromIndex(executionTime, job.getJobId()); storeJob(job, nextExecutionTime); fireJob(job); removeFromIndex(executionTime, job.getJobId()); storeJob(job, nextExecutionTime); if (repeat != 0) { ByteSequence payload = getPayload(job.getLocation()); schedule(jobId, payload, "", job.getDelay(), job.getPeriod(), job.getRepeat()); waitTime = job.getDelay() != 0 ? job.getDelay() : job.getPeriod(); this.scheduleTime.setWaitTime(waitTime);
public JobScheduler getJobScheduler(final String name) throws Exception { JobSchedulerImpl result = this.schedulers.get(name); if (result == null) { final JobSchedulerImpl js = new JobSchedulerImpl(this); js.setName(name); getPageFile().tx().execute(new Transaction.Closure<IOException>() { public void execute(Transaction tx) throws IOException { js.createIndexes(tx); js.load(tx); metaData.storedSchedulers.put(tx, name, js); } }); result = js; this.schedulers.put(name, js); if (isStarted()) { result.start(); } this.pageFile.flush(); } return result; }
void remove(Transaction tx, String id) throws IOException { for (Iterator<Map.Entry<Long, List<JobLocation>>> i = this.index.iterator(tx); i.hasNext();) { Map.Entry<Long, List<JobLocation>> entry = i.next(); List<JobLocation> values = entry.getValue(); if (values != null) { for (JobLocation jl : values) { if (jl.getJobId().equals(id)) { remove(tx, entry.getKey(), id); return; } } } } }