Search in sources :

Example 6 with ProgramScheduleMeta

use of io.cdap.cdap.internal.app.runtime.schedule.ProgramScheduleMeta in project cdap by caskdata.

the class ProgramScheduleStoreDataset method extractMetaFromRow.

/**
 * 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, StructuredRow row) {
    Long updatedTime = row.getLong(StoreDefinition.ProgramScheduleStore.UPDATE_TIME);
    String statusString = row.getString(StoreDefinition.ProgramScheduleStore.STATUS);
    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()));
    }
}
Also used : ProgramScheduleMeta(io.cdap.cdap.internal.app.runtime.schedule.ProgramScheduleMeta) ProgramScheduleStatus(io.cdap.cdap.internal.app.runtime.schedule.ProgramScheduleStatus)

Aggregations

ProgramScheduleMeta (io.cdap.cdap.internal.app.runtime.schedule.ProgramScheduleMeta)6 ProgramScheduleRecord (io.cdap.cdap.internal.app.runtime.schedule.ProgramScheduleRecord)5 ProgramSchedule (io.cdap.cdap.internal.app.runtime.schedule.ProgramSchedule)3 Notification (io.cdap.cdap.proto.Notification)3 NotFoundException (io.cdap.cdap.common.NotFoundException)2 StructuredRow (io.cdap.cdap.spi.data.StructuredRow)2 Test (org.junit.Test)2 ProgramScheduleStatus (io.cdap.cdap.internal.app.runtime.schedule.ProgramScheduleStatus)1 PartitionTrigger (io.cdap.cdap.internal.app.runtime.schedule.trigger.PartitionTrigger)1 ScheduleId (io.cdap.cdap.proto.id.ScheduleId)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1