use of io.cdap.cdap.cli.exception.CommandInputError in project cdap by cdapio.
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 io.cdap.cdap.cli.exception.CommandInputError in project cdap by cdapio.
the class ListWorkflowSchedulesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(ElementType.WORKFLOW.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
final String appId = programIdParts[0];
String workflowName = programIdParts[1];
WorkflowId workflowId = cliConfig.getCurrentNamespace().app(appId).workflow(workflowName);
List<ScheduleDetail> list = scheduleClient.listSchedules(workflowId);
Table table = Table.builder().setHeader("application", "program", "program type", "name", "description", "trigger", "timeoutMillis", "properties").setRows(list, new RowMaker<ScheduleDetail>() {
@Override
public List<?> makeRow(ScheduleDetail object) {
return Lists.newArrayList(appId, object.getProgram().getProgramName(), object.getProgram().getProgramType().name(), object.getName(), object.getDescription(), object.getTrigger(), object.getTimeoutMillis(), GSON.toJson(object.getProperties()));
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.exception.CommandInputError in project cdap by cdapio.
the class ResumeScheduleCommand 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.resume(schedule);
printStream.printf("Successfully resumed schedule '%s' in app '%s'\n", scheduleName, appId);
}
use of io.cdap.cdap.cli.exception.CommandInputError in project cdap by cdapio.
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);
}
use of io.cdap.cdap.cli.exception.CommandInputError 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);
String description = scheduleDescription == null ? null : scheduleDescription;
ScheduleProgramInfo programInfo = new ScheduleProgramInfo(SchedulableProgramType.WORKFLOW, programIdParts[1]);
List<Constraint> constraints = scheduleRunConcurrencyString == null ? ImmutableList.of() : ImmutableList.of(new ProtoConstraint.ConcurrencyConstraint(Integer.valueOf(scheduleRunConcurrencyString)));
Map<String, String> propertiesMap = ArgumentParser.parseMap(schedulePropertiesString, ArgumentName.SCHEDULE_PROPERTIES.toString());
ScheduleDetail scheduleDetail = new ScheduleDetail(scheduleName, description, programInfo, propertiesMap, new ProtoTrigger.TimeTrigger(cronExpression), constraints, null);
scheduleClient.add(scheduleId, scheduleDetail);
printStream.printf("Successfully added schedule '%s' in app '%s'\n", scheduleName, appId);
}
Aggregations