Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/jreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
java-version: '11'
java-version: '25'
distribution: 'microsoft'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
java-version: '11'
java-version: '25'
distribution: 'microsoft'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_to_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
java-version: '11'
java-version: '25'
distribution: 'microsoft'

- name: Version
Expand Down
4 changes: 4 additions & 0 deletions IT/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<groupId>com.microsoft.gctoolkit</groupId>
<artifactId>gctoolkit-vertx</artifactId>
</dependency>
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

public class CollectionCycleCountsSummary extends CollectionCycleCountsAggregation {

private HashMap<GarbageCollectionTypes,Integer> collectionCycleCounts = new HashMap<>();
private Map<GarbageCollectionTypes,Integer> collectionCycleCounts = new HashMap<>();
@Override
public void count(GarbageCollectionTypes gcType) {
collectionCycleCounts.compute(gcType, (key, value) -> value == null ? 1 : ++value);
collectionCycleCounts.compute(gcType, (_, value) -> value == null ? 1 : ++value);
}

private String format = "%s : %s\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public class HeapOccupancyAfterCollectionSummary extends HeapOccupancyAfterColle

private final Map<GarbageCollectionTypes, XYDataSet> aggregations = new ConcurrentHashMap<>();

@Override
public void addDataPoint(GarbageCollectionTypes gcType, DateTimeStamp timeStamp, long heapOccupancy) {
aggregations.computeIfAbsent(gcType, key -> new XYDataSet()).add(timeStamp.getTimeStamp(),heapOccupancy);
aggregations.computeIfAbsent(gcType, _ -> new XYDataSet()).add(timeStamp.getTimeStamp(),heapOccupancy);
}

public Map<GarbageCollectionTypes, XYDataSet> get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
import com.microsoft.gctoolkit.aggregator.Aggregation;
import com.microsoft.gctoolkit.aggregator.Collates;

/**
* API for an Aggregation that records pause time duration. A
* PauseTimeAggregation gets its data from a PauseTimeAggregator.
*/
/// API for an Aggregation that records pause time duration. A
/// PauseTimeAggregation gets its data from a PauseTimeAggregator.
@Collates(PauseTimeAggregator.class)
public abstract class PauseTimeAggregation extends Aggregation {
/**
* Record the duration of a pause event. This method is called from PauseTimeAggregator.
* @param duration The duration (in decimal seconds) of a GC pause.
*/
/// Record the duration of a pause event. This method is called from PauseTimeAggregator.
/// @param duration The duration (in decimal seconds) of a GC pause.
public abstract void recordPauseDuration(double duration);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.microsoft.gctoolkit.event.g1gc.G1RealPause;
import com.microsoft.gctoolkit.event.generational.GenerationalGCPauseEvent;

/**
* An Aggregator that extracts pause time.
*/
/// An Aggregator that extracts pause time.
@Aggregates({EventSource.G1GC, EventSource.GENERATIONAL})
public class PauseTimeAggregator extends Aggregator<PauseTimeAggregation> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.microsoft.gctoolkit.integration.aggregation;

/**
* An implementation of PauseTimeAggregation which simply accumulates pause times, and
* provides methods for getting the total pause time and the percentage of time the
* application was paused. This is an instance of RuntimeAggregation, which gives us
* the run time represented by the GC log.
*/
/// An implementation of PauseTimeAggregation which simply accumulates pause times, and
/// provides methods for getting the total pause time and the percentage of time the
/// application was paused. This is an instance of RuntimeAggregation, which gives us
/// the run time represented by the GC log.
public class PauseTimeSummary extends PauseTimeAggregation {

private double totalPauseTime;
Expand All @@ -25,18 +23,14 @@ public void recordPauseDuration(double duration) {
totalPauseTime += duration;
}

/**
* Get the total amount of time the application was paused for garbage collection.
* @return The total pause time.
*/
/// Get the total amount of time the application was paused for garbage collection.
/// @return The total pause time.
public double getTotalPauseTime() {
return totalPauseTime;
}

/**
* Get the amount of time the application was paused as a percentage of total runtime.
* @return The percentage of time the application was paused.
*/
/// Get the amount of time the application was paused as a percentage of total runtime.
/// @return The percentage of time the application was paused.
public double getPercentPaused() {
return (totalPauseTime / super.estimatedRuntime()) * 100.0D;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,21 @@ public boolean isEmpty() {
return dataSeries.isEmpty();
}

/**
* Returns an immutable List of the items in this DataSet.
*/
/// Returns an immutable List of the items in this DataSet.
public List<com.microsoft.gctoolkit.integration.collections.XYDataSet.Point> getItems() {
return List.copyOf(dataSeries);
}

public com.microsoft.gctoolkit.integration.collections.XYDataSet scaleSeries(double scaleFactor) {
com.microsoft.gctoolkit.integration.collections.XYDataSet scaled = new com.microsoft.gctoolkit.integration.collections.XYDataSet();
var scaled = new com.microsoft.gctoolkit.integration.collections.XYDataSet();
for (com.microsoft.gctoolkit.integration.collections.XYDataSet.Point item : dataSeries) {
scaled.add(item.getX(), item.getY().doubleValue() * scaleFactor);
}
return scaled;
}

/**
* Returns the largest Y value in the XYDataSet as an OptionalDouble,
* with an empty optional if the dataset is empty.
*/
/// Returns the largest Y value in the XYDataSet as an OptionalDouble,
/// with an empty optional if the dataset is empty.
public OptionalDouble maxOfY() {
return dataSeries.stream()
.map(com.microsoft.gctoolkit.integration.collections.XYDataSet.Point::getY)
Expand All @@ -59,9 +55,9 @@ public OptionalDouble maxOfY() {
}

public com.microsoft.gctoolkit.integration.collections.XYDataSet scaleAndTranslateXAxis(double scale, double offset) {
com.microsoft.gctoolkit.integration.collections.XYDataSet translatedSeries = new com.microsoft.gctoolkit.integration.collections.XYDataSet();
var translatedSeries = new com.microsoft.gctoolkit.integration.collections.XYDataSet();
for (com.microsoft.gctoolkit.integration.collections.XYDataSet.Point dataPoint : dataSeries) {
double scaledXCoordinate = (scale * dataPoint.getX().doubleValue()) + offset;
var scaledXCoordinate = (scale * dataPoint.getX().doubleValue()) + offset;
translatedSeries.add(scaledXCoordinate, dataPoint.getY());
}
return translatedSeries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

@Aggregates({EventSource.G1GC,EventSource.GENERATIONAL,EventSource.SHENANDOAH,EventSource.ZGC})
public class OneRuntimeAggregator extends Aggregator<OneRuntimeReport> {
/**
* Subclass only.
*
* @param aggregation The Aggregation that {@literal @}Collates this Aggregator
*/
/// Subclass only.
///
/// @param aggregation The Aggregation that `@`Collates this Aggregator
public OneRuntimeAggregator(OneRuntimeReport aggregation) {
super(aggregation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

@Aggregates({EventSource.G1GC,EventSource.GENERATIONAL,EventSource.SHENANDOAH,EventSource.ZGC})
public class TwoRuntimeAggregator extends Aggregator<TwoRuntimeReport> {
/**
* Subclass only.
*
* @param aggregation The Aggregation that {@literal @}Collates this Aggregator
*/
/// Subclass only.
///
/// @param aggregation The Aggregation that `@`Collates this Aggregator
public TwoRuntimeAggregator(TwoRuntimeReport aggregation) {
super(aggregation);
}
Expand Down
1 change: 1 addition & 0 deletions IT/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

requires com.microsoft.gctoolkit.api;
requires java.logging;
requires transitive org.jspecify;

exports com.microsoft.gctoolkit.integration.aggregation to
com.microsoft.gctoolkit.api;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void analyze(String gcLogFile) {
* The log files can be either in text, zip, or gzip format.
*/
GCLogFile logFile = new SingleGCLogFile(Path.of(gcLogFile));
GCToolKit gcToolKit = new GCToolKit();
var gcToolKit = new GCToolKit();

/**
* This call will load all implementations of Aggregator that have been declared in module-info.java.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void analyze(String gcLogFile) {
* The log files can be either in text, zip, or gzip format.
*/
GCLogFile logFile = new SingleGCLogFile(Path.of(gcLogFile));
GCToolKit gcToolKit = new GCToolKit();
var gcToolKit = new GCToolKit();

/**
* This call will load all implementations of Aggregator that have been declared in module-info.java.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* The log files can be either in text, zip, or gzip format.
*/
GCLogFile logFile = new SingleGCLogFile(Path.of(gcLogFile));
GCToolKit gcToolKit = new GCToolKit();
var gcToolKit = new GCToolKit();

/**
* This call will load all implementations of Aggregator that have been declared in module-info.java.
Expand All @@ -57,10 +57,10 @@
}

// Retrieves the Aggregation for HeapOccupancyAfterCollectionSummary. This is a time-series aggregation.
String message = "The XYDataSet for %s contains %s items.\n";
var message = "The XYDataSet for %s contains %s items.\n";
machine.getAggregation(HeapOccupancyAfterCollectionSummary.class)
.map(HeapOccupancyAfterCollectionSummary::get)
.ifPresent(summary -> {
.ifPresent(summary ->
summary.forEach((gcType, dataSet) -> {
switch (gcType) {
case DefNew:
Expand All @@ -76,13 +76,12 @@
Assertions.assertEquals(26,remarkCount,"Remark count");
break;
default:
System.out.println(gcType + " not managed");
IO.println(gcType + " not managed");
break;
}
});
});
}));

Optional<CollectionCycleCountsSummary> summary = machine.getAggregation(CollectionCycleCountsSummary.class);
var summary = machine.getAggregation(CollectionCycleCountsSummary.class);

Check warning on line 84 in IT/src/test/java/com/microsoft/gctoolkit/integration/EndToEndIntegrationTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused "summary" local variable.

See more on https://sonarcloud.io/project/issues?id=microsoft_gctoolkit&issues=AZ8fR7p6TK5zFVh6CKwM&open=AZ8fR7p6TK5zFVh6CKwM&pullRequest=560
// Retrieves the Aggregation for PauseTimeSummary. This is a com.microsoft.gctoolkit.sample.aggregation.RuntimeAggregation.
machine.getAggregation(PauseTimeSummary.class).ifPresent(pauseTimeSummary -> {
Assertions.assertEquals( 208.922, pauseTimeSummary.getTotalPauseTime(), 0.001d, "Total Pause Time");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MissingAnnotationTest {

@SuppressWarnings("unchecked")
private void workFlow(Aggregation aggregation, Class clazz) {
GCToolKit gcToolKit = new GCToolKit();
var gcToolKit = new GCToolKit();
// Load our test aggregation instead of calling GCToolKit::loadAggregationsFromServiceLoader
gcToolKit.loadAggregation(aggregation);
JavaVirtualMachine machine = null;
Expand All @@ -46,7 +46,7 @@ void testSuppliedAggregation() {
workFlow(new MissingEventSource(), MissingAnnotationTest.MissingEventSource.class);
}

/************* Aggregator/Aggregation with missing Collates annotation */
/// *********** Aggregator/Aggregation with missing Collates annotation
public static class MissingAnnotationAggregation extends Aggregation {

@Override
Expand All @@ -68,7 +68,7 @@ protected TestAggregator(MissingAnnotationAggregation aggregation) {
}
}

/************* Aggregator/Aggregation with missing Aggregates annotation */
/// *********** Aggregator/Aggregation with missing Aggregates annotation
@Collates(MissingAnnotationAggregator.class)
public static class MissingEventSource extends Aggregation {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* The log files can be either in text, zip, or gzip format.
*/
GCLogFile logFile = new SingleGCLogFile(Path.of(gcLogFile));
GCToolKit gcToolKit = new GCToolKit();
var gcToolKit = new GCToolKit();

gcToolKit.loadDataSourceChannel(new VertxDataSourceChannel());
gcToolKit.loadJVMEventChannel(new VertxJVMEventChannel());
Expand All @@ -63,10 +63,10 @@
}

// Retrieves the Aggregation for HeapOccupancyAfterCollectionSummary. This is a time-series aggregation.
String message = "The XYDataSet for %s contains %s items.\n";
var message = "The XYDataSet for %s contains %s items.\n";
machine.getAggregation(HeapOccupancyAfterCollectionSummary.class)
.map(HeapOccupancyAfterCollectionSummary::get)
.ifPresent(summary -> {
.ifPresent(summary ->
summary.forEach((gcType, dataSet) -> {
System.out.printf(message, gcType, dataSet.size());
switch (gcType) {
Expand All @@ -83,13 +83,12 @@
Assertions.assertEquals(26,remarkCount,"Remark count");
break;
default:
System.out.println(gcType + " not managed");
IO.println(gcType + " not managed");
break;
}
});
});
}));

Optional<CollectionCycleCountsSummary> summary = machine.getAggregation(CollectionCycleCountsSummary.class);
var summary = machine.getAggregation(CollectionCycleCountsSummary.class);

Check warning on line 91 in IT/src/test/java/com/microsoft/gctoolkit/integration/NoModuleIntegrationTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused "summary" local variable.

See more on https://sonarcloud.io/project/issues?id=microsoft_gctoolkit&issues=AZ8fR7pcTK5zFVh6CKwK&open=AZ8fR7pcTK5zFVh6CKwK&pullRequest=560
// Retrieves the Aggregation for PauseTimeSummary. This is a com.microsoft.gctoolkit.sample.aggregation.RuntimeAggregation.
machine.getAggregation(PauseTimeSummary.class).ifPresent(pauseTimeSummary -> {
Assertions.assertEquals( 208.922, pauseTimeSummary.getTotalPauseTime(), 0.001d, "Total Pause Time");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class TestSharedAggregators {

@Test
public void compareRuntimeDurations() {
TestLogFile logFile = new TestLogFile(testLog);
var logFile = new TestLogFile(testLog);
Path gcLogFile = logFile.getFile().toPath();
GCLogFile log = new SingleGCLogFile(gcLogFile);
GCToolKit toolKit = new GCToolKit();
var toolKit = new GCToolKit();
toolKit.loadAggregationsFromServiceLoader();
JavaVirtualMachine jvm = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public void shouldScaleOnlyY_AxisDataSet() {
var xyDataSet = new XYDataSet();
xyDataSet.add(new Point(50, 100));
XYDataSet scaledPoint = xyDataSet.scaleSeries(2);
Assertions.assertEquals(50, scaledPoint.getItems().get(0).getX());
Assertions.assertEquals(200.0, scaledPoint.getItems().get(0).getY());
Assertions.assertEquals(50, scaledPoint.getItems().getFirst().getX());
Assertions.assertEquals(200.0, scaledPoint.getItems().getFirst().getY());
}

@Test
Expand All @@ -36,8 +36,8 @@ public void shouldReturnScaledAndTranslatedX_AxisDataSet() {
var xyDataSet = new XYDataSet();
xyDataSet.add(new Point(50, 100));
var translated = xyDataSet.scaleAndTranslateXAxis(2, 20);
Assertions.assertEquals(120.0, translated.getItems().get(0).getX());
Assertions.assertEquals(100, translated.getItems().get(0).getY());
Assertions.assertEquals(120.0, translated.getItems().getFirst().getX());
Assertions.assertEquals(100, translated.getItems().getFirst().getY());
}

@Test
Expand Down
Loading
Loading