Search in sources :

Example 11 with ScheduleId

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

Example 12 with 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);
}
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 13 with ScheduleId

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

Example 14 with ScheduleId

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

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

Aggregations

ScheduleId (co.cask.cdap.proto.id.ScheduleId)18 ApplicationId (co.cask.cdap.proto.id.ApplicationId)7 CommandInputError (co.cask.cdap.cli.exception.CommandInputError)6 ProgramSchedule (co.cask.cdap.internal.app.runtime.schedule.ProgramSchedule)5 Row (co.cask.cdap.api.dataset.table.Row)4 Scanner (co.cask.cdap.api.dataset.table.Scanner)4 NotFoundException (co.cask.cdap.common.NotFoundException)4 Scan (co.cask.cdap.api.dataset.table.Scan)3 Get (co.cask.cdap.api.dataset.table.Get)2 Schedule (co.cask.cdap.api.schedule.Schedule)2 Schedules (co.cask.cdap.api.schedule.Schedules)2 BadRequestException (co.cask.cdap.common.BadRequestException)2 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)2 ProgramType (co.cask.cdap.proto.ProgramType)2 ScheduleDetail (co.cask.cdap.proto.ScheduleDetail)2 ScheduleInstanceConfiguration (co.cask.cdap.proto.ScheduleInstanceConfiguration)2 NamespaceId (co.cask.cdap.proto.id.NamespaceId)2 ProgramId (co.cask.cdap.proto.id.ProgramId)2 ArrayList (java.util.ArrayList)2 Delete (co.cask.cdap.api.dataset.table.Delete)1