Skip to content

Commit

Permalink
handle Recordings PERMANENT_REDIRECT
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Aug 2, 2024
1 parent e85c119 commit 8740c84
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 399 deletions.
213 changes: 1 addition & 212 deletions src/main/java/io/cryostat/recordings/Recordings.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,22 +456,6 @@ public List<LinkedRecordingDescriptor> listForTarget(@RestPath long id) throws E
.toList();
}

/*
* @GET
*
* @Path("/api/v1/targets/{connectUrl}/recordings")
*
* @RolesAllowed("read")
* public Response listForTargetByUrl(@RestPath URI connectUrl) throws Exception
* {
* Target target = Target.getTargetByConnectUrl(connectUrl);
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(URI.create(String.format("/api/v3/targets/%d/recordings",
* target.id)))
* .build();
* }
*/

@PATCH
@Transactional
@Blocking
Expand Down Expand Up @@ -513,36 +497,6 @@ public String patch(@RestPath long targetId, @RestPath long remoteId, String bod
}
}

/*
* @PATCH
*
* @Transactional
*
* @Blocking
*
* @Path("/api/v1/targets/{connectUrl}/recordings/{recordingName}")
*
* @RolesAllowed("write")
* public Response patchV1(@RestPath URI connectUrl, @RestPath String
* recordingName, String body)
* throws Exception {
* Target target = Target.getTargetByConnectUrl(connectUrl);
* Optional<IRecordingDescriptor> recording =
* connectionManager.executeConnectedTask(
* target, conn -> recordingHelper.getDescriptorByName(conn, recordingName));
* if (recording.isEmpty()) {
* throw new NotFoundException();
* }
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(
* String.format(
* "/api/v3/targets/%d/recordings/%s",
* target.id, recording.get().getId())))
* .build();
* }
*/

@POST
@Transactional
@Path("/api/v1/targets/{connectUrl}/snapshot")
Expand Down Expand Up @@ -577,10 +531,7 @@ public Uni<Response> createSnapshotV2(@RestPath URI connectUrl) throws Exception
.transform(
recording ->
Response.status(Response.Status.CREATED)
.entity(
V2Response.json(
Response.Status.CREATED,
recordingHelper.toExternalForm(recording)))
.entity(recordingHelper.toExternalForm(recording))
.build())
.onFailure(SnapshotCreationException.class)
.recoverWithItem(
Expand Down Expand Up @@ -673,61 +624,6 @@ public Response createRecording(
.build();
}

/*
* @POST
*
* @Transactional
*
* @Blocking
*
* @Path("/api/v1/targets/{connectUrl}/recordings")
*
* @RolesAllowed("write")
* public Response createRecordingV1(@RestPath URI connectUrl) throws Exception
* {
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(
* String.format(
* "/api/v3/targets/%d/recordings",
* Target.getTargetByConnectUrl(connectUrl).id)))
* .build();
* }
*/

/*
* @DELETE
*
* @Transactional
*
* @Blocking
*
* @Path("/api/v1/targets/{connectUrl}/recordings/{recordingName}")
*
* @RolesAllowed("write")
* public Response deleteRecordingV1(@RestPath URI connectUrl, @RestPath String
* recordingName)
* throws Exception {
* if (StringUtils.isBlank(recordingName)) {
* throw new
* BadRequestException("\"recordingName\" form parameter must be provided");
* }
* Target target = Target.getTargetByConnectUrl(connectUrl);
* long remoteId =
* recordingHelper.listActiveRecordings(target).stream()
* .filter(r -> Objects.equals(r.name, recordingName))
* .findFirst()
* .map(r -> r.remoteId)
* .orElseThrow(() -> new NotFoundException());
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(
* String.format(
* "/api/v3/targets/%d/recordings/%d", target.id, remoteId)))
* .build();
* }
*/

@DELETE
@Transactional
@Blocking
Expand Down Expand Up @@ -803,36 +699,6 @@ public void deleteArchivedRecording(@RestPath String jvmId, @RestPath String fil
}
}

/*
* @POST
*
* @Blocking
*
* @Transactional
*
* @Path("/api/v1/targets/{connectUrl}/recordings/{recordingName}/upload")
*
* @RolesAllowed("write")
* public Response uploadActiveToGrafanaV1(
*
* @RestPath URI connectUrl, @RestPath String recordingName) {
* Target target = Target.getTargetByConnectUrl(connectUrl);
* long remoteId =
* recordingHelper.listActiveRecordings(target).stream()
* .filter(r -> Objects.equals(r.name, recordingName))
* .findFirst()
* .map(r -> r.remoteId)
* .orElseThrow(() -> new NotFoundException());
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(
* String.format(
* "/api/v3/targets/%d/recordings/%d/upload",
* target.id, remoteId)))
* .build();
* }
*/

@POST
@Blocking
@Path("/api/v3/targets/{targetId}/recordings/{remoteId}/upload")
Expand All @@ -842,48 +708,6 @@ public Uni<String> uploadActiveToGrafana(@RestPath long targetId, @RestPath long
return recordingHelper.uploadToJFRDatasource(targetId, remoteId);
}

/*
* @POST
*
* @Path("/api/beta/recordings/{connectUrl}/{filename}/upload")
*
* @RolesAllowed("write")
* public Response uploadArchivedToGrafanaBeta(
*
* @RestPath String connectUrl, @RestPath String filename) throws Exception {
* String jvmId;
* if ("uploads".equals(connectUrl)) {
* jvmId = "uploads";
* } else {
* jvmId = Target.getTargetByConnectUrl(URI.create(connectUrl)).jvmId;
* }
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(
* String.format(
* "/api/v3/grafana/%s",
* recordingHelper.encodedKey(jvmId, filename))))
* .build();
* }
*
* @POST
*
* @Path("/api/beta/fs/recordings/{jvmId}/{filename}/upload")
*
* @RolesAllowed("write")
* public Response uploadArchivedToGrafanaFromPath(
*
* @RestPath String jvmId, @RestPath String filename) throws Exception {
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(
* String.format(
* "/api/v3/grafana/%s",
* recordingHelper.encodedKey(jvmId, filename))))
* .build();
* }
*/

@POST
@Blocking
@Path("/api/v3/grafana/{encodedKey}")
Expand All @@ -903,24 +727,6 @@ public Uni<String> uploadArchivedToGrafana(@RestPath String encodedKey) throws E
return recordingHelper.uploadToJFRDatasource(key);
}

/*
* @GET
*
* @Blocking
*
* @Path("/api/v1/targets/{connectUrl}/recordingOptions")
*
* @RolesAllowed("read")
* public Response getRecordingOptionsV1(@RestPath URI connectUrl) throws
* Exception {
* Target target = Target.getTargetByConnectUrl(connectUrl);
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(String.format("/api/v3/targets/%d/recordingOptions", target.id)))
* .build();
* }
*/

@GET
@Blocking
@Path("/api/v3/targets/{id}/recordingOptions")
Expand All @@ -935,23 +741,6 @@ public Map<String, Object> getRecordingOptions(@RestPath long id) throws Excepti
});
}

/*
* @PATCH
*
* @Blocking
*
* @Path("/api/v1/targets/{connectUrl}/recordingOptions")
*
* @RolesAllowed("write")
* public Response patchRecordingOptionsV1(@RestPath URI connectUrl) {
* Target target = Target.getTargetByConnectUrl(connectUrl);
* return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
* .location(
* URI.create(String.format("/api/v3/targets/%d/recordingOptions", target.id)))
* .build();
* }
*/

@PATCH
@Blocking
@Path("/api/v3/targets/{id}/recordingOptions")
Expand Down
55 changes: 0 additions & 55 deletions src/test/java/itest/NonExistentTargetIT.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/java/itest/RecordingWorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public void testWorkflow() throws Exception {
}
});
listResp = listRespFuture2.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
System.out.println("+++List response: " + listResp.encode());

MatcherAssert.assertThat(
"list should have size 1 after recording creation",
Expand All @@ -105,7 +104,6 @@ public void testWorkflow() throws Exception {
JsonObject recordingInfo = listResp.getJsonObject(0);
long remoteId = recordingInfo.getLong("remoteId");
TEST_REMOTE_ID = remoteId;
System.out.println("+++TEST_REMORE_ID: " + TEST_REMOTE_ID);
MatcherAssert.assertThat(
recordingInfo.getString("name"), Matchers.equalTo(TEST_RECORDING_NAME));
MatcherAssert.assertThat(recordingInfo.getString("state"), Matchers.equalTo("RUNNING"));
Expand Down
Loading

0 comments on commit 8740c84

Please sign in to comment.