use of io.cdap.cdap.proto.id.ScheduleId in project cdap by cdapio.
the class SparkTest method testSparkProgramStatusSchedule.
@Test
public void testSparkProgramStatusSchedule() throws Exception {
ApplicationManager appManager = deploy(TestSparkApp.class);
ScheduleId scheduleId = new ScheduleId(NamespaceId.DEFAULT.getNamespace(), TestSparkApp.class.getSimpleName(), "schedule");
appManager.enableSchedule(scheduleId);
WorkflowManager workflowManager = appManager.getWorkflowManager(TestSparkApp.TriggeredWorkflow.class.getSimpleName());
int numRuns = workflowManager.getHistory(ProgramRunStatus.COMPLETED).size();
// Start the upstream program
SparkManager sparkManager = appManager.getSparkManager(TestSparkApp.ScalaClassicSpark.class.getSimpleName());
sparkManager.start();
// Wait for the downstream to complete
workflowManager.waitForRun(ProgramRunStatus.COMPLETED, 5, TimeUnit.MINUTES);
// Run again with the kryo serializer
sparkManager.start(Collections.singletonMap("spark.serializer", "org.apache.spark.serializer.KryoSerializer"));
// Wait for the downstream to complete again
workflowManager.waitForRuns(ProgramRunStatus.COMPLETED, numRuns + 2, 5, TimeUnit.MINUTES);
}
use of io.cdap.cdap.proto.id.ScheduleId in project cdap by cdapio.
the class ProgramScheduleStoreDataset method deleteSchedules.
/**
* Removes all schedules for a specific application from the store.
*
* @param appId the application 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(ApplicationId appId, long deleteTime) throws IOException {
List<ScheduleId> deleted = new ArrayList<>();
Collection<Field<?>> scanKeys = getScheduleKeysForApplicationScan(appId);
Range range = Range.singleton(scanKeys);
// First collect all the schedules that are going to be deleted
try (CloseableIterator<StructuredRow> iterator = scheduleStore.scan(range, Integer.MAX_VALUE)) {
while (iterator.hasNext()) {
StructuredRow row = iterator.next();
if (row.getString(StoreDefinition.ProgramScheduleStore.SCHEDULE) != null) {
markScheduleAsDeleted(row, deleteTime);
deleted.add(rowToScheduleId(row));
}
}
}
// Then delete all triggers for the app
triggerStore.deleteAll(range);
return deleted;
}
use of io.cdap.cdap.proto.id.ScheduleId in project cdap by cdapio.
the class ProgramScheduleStoreDataset method deleteSchedules.
/**
* 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, long deleteTime) throws IOException {
List<ScheduleId> deleted = new ArrayList<>();
Collection<Field<?>> scanKeys = getScheduleKeysForApplicationScan(programId.getParent());
Range range = Range.singleton(scanKeys);
// First collect all the schedules that are going to be deleted
try (CloseableIterator<StructuredRow> iterator = scheduleStore.scan(range, Integer.MAX_VALUE)) {
while (iterator.hasNext()) {
StructuredRow row = iterator.next();
String serializedSchedule = row.getString(StoreDefinition.ProgramScheduleStore.SCHEDULE);
if (serializedSchedule != null) {
ProgramSchedule schedule = GSON.fromJson(serializedSchedule, ProgramSchedule.class);
if (programId.equals(schedule.getProgramId())) {
markScheduleAsDeleted(row, deleteTime);
Collection<Field<?>> deleteKeys = getScheduleKeys(row);
triggerStore.deleteAll(Range.singleton(deleteKeys));
deleted.add(rowToScheduleId(row));
}
}
}
}
return deleted;
}
use of io.cdap.cdap.proto.id.ScheduleId in project cdap by cdapio.
the class ProgramScheduleStoreDataset method deleteSchedules.
/**
* Removes one or more schedules from the store. Succeeds whether the schedules exist or not.
*
* @param scheduleIds the schedules to delete
* @throws NotFoundException if one of the schedules does not exist in the store
*/
public void deleteSchedules(Iterable<? extends ScheduleId> scheduleIds, @Nullable Long deleteTime) throws NotFoundException, IOException {
if (deleteTime == null) {
deleteTime = System.currentTimeMillis();
}
for (ScheduleId scheduleId : scheduleIds) {
StructuredRow existingRow = readExistingScheduleRow(scheduleId);
markScheduleAsDeleted(existingRow, deleteTime);
Collection<Field<?>> scheduleKeys = getScheduleKeys(scheduleId);
triggerStore.deleteAll(Range.singleton(scheduleKeys));
}
}
use of io.cdap.cdap.proto.id.ScheduleId in project cdap by cdapio.
the class ProgramScheduleRecord method toScheduleDetail.
public ScheduleDetail toScheduleDetail() {
ScheduleProgramInfo programInfo = new ScheduleProgramInfo(schedule.getProgramId().getType().getSchedulableType(), schedule.getProgramId().getProgram());
ScheduleId scheduleId = schedule.getScheduleId();
return new ScheduleDetail(scheduleId.getNamespace(), scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule(), schedule.getDescription(), programInfo, schedule.getProperties(), schedule.getTrigger(), schedule.getConstraints(), schedule.getTimeoutMillis(), meta.getStatus().name(), meta.getLastUpdated());
}
Aggregations