Skip to content

Commit

Permalink
refactor, move persistence interactions out of worker thread executio…
Browse files Browse the repository at this point in the history
…n and onto persistent context execution
  • Loading branch information
andrewazores committed Apr 2, 2024
1 parent 15cf436 commit 6bc061f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/main/java/io/cryostat/recordings/RecordingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,19 +470,21 @@ public ActiveRecording stopRecording(ActiveRecording recording) throws Exception
@Blocking
@Transactional
public ActiveRecording deleteRecording(ActiveRecording recording) {
return connectionManager.executeConnectedTask(
recording.target,
conn -> {
var desc = getDescriptorById(conn, recording.remoteId);
if (desc.isEmpty()) {
throw new NotFoundException();
}
conn.getService().close(desc.get());
recording.target.activeRecordings.remove(recording);
recording.target.persist();
recording.delete();
return recording;
});
var closed =
connectionManager.executeConnectedTask(
recording.target,
conn -> {
var desc = getDescriptorById(conn, recording.remoteId);
if (desc.isEmpty()) {
throw new NotFoundException();
}
conn.getService().close(desc.get());
return recording;
});
closed.target.activeRecordings.remove(recording);
closed.target.persist();
closed.delete();
return closed;
}

public LinkedRecordingDescriptor toExternalForm(ActiveRecording recording) {
Expand Down

0 comments on commit 6bc061f

Please sign in to comment.