Skip to content

Commit

Permalink
fix(reports): report generation does not cause recursive update (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Apr 24, 2024
1 parent 5baa88c commit bf13fb3
Show file tree
Hide file tree
Showing 11 changed files with 424 additions and 302 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/cryostat/ConfigProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class ConfigProperties {
public static final String CONNECTIONS_FAILED_TIMEOUT = "cryostat.connections.failed-timeout";

public static final String REPORTS_SIDECAR_URL = "cryostat.services.reports.url";
public static final String MEMORY_CACHE_ENABLED =
public static final String REPORTS_MEMORY_CACHE_ENABLED =
"cryostat.services.reports.memory-cache.enabled";
public static final String STORAGE_CACHE_ENABLED =
public static final String REPORTS_STORAGE_CACHE_ENABLED =
"cryostat.services.reports.storage-cache.enabled";
public static final String ARCHIVED_REPORTS_STORAGE_CACHE_NAME =
"cryostat.services.reports.storage-cache.name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MemoryCachingReportsListener {
@ConfigProperty(name = "quarkus.cache.enabled")
boolean quarkusCache;

@ConfigProperty(name = ConfigProperties.MEMORY_CACHE_ENABLED)
@ConfigProperty(name = ConfigProperties.REPORTS_MEMORY_CACHE_ENABLED)
boolean memoryCache;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MemoryCachingReportsService implements ReportsService {
@ConfigProperty(name = "quarkus.cache.enabled")
boolean quarkusCache;

@ConfigProperty(name = ConfigProperties.MEMORY_CACHE_ENABLED)
@ConfigProperty(name = ConfigProperties.REPORTS_MEMORY_CACHE_ENABLED)
boolean memoryCache;

@Inject
Expand Down Expand Up @@ -98,4 +98,14 @@ public Uni<Map<String, AnalysisResult>> reportFor(
return delegate.reportFor(jvmId, filename);
});
}

@Override
public Uni<Map<String, AnalysisResult>> reportFor(ActiveRecording recording) {
return reportFor(recording, r -> true);
}

@Override
public Uni<Map<String, AnalysisResult>> reportFor(String jvmId, String filename) {
return reportFor(jvmId, filename, r -> true);
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/cryostat/reports/Reports.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@Path("")
public class Reports {

@ConfigProperty(name = ConfigProperties.STORAGE_CACHE_ENABLED)
@ConfigProperty(name = ConfigProperties.REPORTS_STORAGE_CACHE_ENABLED)
boolean storageCacheEnabled;

@ConfigProperty(name = ConfigProperties.ARCHIVED_REPORTS_STORAGE_CACHE_NAME)
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/io/cryostat/reports/ReportsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ public interface ReportsService {
Uni<Map<String, AnalysisResult>> reportFor(
ActiveRecording recording, Predicate<IRule> predicate);

default Uni<Map<String, AnalysisResult>> reportFor(ActiveRecording recording) {
return reportFor(recording, r -> true);
}
Uni<Map<String, AnalysisResult>> reportFor(ActiveRecording recording);

Uni<Map<String, AnalysisResult>> reportFor(
String jvmId, String filename, Predicate<IRule> predicate);

default Uni<Map<String, AnalysisResult>> reportFor(String jvmId, String filename) {
return reportFor(jvmId, filename, r -> true);
}
Uni<Map<String, AnalysisResult>> reportFor(String jvmId, String filename);

static String key(ActiveRecording recording) {
return String.format("%s/%d", recording.target.jvmId, recording.id);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/cryostat/reports/ReportsServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ public Uni<Map<String, AnalysisResult>> reportFor(
return Uni.createFrom().future(future);
}

@Override
public Uni<Map<String, AnalysisResult>> reportFor(ActiveRecording recording) {
return reportFor(recording, r -> true);
}

@Override
public Uni<Map<String, AnalysisResult>> reportFor(String jvmId, String filename) {
return reportFor(jvmId, filename, r -> true);
}

private Future<Map<String, AnalysisResult>> process(
InputStream stream, Predicate<IRule> predicate) {
return reportGenerator.generateEvalMapInterruptibly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@ApplicationScoped
class StorageCachingReportsListener {

@ConfigProperty(name = ConfigProperties.STORAGE_CACHE_ENABLED)
@ConfigProperty(name = ConfigProperties.REPORTS_STORAGE_CACHE_ENABLED)
boolean enabled;

@ConfigProperty(name = ConfigProperties.ARCHIVED_REPORTS_STORAGE_CACHE_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
@Dependent
class StorageCachingReportsService implements ReportsService {

@ConfigProperty(name = ConfigProperties.STORAGE_CACHE_ENABLED)
@ConfigProperty(name = ConfigProperties.REPORTS_STORAGE_CACHE_ENABLED)
boolean enabled;

@ConfigProperty(name = ConfigProperties.ARCHIVED_REPORTS_STORAGE_CACHE_NAME)
Expand Down Expand Up @@ -157,4 +157,14 @@ private Uni<Map<String, AnalysisResult>> getStorage(String key) {
}
});
}

@Override
public Uni<Map<String, AnalysisResult>> reportFor(ActiveRecording recording) {
return reportFor(recording, r -> true);
}

@Override
public Uni<Map<String, AnalysisResult>> reportFor(String jvmId, String filename) {
return reportFor(jvmId, filename, r -> true);
}
}
Loading

0 comments on commit bf13fb3

Please sign in to comment.