Search in sources :

Example 11 with WorkflowNodeStateDetail

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

the class AppFabricClient method getWorkflowNodeStates.

public Map<String, WorkflowNodeStateDetail> getWorkflowNodeStates(ProgramRunId workflowRunId) throws NotFoundException {
    MockResponder responder = new MockResponder();
    String uri = String.format("%s/apps/%s/workflows/%s/runs/%s/nodes/state", getNamespacePath(workflowRunId.getNamespace()), workflowRunId.getApplication(), workflowRunId.getProgram(), workflowRunId.getRun());
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
    workflowHttpHandler.getWorkflowNodeStates(request, responder, workflowRunId.getNamespace(), workflowRunId.getApplication(), workflowRunId.getProgram(), workflowRunId.getRun());
    Type nodeStatesType = new TypeToken<Map<String, WorkflowNodeStateDetail>>() {
    }.getType();
    Map<String, WorkflowNodeStateDetail> nodeStates = responder.decodeResponseContent(nodeStatesType, GSON);
    verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Getting workflow node states failed.");
    return nodeStates;
}
Also used : HttpRequest(org.jboss.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) ProgramType(co.cask.cdap.proto.ProgramType) Type(java.lang.reflect.Type) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) Map(java.util.Map) WorkflowNodeStateDetail(co.cask.cdap.proto.WorkflowNodeStateDetail)

Example 12 with WorkflowNodeStateDetail

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

the class WorkflowHttpHandler method getWorkflowNodeStates.

@GET
@Path("/apps/{app-id}/workflows/{workflow-id}/runs/{run-id}/nodes/state")
public void getWorkflowNodeStates(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String applicationId, @PathParam("workflow-id") String workflowId, @PathParam("run-id") String runId) throws NotFoundException {
    ApplicationId appId = Ids.namespace(namespaceId).app(applicationId);
    ApplicationSpecification appSpec = store.getApplication(appId);
    if (appSpec == null) {
        throw new ApplicationNotFoundException(appId);
    }
    ProgramId workflowProgramId = appId.workflow(workflowId);
    WorkflowSpecification workflowSpec = appSpec.getWorkflows().get(workflowProgramId.getProgram());
    if (workflowSpec == null) {
        throw new ProgramNotFoundException(workflowProgramId);
    }
    ProgramRunId workflowRunId = workflowProgramId.run(runId);
    if (store.getRun(workflowProgramId, runId) == null) {
        throw new NotFoundException(workflowRunId);
    }
    List<WorkflowNodeStateDetail> nodeStateDetails = store.getWorkflowNodeStates(workflowRunId);
    Map<String, WorkflowNodeStateDetail> nodeStates = new HashMap<>();
    for (WorkflowNodeStateDetail nodeStateDetail : nodeStateDetails) {
        nodeStates.put(nodeStateDetail.getNodeId(), nodeStateDetail);
    }
    responder.sendJson(HttpResponseStatus.OK, nodeStates, STRING_TO_NODESTATEDETAIL_MAP_TYPE);
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) HashMap(java.util.HashMap) ProgramNotFoundException(co.cask.cdap.common.ProgramNotFoundException) ApplicationNotFoundException(co.cask.cdap.common.ApplicationNotFoundException) InstanceNotFoundException(co.cask.cdap.api.dataset.InstanceNotFoundException) NotFoundException(co.cask.cdap.common.NotFoundException) ProgramId(co.cask.cdap.proto.id.ProgramId) WorkflowNodeStateDetail(co.cask.cdap.proto.WorkflowNodeStateDetail) ApplicationNotFoundException(co.cask.cdap.common.ApplicationNotFoundException) WorkflowSpecification(co.cask.cdap.api.workflow.WorkflowSpecification) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) ProgramNotFoundException(co.cask.cdap.common.ProgramNotFoundException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

WorkflowNodeStateDetail (co.cask.cdap.proto.WorkflowNodeStateDetail)12 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)6 ProgramId (co.cask.cdap.proto.id.ProgramId)5 Test (org.junit.Test)4 NotFoundException (co.cask.cdap.common.NotFoundException)3 BasicThrowable (co.cask.cdap.proto.BasicThrowable)3 RunRecord (co.cask.cdap.proto.RunRecord)3 ApplicationId (co.cask.cdap.proto.id.ApplicationId)3 File (java.io.File)3 HashMap (java.util.HashMap)3 MDSKey (co.cask.cdap.data2.dataset2.lib.table.MDSKey)2 IOException (java.io.IOException)2 Path (javax.ws.rs.Path)2 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)1 InstanceNotFoundException (co.cask.cdap.api.dataset.InstanceNotFoundException)1 FileSet (co.cask.cdap.api.dataset.lib.FileSet)1 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)1 NodeStatus (co.cask.cdap.api.workflow.NodeStatus)1 WorkflowNodeState (co.cask.cdap.api.workflow.WorkflowNodeState)1 WorkflowSpecification (co.cask.cdap.api.workflow.WorkflowSpecification)1