@Override public ProgramScheduleStatus getScheduleStatus(ScheduleId scheduleId) throws NotFoundException { checkStarted(); return execute(store -> store.getScheduleRecord(scheduleId).getMeta().getStatus(), NotFoundException.class); }
@Override public ProgramScheduleStatus getScheduleStatus(ScheduleId scheduleId) throws NotFoundException { checkStarted(); return execute(store -> store.getScheduleRecord(scheduleId).getMeta().getStatus(), NotFoundException.class); }
.filter(record -> programScheduleStatus == null || record.getMeta().getStatus().equals(programScheduleStatus)) .map(ProgramScheduleRecord::toScheduleDetail) .collect(Collectors.toList());
.filter(record -> programScheduleStatus == null || record.getMeta().getStatus().equals(programScheduleStatus)) .map(ProgramScheduleRecord::toScheduleDetail) .collect(Collectors.toList());
@Override public void disableSchedule(ScheduleId scheduleId) throws NotFoundException, ConflictException { checkStarted(); try { execute((StoreAndQueueTxRunnable<Void, Exception>) (store, queue) -> { ProgramScheduleRecord record = store.getScheduleRecord(scheduleId); if (ProgramScheduleStatus.SCHEDULED != record.getMeta().getStatus()) { throw new ConflictException("Schedule '" + scheduleId + "' is already disabled"); } timeSchedulerService.suspendProgramSchedule(record.getSchedule()); store.updateScheduleStatus(scheduleId, ProgramScheduleStatus.SUSPENDED); queue.markJobsForDeletion(scheduleId, System.currentTimeMillis()); return null; }, Exception.class); } catch (NotFoundException | ConflictException e) { throw e; } catch (SchedulerException e) { // TODO: [CDAP-11574] temporarily catch the SchedulerException and throw RuntimeException. throw new RuntimeException("Exception occurs when enabling schedule " + scheduleId, e); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void enableSchedule(ScheduleId scheduleId) throws NotFoundException, ConflictException { checkStarted(); try { execute((StoreTxRunnable<Void, Exception>) store -> { ProgramScheduleRecord record = store.getScheduleRecord(scheduleId); if (ProgramScheduleStatus.SUSPENDED != record.getMeta().getStatus()) { throw new ConflictException("Schedule '" + scheduleId + "' is already enabled"); } timeSchedulerService.resumeProgramSchedule(record.getSchedule()); store.updateScheduleStatus(scheduleId, ProgramScheduleStatus.SCHEDULED); return null; }, Exception.class); } catch (NotFoundException | ConflictException e) { throw e; } catch (SchedulerException e) { // TODO: [CDAP-11574] temporarily catch the SchedulerException and throw RuntimeException. throw new RuntimeException("Exception occurs when enabling schedule " + scheduleId, e); } catch (Exception e) { throw Throwables.propagate(e); } }
predicate = predicate.and(record -> record.getMeta().getStatus().equals(status));
predicate = predicate.and(record -> record.getMeta().getStatus().equals(status));
@Override public void enableSchedule(ScheduleId scheduleId) throws NotFoundException, ConflictException { checkStarted(); try { execute((StoreTxRunnable<Void, Exception>) store -> { ProgramScheduleRecord record = store.getScheduleRecord(scheduleId); if (ProgramScheduleStatus.SUSPENDED != record.getMeta().getStatus()) { throw new ConflictException("Schedule '" + scheduleId + "' is already enabled"); } timeSchedulerService.resumeProgramSchedule(record.getSchedule()); store.updateScheduleStatus(scheduleId, ProgramScheduleStatus.SCHEDULED); return null; }, Exception.class); } catch (NotFoundException | ConflictException e) { throw e; } catch (SchedulerException e) { // TODO: [CDAP-11574] temporarily catch the SchedulerException and throw RuntimeException. throw new RuntimeException("Exception occurs when enabling schedule " + scheduleId, e); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void disableSchedule(ScheduleId scheduleId) throws NotFoundException, ConflictException { checkStarted(); try { execute((StoreAndQueueTxRunnable<Void, Exception>) (store, queue) -> { ProgramScheduleRecord record = store.getScheduleRecord(scheduleId); if (ProgramScheduleStatus.SCHEDULED != record.getMeta().getStatus()) { throw new ConflictException("Schedule '" + scheduleId + "' is already disabled"); } timeSchedulerService.suspendProgramSchedule(record.getSchedule()); store.updateScheduleStatus(scheduleId, ProgramScheduleStatus.SUSPENDED); queue.markJobsForDeletion(scheduleId, System.currentTimeMillis()); return null; }, Exception.class); } catch (NotFoundException | ConflictException e) { throw e; } catch (SchedulerException e) { // TODO: [CDAP-11574] temporarily catch the SchedulerException and throw RuntimeException. throw new RuntimeException("Exception occurs when enabling schedule " + scheduleId, e); } catch (Exception e) { throw Throwables.propagate(e); } }
schedule.getProgramId(), schedule.getProperties(), updatedTrigger, schedule.getConstraints(), schedule.getTimeoutMillis()), scheduleRecord.getMeta().getStatus(), System.currentTimeMillis()); } catch (AlreadyExistsException e) {
schedule.getProgramId(), schedule.getProperties(), updatedTrigger, schedule.getConstraints(), schedule.getTimeoutMillis()), scheduleRecord.getMeta().getStatus(), System.currentTimeMillis()); } catch (AlreadyExistsException e) {
if (record.getMeta().getStatus() != ProgramScheduleStatus.SCHEDULED) { return; long scheduleLastUpdated = record.getMeta().getLastUpdated(); if (job.getScheduleLastUpdatedTime() != scheduleLastUpdated) { ? Job.State.PENDING_CONSTRAINT : Job.State.PENDING_TRIGGER; put(new SimpleJob(schedule, System.currentTimeMillis(), notifications, jobState, record.getMeta().getLastUpdated()));
if (record.getMeta().getStatus() != ProgramScheduleStatus.SCHEDULED) { return; long scheduleLastUpdated = record.getMeta().getLastUpdated(); if (job.getScheduleLastUpdatedTime() != scheduleLastUpdated) { ? Job.State.PENDING_CONSTRAINT : Job.State.PENDING_TRIGGER; put(new SimpleJob(schedule, System.currentTimeMillis(), notifications, jobState, record.getMeta().getLastUpdated()));