Search in sources :

Example 16 with WorkflowId

use of io.cdap.cdap.proto.id.WorkflowId in project cdap by caskdata.

the class LineageAdmin method extractWorkflowRunId.

private ProgramRunId extractWorkflowRunId(ProgramRunId programRunId, RunRecordDetail runRecord) {
    Map<String, String> systemArgs = runRecord.getSystemArgs();
    String workflowRunId = systemArgs.get(ProgramOptionConstants.WORKFLOW_RUN_ID);
    String workflowName = systemArgs.get(ProgramOptionConstants.WORKFLOW_NAME);
    WorkflowId workflowId = programRunId.getParent().getParent().workflow(workflowName);
    return workflowId.run(workflowRunId);
}
Also used : WorkflowId(io.cdap.cdap.proto.id.WorkflowId)

Example 17 with WorkflowId

use of io.cdap.cdap.proto.id.WorkflowId in project cdap by caskdata.

the class WorkflowStatsSLAHttpHandlerTest method testDetails.

@Test
public void testDetails() throws Exception {
    deploy(WorkflowApp.class, 200);
    String workflowName = "FunWorkflow";
    String mapreduceName = "ClassicWordCount";
    String sparkName = "SparkWorkflowTest";
    WorkflowId workflowProgram = WORKFLOW_APP.workflow(workflowName);
    ProgramId mapreduceProgram = WORKFLOW_APP.mr(mapreduceName);
    ProgramId sparkProgram = WORKFLOW_APP.spark(sparkName);
    ArtifactId artifactId = WORKFLOW_APP.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId();
    List<RunId> runIdList = setupRuns(workflowProgram, mapreduceProgram, sparkProgram, store, 13, artifactId);
    String request = String.format("%s/namespaces/%s/apps/%s/workflows/%s/runs/%s/statistics?limit=%s&interval=%s", Constants.Gateway.API_VERSION_3, Id.Namespace.DEFAULT.getId(), WorkflowApp.class.getSimpleName(), workflowProgram.getProgram(), runIdList.get(6).getId(), "3", "10m");
    HttpResponse response = doGet(request);
    WorkflowStatsComparison workflowStatistics = readResponse(response, new TypeToken<WorkflowStatsComparison>() {
    }.getType());
    Assert.assertEquals(7, workflowStatistics.getProgramNodesList().iterator().next().getWorkflowProgramDetailsList().size());
    request = String.format("%s/namespaces/%s/apps/%s/workflows/%s/runs/%s/statistics?limit=0", Constants.Gateway.API_VERSION_3, Id.Namespace.DEFAULT.getId(), WorkflowApp.class.getSimpleName(), workflowProgram.getProgram(), runIdList.get(6).getId());
    response = doGet(request);
    Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), response.getResponseCode());
    request = String.format("%s/namespaces/%s/apps/%s/workflows/%s/runs/%s/statistics?limit=10&interval=10", Constants.Gateway.API_VERSION_3, Id.Namespace.DEFAULT.getId(), WorkflowApp.class.getSimpleName(), workflowProgram.getProgram(), runIdList.get(6).getId());
    response = doGet(request);
    Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), response.getResponseCode());
    request = String.format("%s/namespaces/%s/apps/%s/workflows/%s/runs/%s/statistics?limit=10&interval=10P", Constants.Gateway.API_VERSION_3, Id.Namespace.DEFAULT.getId(), WorkflowApp.class.getSimpleName(), workflowProgram.getProgram(), runIdList.get(6).getId());
    response = doGet(request);
    Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), response.getResponseCode());
    request = String.format("%s/namespaces/%s/apps/%s/workflows/%s/runs/%s/statistics?limit=20&interval=0d", Constants.Gateway.API_VERSION_3, Id.Namespace.DEFAULT.getId(), WorkflowApp.class.getSimpleName(), workflowProgram.getProgram(), runIdList.get(6).getId());
    response = doGet(request);
    Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), response.getResponseCode());
}
Also used : WorkflowApp(io.cdap.cdap.WorkflowApp) ArtifactId(io.cdap.cdap.api.artifact.ArtifactId) WorkflowStatsComparison(io.cdap.cdap.proto.WorkflowStatsComparison) TypeToken(com.google.gson.reflect.TypeToken) HttpResponse(io.cdap.common.http.HttpResponse) WorkflowId(io.cdap.cdap.proto.id.WorkflowId) ProgramId(io.cdap.cdap.proto.id.ProgramId) RunId(org.apache.twill.api.RunId) Test(org.junit.Test)

Aggregations

WorkflowId (io.cdap.cdap.proto.id.WorkflowId)17 Test (org.junit.Test)8 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)7 ProgramId (io.cdap.cdap.proto.id.ProgramId)7 RunRecord (io.cdap.cdap.proto.RunRecord)5 File (java.io.File)5 NotFoundException (io.cdap.cdap.common.NotFoundException)4 Id (io.cdap.cdap.common.id.Id)4 WorkflowTokenDetail (io.cdap.cdap.proto.WorkflowTokenDetail)4 BadRequestException (io.cdap.cdap.common.BadRequestException)3 WorkflowStatsComparison (io.cdap.cdap.proto.WorkflowStatsComparison)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 TypeToken (com.google.gson.reflect.TypeToken)2 WorkflowApp (io.cdap.cdap.WorkflowApp)2 ArtifactId (io.cdap.cdap.api.artifact.ArtifactId)2 ScheduleDetail (io.cdap.cdap.proto.ScheduleDetail)2 WorkflowNodeStateDetail (io.cdap.cdap.proto.WorkflowNodeStateDetail)2 WorkflowTokenNodeDetail (io.cdap.cdap.proto.WorkflowTokenNodeDetail)2 List (java.util.List)2