use of co.cask.cdap.proto.id.ScheduleId in project cdap by caskdata.
the class CoreSchedulerServiceTest method enableSchedule.
private void enableSchedule(String name) throws NotFoundException, ConflictException {
ScheduleId scheduleId = APP_ID.schedule(name);
scheduler.enableSchedule(scheduleId);
Assert.assertEquals(ProgramScheduleStatus.SCHEDULED, scheduler.getScheduleStatus(scheduleId));
}
use of co.cask.cdap.proto.id.ScheduleId in project cdap by caskdata.
the class AddTimeScheduleCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String scheduleName = arguments.get(ArgumentName.SCHEDULE_NAME.toString());
String[] programIdParts = arguments.get(ArgumentName.PROGRAM.toString()).split("\\.");
String version = arguments.getOptional(ArgumentName.APP_VERSION.toString());
String scheduleDescription = arguments.getOptional(ArgumentName.DESCRIPTION.toString(), "");
String cronExpression = arguments.get(ArgumentName.CRON_EXPRESSION.toString());
String schedulePropertiesString = arguments.getOptional(ArgumentName.SCHEDULE_PROPERTIES.toString(), "");
String scheduleRunConcurrencyString = arguments.getOptional(ArgumentName.CONCURRENCY.toString(), null);
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
NamespaceId namespaceId = cliConfig.getCurrentNamespace();
ApplicationId applicationId = (version == null) ? namespaceId.app(appId) : namespaceId.app(appId, version);
ScheduleId scheduleId = applicationId.schedule(scheduleName);
Schedules.Builder builder = Schedules.builder(scheduleName);
if (scheduleRunConcurrencyString != null) {
builder.setMaxConcurrentRuns(Integer.valueOf(scheduleRunConcurrencyString));
}
if (scheduleDescription != null) {
builder.setDescription(scheduleDescription);
}
Schedule schedule = builder.createTimeSchedule(cronExpression);
Map<String, String> programMap = ImmutableMap.of("programName", programIdParts[1], "programType", ElementType.WORKFLOW.name().toUpperCase());
Map<String, String> propertiesMap = ArgumentParser.parseMap(schedulePropertiesString, ArgumentName.SCHEDULE_PROPERTIES.toString());
ScheduleInstanceConfiguration configuration = new ScheduleInstanceConfiguration("TIME", schedule, programMap, propertiesMap);
scheduleClient.add(scheduleId, configuration);
printStream.printf("Successfully added schedule '%s' in app '%s'\n", scheduleName, appId);
}
use of co.cask.cdap.proto.id.ScheduleId in project cdap by caskdata.
the class DeleteScheduleCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String[] programIdParts = arguments.get(ElementType.SCHEDULE.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
String scheduleName = programIdParts[1];
ScheduleId schedule = cliConfig.getCurrentNamespace().app(appId).schedule(scheduleName);
scheduleClient.delete(schedule);
printStream.printf("Successfully deleted schedule '%s' in app '%s'\n", scheduleName, appId);
}
use of co.cask.cdap.proto.id.ScheduleId in project cdap by caskdata.
the class GetScheduleStatusCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String[] programIdParts = arguments.get(ElementType.SCHEDULE.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
String scheduleName = programIdParts[1];
ScheduleId scheduleId = cliConfig.getCurrentNamespace().app(appId).schedule(scheduleName);
printStream.println(scheduleClient.getStatus(scheduleId));
}
use of co.cask.cdap.proto.id.ScheduleId in project cdap by caskdata.
the class SuspendScheduleCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String[] programIdParts = arguments.get(ElementType.SCHEDULE.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
String scheduleName = programIdParts[1];
ScheduleId scheduleId = cliConfig.getCurrentNamespace().app(appId).schedule(scheduleName);
scheduleClient.suspend(scheduleId);
printStream.printf("Successfully suspended schedule '%s' in app '%s'\n", scheduleName, appId);
}
Aggregations