Search in sources :

Example 6 with ScheduledRuntime

use of co.cask.cdap.proto.ScheduledRuntime in project cdap by caskdata.

the class WorkflowHttpHandler method getScheduledRuntime.

private void getScheduledRuntime(HttpResponder responder, String namespaceId, String appName, String workflowName, boolean previousRuntimeRequested) throws SchedulerException, NotFoundException {
    try {
        ApplicationId appId = new ApplicationId(namespaceId, appName);
        WorkflowId workflowId = new WorkflowId(appId, workflowName);
        ApplicationSpecification appSpec = store.getApplication(appId);
        if (appSpec == null) {
            throw new ApplicationNotFoundException(appId);
        }
        if (appSpec.getWorkflows().get(workflowName) == null) {
            throw new ProgramNotFoundException(workflowId);
        }
        List<ScheduledRuntime> runtimes;
        if (previousRuntimeRequested) {
            runtimes = timeScheduler.previousScheduledRuntime(workflowId, SchedulableProgramType.WORKFLOW);
        } else {
            runtimes = timeScheduler.nextScheduledRuntime(workflowId, SchedulableProgramType.WORKFLOW);
        }
        responder.sendJson(HttpResponseStatus.OK, GSON.toJson(runtimes));
    } catch (SecurityException e) {
        responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
    }
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) ApplicationNotFoundException(co.cask.cdap.common.ApplicationNotFoundException) ApplicationId(co.cask.cdap.proto.id.ApplicationId) WorkflowId(co.cask.cdap.proto.id.WorkflowId) ProgramNotFoundException(co.cask.cdap.common.ProgramNotFoundException) ScheduledRuntime(co.cask.cdap.proto.ScheduledRuntime)

Aggregations

ScheduledRuntime (co.cask.cdap.proto.ScheduledRuntime)6 NotFoundException (co.cask.cdap.common.NotFoundException)2 ProtoTrigger (co.cask.cdap.proto.ProtoTrigger)2 ScheduleDetail (co.cask.cdap.proto.ScheduleDetail)2 ApplicationId (co.cask.cdap.proto.id.ApplicationId)2 WorkflowId (co.cask.cdap.proto.id.WorkflowId)2 HttpResponse (org.apache.http.HttpResponse)2 Test (org.junit.Test)2 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)1 ApplicationNotFoundException (co.cask.cdap.common.ApplicationNotFoundException)1 ProgramNotFoundException (co.cask.cdap.common.ProgramNotFoundException)1 Id (co.cask.cdap.common.id.Id)1 AbstractSatisfiableCompositeTrigger (co.cask.cdap.internal.app.runtime.schedule.trigger.AbstractSatisfiableCompositeTrigger)1 SatisfiableTrigger (co.cask.cdap.internal.app.runtime.schedule.trigger.SatisfiableTrigger)1 TimeTrigger (co.cask.cdap.internal.app.runtime.schedule.trigger.TimeTrigger)1 ProgramId (co.cask.cdap.proto.id.ProgramId)1 HttpResponse (co.cask.common.http.HttpResponse)1 TypeToken (com.google.common.reflect.TypeToken)1 TypeToken (com.google.gson.reflect.TypeToken)1 IOException (java.io.IOException)1