@Override public boolean apply(RuntimeInfo info) { return info.getProgramId().equals(program); } });
@Override public boolean apply(RuntimeInfo info) { return info.getProgramId().equals(program); } });
@Override public Iterable<TwillController> lookup(String applicationName) { ProgramId programId = TwillAppNames.fromTwillAppName(applicationName, false); if (programId == null) { return Collections.emptyList(); } return controllers.entrySet().stream() .filter(entry -> programId.equals(entry.getKey().getParent())) .map(Map.Entry::getValue) .map(TwillController.class::cast) ::iterator; }
@Override public Iterable<TwillController> lookup(String applicationName) { ProgramId programId = TwillAppNames.fromTwillAppName(applicationName, false); if (programId == null) { return Collections.emptyList(); } return controllers.entrySet().stream() .filter(entry -> programId.equals(entry.getKey().getParent())) .map(Map.Entry::getValue) .map(TwillController.class::cast) ::iterator; }
protected ProgramRuntimeService.RuntimeInfo findRuntimeInfo(ProgramId programId, ProgramRuntimeService runtimeService) { Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos = runtimeService.list(programId.getType()).values(); Preconditions.checkNotNull(runtimeInfos, UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND), programId); for (ProgramRuntimeService.RuntimeInfo info : runtimeInfos) { if (programId.equals(info.getProgramId())) { return info; } } return null; }
protected ProgramRuntimeService.RuntimeInfo findRuntimeInfo(ProgramId programId, ProgramRuntimeService runtimeService) { Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos = runtimeService.list(programId.getType()).values(); Preconditions.checkNotNull(runtimeInfos, UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND), programId); for (ProgramRuntimeService.RuntimeInfo info : runtimeInfos) { if (programId.equals(info.getProgramId())) { return info; } } return null; }
for (SatisfiableTrigger trigger : getTriggers()) { if (trigger instanceof ProgramStatusTrigger && programId.equals(((ProgramStatusTrigger) trigger).getProgramId())) {
for (SatisfiableTrigger trigger : getTriggers()) { if (trigger instanceof ProgramStatusTrigger && programId.equals(((ProgramStatusTrigger) trigger).getProgramId())) {
for (SatisfiableTrigger trigger : getTriggers()) { if (trigger instanceof ProgramStatusTrigger && programId.equals(((ProgramStatusTrigger) trigger).getProgramId())) {
for (SatisfiableTrigger trigger : getTriggers()) { if (trigger instanceof ProgramStatusTrigger && programId.equals(((ProgramStatusTrigger) trigger).getProgramId())) {
/** * Retrieve all schedule records for a given program. * * @param programId the program for which to list the schedule records. * @return a list of schedule records for the program; never null */ public List<ProgramScheduleRecord> listScheduleRecords(ProgramId programId) { byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); return listSchedulesRecordsWithPrefix(prefix, schedule -> programId.equals(schedule.getProgramId())); }
/** * Retrieve all schedules for a given program. * * @param programId the program for which to list the schedules. * @return a list of schedules for the program; never null */ public List<ProgramSchedule> listSchedules(ProgramId programId) { byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); return listSchedulesWithPrefix(prefix, schedule -> programId.equals(schedule.getProgramId())); }
/** * Retrieve all schedule records for a given program. * * @param programId the program for which to list the schedule records. * @return a list of schedule records for the program; never null */ public List<ProgramScheduleRecord> listScheduleRecords(ProgramId programId) { byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); return listSchedulesRecordsWithPrefix(prefix, schedule -> programId.equals(schedule.getProgramId())); }
/** * Retrieve all schedules for a given program. * * @param programId the program for which to list the schedules. * @return a list of schedules for the program; never null */ public List<ProgramSchedule> listSchedules(ProgramId programId) { byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); return listSchedulesWithPrefix(prefix, schedule -> programId.equals(schedule.getProgramId())); }
if (this.programId.equals(triggeringProgramId) && programStatuses.contains(programStatus)) { return function.apply(new ProgramRunInfo(programStatus, programRunId));
if (this.programId.equals(triggeringProgramId) && programStatuses.contains(programStatus)) { return function.apply(new ProgramRunInfo(programStatus, programRunId));
/** * Removes all schedules for a specific program from the store. * * @param programId the program id for which to delete the schedules * @return the IDs of the schedules that were deleted */ // TODO: fix the bug that this method will return fake schedule id https://issues.cask.co/browse/CDAP-13626 public List<ScheduleId> deleteSchedules(ProgramId programId) { List<ScheduleId> deleted = new ArrayList<>(); // since all trigger row keys are prefixed by <scheduleRowKey>@, // a scan for that prefix finds exactly the schedules and all of its triggers byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); 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 (programId.equals(schedule.getProgramId())) { store.delete(row.getRow()); deleted.add(schedule.getScheduleId()); } } } } return deleted; }
/** * Removes all schedules for a specific program from the store. * * @param programId the program id for which to delete the schedules * @return the IDs of the schedules that were deleted */ // TODO: fix the bug that this method will return fake schedule id https://issues.cask.co/browse/CDAP-13626 public List<ScheduleId> deleteSchedules(ProgramId programId) { List<ScheduleId> deleted = new ArrayList<>(); // since all trigger row keys are prefixed by <scheduleRowKey>@, // a scan for that prefix finds exactly the schedules and all of its triggers byte[] prefix = keyPrefixForApplicationScan(programId.getParent()); 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 (programId.equals(schedule.getProgramId())) { store.delete(row.getRow()); deleted.add(schedule.getScheduleId()); } } } } return deleted; }
: ProgramType.valueOfSchedulableType(scheduleDetail.getProgram().getProgramType()), Objects.firstNonNull(scheduleDetail.getProgram().getProgramName(), existing.getProgramId().getProgram())); if (!programId.equals(existing.getProgramId())) { throw new BadRequestException( String.format("Must update the schedule '%s' with the same program as '%s'. "
: ProgramType.valueOfSchedulableType(scheduleDetail.getProgram().getProgramType()), Objects.firstNonNull(scheduleDetail.getProgram().getProgramName(), existing.getProgramId().getProgram())); if (!programId.equals(existing.getProgramId())) { throw new BadRequestException( String.format("Must update the schedule '%s' with the same program as '%s'. "