Tabnine Logo
ProgramScheduleRecord
Code IndexAdd Tabnine to your IDE (free)

How to use
ProgramScheduleRecord
in
co.cask.cdap.internal.app.runtime.schedule

Best Java code snippets using co.cask.cdap.internal.app.runtime.schedule.ProgramScheduleRecord (Showing top 20 results out of 315)

origin: co.cask.cdap/cdap-app-fabric

/**
 * List schedule records with the given key prefix and only returns the schedules that can pass the filter.
 *
 * @param prefix the prefix of the schedule records to be listed
 * @param filter a filter that only returns true if the schedule record will be returned in the result
 * @return the schedule records with the given key prefix that can pass the filter
 */
private List<ProgramScheduleRecord> listSchedulesRecordsWithPrefix(byte[] prefix,
                                  Predicate<ProgramSchedule> filter) {
 List<ProgramScheduleRecord> result = new ArrayList<>();
 try (Scanner scanner = store.scan(new Scan(prefix, Bytes.stopKeyForPrefix(prefix)))) {
  Row row;
  while ((row = scanner.next()) != null) {
   byte[] serialized = row.get(SCHEDULE_COLUMN_BYTES);
   if (serialized != null) {
    ProgramSchedule schedule = GSON.fromJson(Bytes.toString(serialized), ProgramSchedule.class);
    if (schedule != null && filter.test(schedule)) {
     result.add(new ProgramScheduleRecord(schedule, extractMetaFromRow(schedule.getScheduleId(), row)));
    }
   }
  }
 }
 return result;
}
origin: co.cask.cdap/cdap-app-fabric

@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);
 }
}
origin: cdapio/cdap

@Override
public ProgramScheduleStatus getScheduleStatus(ScheduleId scheduleId) throws NotFoundException {
 checkStarted();
 return execute(store -> store.getScheduleRecord(scheduleId).getMeta().getStatus(), NotFoundException.class);
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public ProgramScheduleStatus getScheduleStatus(ScheduleId scheduleId) throws NotFoundException {
 checkStarted();
 return execute(store -> store.getScheduleRecord(scheduleId).getMeta().getStatus(), NotFoundException.class);
}
origin: cdapio/cdap

@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);
 }
}
origin: cdapio/cdap

/**
 * List schedule records with the given key prefix and only returns the schedules that can pass the filter.
 *
 * @param prefix the prefix of the schedule records to be listed
 * @param filter a filter that only returns true if the schedule record will be returned in the result
 * @return the schedule records with the given key prefix that can pass the filter
 */
private List<ProgramScheduleRecord> listSchedulesRecordsWithPrefix(byte[] prefix,
                                  Predicate<ProgramSchedule> filter) {
 List<ProgramScheduleRecord> result = new ArrayList<>();
 try (Scanner scanner = store.scan(new Scan(prefix, Bytes.stopKeyForPrefix(prefix)))) {
  Row row;
  while ((row = scanner.next()) != null) {
   byte[] serialized = row.get(SCHEDULE_COLUMN_BYTES);
   if (serialized != null) {
    ProgramSchedule schedule = GSON.fromJson(Bytes.toString(serialized), ProgramSchedule.class);
    if (schedule != null && filter.test(schedule)) {
     result.add(new ProgramScheduleRecord(schedule, extractMetaFromRow(schedule.getScheduleId(), row)));
    }
   }
  }
 }
 return result;
}
origin: cdapio/cdap

.filter(record -> programScheduleStatus == null || record.getMeta().getStatus().equals(programScheduleStatus))
.map(ProgramScheduleRecord::toScheduleDetail)
.collect(Collectors.toList());
origin: cdapio/cdap

@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);
 }
}
origin: cdapio/cdap

 ProgramScheduleRecord record = new ProgramScheduleRecord(schedule, meta);
 schedulesFound.put(scheduleId, record);
} catch (IllegalArgumentException | NotFoundException e) {
origin: co.cask.cdap/cdap-app-fabric

.filter(record -> programScheduleStatus == null || record.getMeta().getStatus().equals(programScheduleStatus))
.map(ProgramScheduleRecord::toScheduleDetail)
.collect(Collectors.toList());
origin: co.cask.cdap/cdap-app-fabric

@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);
 }
}
origin: co.cask.cdap/cdap-app-fabric

 ProgramScheduleRecord record = new ProgramScheduleRecord(schedule, meta);
 schedulesFound.put(scheduleId, record);
} catch (IllegalArgumentException | NotFoundException e) {
origin: cdapio/cdap

predicate = predicate.and(record -> record.getMeta().getStatus().equals(status));
predicate = predicate.and(record -> record.getSchedule().getTrigger().getType().equals(triggerType));
origin: cdapio/cdap

/**
 * Read all information about a schedule from the store.
 *
 * @param scheduleId the id of the schedule to read
 * @return the schedule record from the store
 * @throws NotFoundException if the schedule does not exist in the store
 */
public ProgramScheduleRecord getScheduleRecord(ScheduleId scheduleId) throws NotFoundException {
 Row row = store.get(new Get(rowKeyForSchedule(scheduleId)));
 byte[] serialized = row.get(SCHEDULE_COLUMN_BYTES);
 if (serialized == null) {
  throw new NotFoundException(scheduleId);
 }
 ProgramSchedule schedule = GSON.fromJson(Bytes.toString(serialized), ProgramSchedule.class);
 ProgramScheduleMeta meta = extractMetaFromRow(scheduleId, row);
 return new ProgramScheduleRecord(schedule, meta);
}
origin: co.cask.cdap/cdap-app-fabric

predicate = predicate.and(record -> record.getMeta().getStatus().equals(status));
predicate = predicate.and(record -> record.getSchedule().getTrigger().getType().equals(triggerType));
origin: co.cask.cdap/cdap-app-fabric

/**
 * Read all information about a schedule from the store.
 *
 * @param scheduleId the id of the schedule to read
 * @return the schedule record from the store
 * @throws NotFoundException if the schedule does not exist in the store
 */
public ProgramScheduleRecord getScheduleRecord(ScheduleId scheduleId) throws NotFoundException {
 Row row = store.get(new Get(rowKeyForSchedule(scheduleId)));
 byte[] serialized = row.get(SCHEDULE_COLUMN_BYTES);
 if (serialized == null) {
  throw new NotFoundException(scheduleId);
 }
 ProgramSchedule schedule = GSON.fromJson(Bytes.toString(serialized), ProgramSchedule.class);
 ProgramScheduleMeta meta = extractMetaFromRow(scheduleId, row);
 return new ProgramScheduleRecord(schedule, meta);
}
origin: cdapio/cdap

ProgramSchedule schedule = scheduleRecord.getSchedule();
try {
 deleteSchedule(schedule.getScheduleId());
                       schedule.getProgramId(), schedule.getProperties(), updatedTrigger,
                       schedule.getConstraints(), schedule.getTimeoutMillis()),
             scheduleRecord.getMeta().getStatus(), System.currentTimeMillis());
 } catch (AlreadyExistsException e) {
origin: cdapio/cdap

 @Override
 public void apply() throws Exception {
  // should be 0 jobs in the JobQueue to begin with
  Assert.assertEquals(0, getAllJobs(jobQueue, false).size());
  // Construct a partition notification with DATASET_ID
  Notification notification = Notification.forPartitions(DATASET_ID, ImmutableList.<PartitionKey>of());
  Assert.assertNull(jobQueue.getJob(SCHED1_JOB.getJobKey()));
  jobQueue.put(SCHED1_JOB);
  Assert.assertEquals(SCHED1_JOB, jobQueue.getJob(SCHED1_JOB.getJobKey()));
  // Since notification and SCHED1 have the same dataset id DATASET_ID, notification will be added to
  // SCHED1_JOB, which is a job in SCHED1
  jobQueue.addNotification(
   new ProgramScheduleRecord(SCHED1, new ProgramScheduleMeta(ProgramScheduleStatus.SCHEDULED, 0L)),
   notification);
  Assert.assertEquals(ImmutableList.of(notification), jobQueue.getJob(SCHED1_JOB.getJobKey()).getNotifications());
 }
});
origin: co.cask.cdap/cdap-app-fabric

ProgramSchedule schedule = scheduleRecord.getSchedule();
try {
 deleteSchedule(schedule.getScheduleId());
                       schedule.getProgramId(), schedule.getProperties(), updatedTrigger,
                       schedule.getConstraints(), schedule.getTimeoutMillis()),
             scheduleRecord.getMeta().getStatus(), System.currentTimeMillis());
 } catch (AlreadyExistsException e) {
origin: cdapio/cdap

new ProgramScheduleRecord(SCHED1, new ProgramScheduleMeta(ProgramScheduleStatus.SCHEDULED, 0L)),
notification);
co.cask.cdap.internal.app.runtime.scheduleProgramScheduleRecord

Javadoc

Represents all information for a schedule in the schedule store.

Most used methods

  • <init>
  • getMeta
  • getSchedule

Popular in Java

  • Finding current android device location
  • startActivity (Activity)
  • setContentView (Activity)
  • getResourceAsStream (ClassLoader)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now