Skip to content

Commit c9d38cb

Browse files
committed
optimizing internal call with version
1 parent 45dce6b commit c9d38cb

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

cdap-app-fabric/src/main/java/io/cdap/cdap/gateway/handlers/ProgramLifecycleHttpHandlerInternal.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import io.cdap.cdap.internal.app.services.ProgramLifecycleService;
2525
import io.cdap.cdap.internal.app.store.RunRecordDetail;
2626
import io.cdap.cdap.proto.ProgramType;
27+
import io.cdap.cdap.proto.id.ApplicationId;
28+
import io.cdap.cdap.proto.id.ProgramId;
2729
import io.cdap.cdap.proto.id.ProgramReference;
2830
import io.cdap.http.HttpHandler;
2931
import io.cdap.http.HttpResponder;
@@ -72,9 +74,10 @@ public void getProgramRunRecordMeta(HttpRequest request, HttpResponder responder
7274
@PathParam("program-name") String programName,
7375
@PathParam("run-id") String runid) throws Exception {
7476
ProgramType programType = ProgramType.valueOfCategoryName(type, BadRequestException::new);
75-
ProgramReference programRef = new ProgramReference(namespaceId, appName, programType,
77+
78+
ProgramId progId = new ApplicationId(namespaceId, appName, appVersion).program(programType,
7679
programName);
77-
RunRecordDetail runRecordMeta = programLifecycleService.getRunRecordMeta(programRef, runid);
80+
RunRecordDetail runRecordMeta = programLifecycleService.getRunRecordMeta(progId.run(runid));
7881
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(runRecordMeta));
7982
}
8083
}

cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/services/ProgramLifecycleService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,25 @@ public RunRecordDetail getRunRecordMeta(ProgramReference programRef, String runI
333333
return runRecord;
334334
}
335335

336+
public RunRecordDetail getRunRecordMeta(ProgramRunId id)
337+
throws Exception {
338+
accessEnforcer.enforce(new ProgramReference(id.getNamespace(), id.getApplication(),
339+
id.getType(), id.getProgram()),
340+
authenticationContext.getPrincipal(),
341+
StandardPermission.GET);
342+
RunRecordDetail runRecord = store.getRun(id);
343+
if (runRecord == null) {
344+
throw new NotFoundException(
345+
String.format("No run record found for program %s and runID: %s", id.getProgram(), id.getRun()));
346+
}
347+
ApplicationId appId = runRecord.getProgramRunId().getParent().getParent();
348+
ApplicationSpecification appSpec = store.getApplication(appId);
349+
if (appSpec == null) {
350+
throw new ApplicationNotFoundException(appId);
351+
}
352+
return runRecord;
353+
}
354+
336355
/**
337356
* Get the latest runs within the specified start and end times for the specified program.
338357
*

0 commit comments

Comments
 (0)