Skip to content

Commit

Permalink
added updateRecordingOprtions: help needed to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Sep 7, 2023
1 parent 63fbd5b commit 942c548
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
26 changes: 26 additions & 0 deletions src/main/java/io/cryostat/net/AgentClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,32 @@ Future<IRecordingDescriptor> startSnapshot() {
});
}

Future<Void> updateRecordingOptions(long id, IConstrainedMap<String> newSettings) {

JsonObject jsonSettings = new JsonObject();
for (String key : newSettings.keySet()) {
jsonSettings.put(key, newSettings.get(key));
}
Future<HttpResponse<Void>> f =
invoke(
HttpMethod.PATCH,
String.format("/recordings/%d", id),
jsonSettings.toBuffer(),
BodyCodec.none());

return f.map(
resp -> {
int statusCode = resp.statusCode();
if (HttpStatusCodeIdentifier.isSuccessCode(statusCode)) {
return null;
} else if (statusCode == 403) {
throw new UnsupportedOperationException();
} else {
throw new RuntimeException("Unknown failure");
}
});
}

Future<Buffer> openStream(long id) {
Future<HttpResponse<Buffer>> f =
invoke(HttpMethod.GET, "/recordings/" + id, BodyCodec.buffer());
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/io/cryostat/net/AgentJFRService.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public IRecordingDescriptor getSnapshotRecording() throws FlightRecorderExceptio
try {
return client.startSnapshot().toCompletionStage().toCompletableFuture().get();
} catch (ExecutionException | InterruptedException e) {
throw new FlightRecorderException("Failed to creat snapshot recording");
throw new FlightRecorderException("Failed to create snapshot recording", e);
}
}

Expand Down Expand Up @@ -249,9 +249,18 @@ public void updateEventOptions(IRecordingDescriptor arg0, IConstrainedMap<EventO
}

@Override
public void updateRecordingOptions(IRecordingDescriptor arg0, IConstrainedMap<String> arg1)
public void updateRecordingOptions(
IRecordingDescriptor recordingDescriptor, IConstrainedMap<String> newSettings)
throws FlightRecorderException {
throw new UnimplementedException();
try {
long recordingId = recordingDescriptor.getId();
client.updateRecordingOptions(recordingId, newSettings)
.toCompletionStage()
.toCompletableFuture()
.get();
} catch (ExecutionException | InterruptedException e) {
throw new FlightRecorderException("Failed to update recording options", e);
}
}

@Override
Expand Down

0 comments on commit 942c548

Please sign in to comment.