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;
}
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);
}
Aggregations