Search in sources :

Example 16 with CommandInputError

use of co.cask.cdap.cli.exception.CommandInputError in project cdap by caskdata.

the class GetProgramStatusCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
    if (programIdParts.length < 2) {
        throw new CommandInputError(this);
    }
    String appId = programIdParts[0];
    String programName = programIdParts[1];
    ProgramId programId = cliConfig.getCurrentNamespace().app(appId).program(elementType.getProgramType(), programName);
    String status = programClient.getStatus(programId);
    output.println(status);
}
Also used : CommandInputError(co.cask.cdap.cli.exception.CommandInputError) ProgramId(co.cask.cdap.proto.id.ProgramId)

Example 17 with CommandInputError

use of co.cask.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);
    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);
}
Also used : CommandInputError(co.cask.cdap.cli.exception.CommandInputError) Schedules(co.cask.cdap.api.schedule.Schedules) Schedule(co.cask.cdap.api.schedule.Schedule) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ScheduleInstanceConfiguration(co.cask.cdap.proto.ScheduleInstanceConfiguration) ApplicationId(co.cask.cdap.proto.id.ApplicationId) ScheduleId(co.cask.cdap.proto.id.ScheduleId)

Example 18 with CommandInputError

use of co.cask.cdap.cli.exception.CommandInputError 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);
}
Also used : CommandInputError(co.cask.cdap.cli.exception.CommandInputError) ScheduleId(co.cask.cdap.proto.id.ScheduleId)

Example 19 with CommandInputError

use of co.cask.cdap.cli.exception.CommandInputError 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));
}
Also used : CommandInputError(co.cask.cdap.cli.exception.CommandInputError) ScheduleId(co.cask.cdap.proto.id.ScheduleId)

Example 20 with CommandInputError

use of co.cask.cdap.cli.exception.CommandInputError 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);
}
Also used : CommandInputError(co.cask.cdap.cli.exception.CommandInputError) ScheduleId(co.cask.cdap.proto.id.ScheduleId)

Aggregations

CommandInputError (co.cask.cdap.cli.exception.CommandInputError)21 ProgramId (co.cask.cdap.proto.id.ProgramId)8 Table (co.cask.cdap.cli.util.table.Table)7 ApplicationId (co.cask.cdap.proto.id.ApplicationId)6 ScheduleId (co.cask.cdap.proto.id.ScheduleId)6 RowMaker (co.cask.cdap.cli.util.RowMaker)4 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)4 Schedule (co.cask.cdap.api.schedule.Schedule)2 Schedules (co.cask.cdap.api.schedule.Schedules)2 ScheduleInstanceConfiguration (co.cask.cdap.proto.ScheduleInstanceConfiguration)2 FlowletId (co.cask.cdap.proto.id.FlowletId)2 NamespaceId (co.cask.cdap.proto.id.NamespaceId)2 ServiceId (co.cask.cdap.proto.id.ServiceId)2 WorkflowActionNode (co.cask.cdap.api.workflow.WorkflowActionNode)1 WorkflowToken (co.cask.cdap.api.workflow.WorkflowToken)1 Containers (co.cask.cdap.proto.Containers)1 DistributedProgramLiveInfo (co.cask.cdap.proto.DistributedProgramLiveInfo)1 RunRecord (co.cask.cdap.proto.RunRecord)1 ScheduleDetail (co.cask.cdap.proto.ScheduleDetail)1 WorkflowId (co.cask.cdap.proto.id.WorkflowId)1