Skip to content

Commit

Permalink
include jvmId in issueNotifications for recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Sep 29, 2023
1 parent 172113a commit a675f59
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/main/java/io/cryostat/recordings/RecordingTargetHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import io.cryostat.net.reports.ReportService;
import io.cryostat.net.web.WebServer;
import io.cryostat.net.web.http.HttpMimeType;
import io.cryostat.recordings.JvmIdHelper;
import io.cryostat.recordings.JvmIdHelper.JvmIdGetException;
import io.cryostat.recordings.RecordingMetadataManager.Metadata;

import dagger.Lazy;
Expand Down Expand Up @@ -72,6 +74,7 @@ public class RecordingTargetHelper {
private final Vertx vertx;
private final TargetConnectionManager targetConnectionManager;
private final Lazy<WebServer> webServer;
private final Lazy<JvmIdHelper> jvmIdHelper;
private final EventOptionsBuilder.Factory eventOptionsBuilderFactory;
private final NotificationFactory notificationFactory;
private final RecordingOptionsBuilderFactory recordingOptionsBuilderFactory;
Expand All @@ -85,6 +88,7 @@ public class RecordingTargetHelper {
Vertx vertx,
TargetConnectionManager targetConnectionManager,
Lazy<WebServer> webServer,
Lazy<JvmIdHelper> jvmIdHelper,
EventOptionsBuilder.Factory eventOptionsBuilderFactory,
NotificationFactory notificationFactory,
RecordingOptionsBuilderFactory recordingOptionsBuilderFactory,
Expand All @@ -95,6 +99,7 @@ public class RecordingTargetHelper {
this.vertx = vertx;
this.targetConnectionManager = targetConnectionManager;
this.webServer = webServer;
this.jvmIdHelper = jvmIdHelper;
this.eventOptionsBuilderFactory = eventOptionsBuilderFactory;
this.notificationFactory = notificationFactory;
this.recordingOptionsBuilderFactory = recordingOptionsBuilderFactory;
Expand Down Expand Up @@ -467,13 +472,18 @@ private void issueNotification(
String targetId,
HyperlinkedSerializableRecordingDescriptor linkedDesc,
String notificationCategory) {
notificationFactory
.createBuilder()
.metaCategory(notificationCategory)
.metaType(HttpMimeType.JSON)
.message(Map.of("recording", linkedDesc, "target", targetId))
.build()
.send();
try {
notificationFactory
.createBuilder()
.metaCategory(notificationCategory)
.metaType(HttpMimeType.JSON)
.message(Map.of("recording", linkedDesc, "target", targetId, "jvmId", jvmIdHelper.get().getJvmId(targetId)))
.build()
.send();
} catch (JvmIdGetException e) {
logger.info("Retain null jvmId for target [{}]", targetId);
logger.info(e);
}
}

private void cancelScheduledTasksIfExists(String targetId, String stoppedRecordingName)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/recordings/RecordingsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static RecordingTargetHelper provideRecordingTargetHelper(
Vertx vertx,
TargetConnectionManager targetConnectionManager,
Lazy<WebServer> webServer,
Lazy<JvmIdHelper> jvmIdHelper,
EventOptionsBuilder.Factory eventOptionsBuilderFactory,
NotificationFactory notificationFactory,
RecordingOptionsBuilderFactory recordingOptionsBuilderFactory,
Expand All @@ -90,6 +91,7 @@ static RecordingTargetHelper provideRecordingTargetHelper(
vertx,
targetConnectionManager,
webServer,
jvmIdHelper,
eventOptionsBuilderFactory,
notificationFactory,
recordingOptionsBuilderFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.cryostat.net.reports.ReportService;
import io.cryostat.net.web.WebServer;
import io.cryostat.net.web.http.HttpMimeType;
import io.cryostat.recordings.JvmIdHelper;
import io.cryostat.recordings.RecordingMetadataManager.Metadata;
import io.cryostat.recordings.RecordingTargetHelper.ReplacementPolicy;
import io.cryostat.recordings.RecordingTargetHelper.SnapshotCreationException;
Expand Down Expand Up @@ -80,6 +81,7 @@ public class RecordingTargetHelperTest {
@Mock AuthManager auth;
@Mock TargetConnectionManager targetConnectionManager;
@Mock WebServer webServer;
@Mock JvmIdHelper jvmIdHelper;
@Mock EventOptionsBuilder.Factory eventOptionsBuilderFactory;
@Mock NotificationFactory notificationFactory;
@Mock RecordingOptionsBuilderFactory recordingOptionsBuilderFactory;
Expand Down Expand Up @@ -113,6 +115,7 @@ void setup() {
vertx,
targetConnectionManager,
() -> webServer,
() -> jvmIdHelper,
eventOptionsBuilderFactory,
notificationFactory,
recordingOptionsBuilderFactory,
Expand Down

0 comments on commit a675f59

Please sign in to comment.