Search in sources :

Example 11 with WorkflowId

use of co.cask.cdap.proto.id.WorkflowId 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 = scheduler.previousScheduledRuntime(workflowId, SchedulableProgramType.WORKFLOW);
        } else {
            runtimes = scheduler.nextScheduledRuntime(workflowId, SchedulableProgramType.WORKFLOW);
        }
        responder.sendJson(HttpResponseStatus.OK, 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

WorkflowId (co.cask.cdap.proto.id.WorkflowId)11 NotFoundException (co.cask.cdap.common.NotFoundException)4 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)3 ApplicationNotFoundException (co.cask.cdap.common.ApplicationNotFoundException)3 ProgramNotFoundException (co.cask.cdap.common.ProgramNotFoundException)3 WorkflowStatsComparison (co.cask.cdap.proto.WorkflowStatsComparison)3 ApplicationId (co.cask.cdap.proto.id.ApplicationId)3 ProgramId (co.cask.cdap.proto.id.ProgramId)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Test (org.junit.Test)3 WorkflowApp (co.cask.cdap.WorkflowApp)2 BadRequestException (co.cask.cdap.common.BadRequestException)2 ScheduleDetail (co.cask.cdap.proto.ScheduleDetail)2 TypeToken (com.google.gson.reflect.TypeToken)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HttpResponse (org.apache.http.HttpResponse)2 RunId (org.apache.twill.api.RunId)2 TxRunnable (co.cask.cdap.api.TxRunnable)1