/** * Reads the meta data from a row in the schedule store. * * @throws IllegalStateException if one of the expected fields is missing or ill-formed. */ private ProgramScheduleMeta extractMetaFromRow(ScheduleId scheduleId, Row row) { Long updatedTime = row.getLong(UPDATED_COLUMN_BYTES); String statusString = row.getString(STATUS_COLUMN_BYTES); try { Preconditions.checkArgument(updatedTime != null, "Last-updated timestamp is null"); Preconditions.checkArgument(statusString != null, "schedule status is null"); ProgramScheduleStatus status = ProgramScheduleStatus.valueOf(statusString); return new ProgramScheduleMeta(status, updatedTime); } catch (IllegalArgumentException e) { throw new IllegalStateException( String.format("Unexpected stored meta data for schedule %s: %s", scheduleId, e.getMessage())); } }
/** * Reads the meta data from a row in the schedule store. * * @throws IllegalStateException if one of the expected fields is missing or ill-formed. */ private ProgramScheduleMeta extractMetaFromRow(ScheduleId scheduleId, Row row) { Long updatedTime = row.getLong(UPDATED_COLUMN_BYTES); String statusString = row.getString(STATUS_COLUMN_BYTES); try { Preconditions.checkArgument(updatedTime != null, "Last-updated timestamp is null"); Preconditions.checkArgument(statusString != null, "schedule status is null"); ProgramScheduleStatus status = ProgramScheduleStatus.valueOf(statusString); return new ProgramScheduleMeta(status, updatedTime); } catch (IllegalArgumentException e) { throw new IllegalStateException( String.format("Unexpected stored meta data for schedule %s: %s", scheduleId, e.getMessage())); } }
@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()); } });
new ProgramScheduleRecord(SCHED1, new ProgramScheduleMeta(ProgramScheduleStatus.SCHEDULED, 0L)), notification);