Skip to content

Commit

Permalink
Clarify datetime option usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm3746 committed Dec 14, 2024
1 parent ba17be1 commit 4af1893
Show file tree
Hide file tree
Showing 33 changed files with 222 additions and 230 deletions.
16 changes: 5 additions & 11 deletions src/main/java/org/eclipselabs/garbagecat/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ public static void createReport(CommandLine cmd) throws IOException {
throw new IllegalArgumentException("Log file and report are the same file.");
}

// Determine JVM environment information.
// Requiring the JVM start date/time for preprocessing was originally a hack to handle datestamps introduced
// with <code>-XX:+PrintGCDateStamps</code> was introduced in JDK 1.6 update 4. It is now to
// convert uptime to a datestamp in reporting (e.g. bottlenecks).
Date jvmStartDate = cmd.hasOption(OPTION_STARTDATETIME_LONG)
? parseStartDateTime(cmd.getOptionValue(OPTION_STARTDATETIME_SHORT))
: null;

String jvmOptions = cmd.hasOption(OPTION_JVMOPTIONS_LONG) ? cmd.getOptionValue(OPTION_JVMOPTIONS_SHORT) : null;

URI logFileUri = logFile.toURI();
Expand All @@ -122,19 +125,10 @@ public static void createReport(CommandLine cmd) throws IOException {

// Do preprocessing
if (cmd.hasOption(OPTION_PREPROCESS_LONG) || cmd.hasOption(OPTION_STARTDATETIME_LONG)) {
/*
* Requiring the JVM start date/time for preprocessing is a hack to handle datestamps. When garbagecat was
* started there was no <code>-XX:+PrintGCDateStamps</code> option. When it was introduced in JDK 1.6 update
* 4, the easiest thing to do to handle datestamps was to preprocess the datestamps and convert them to
* timestamps.
*
* TODO: Handle datetimes separately from preprocessing so preprocessing doesn't require passing in the JVM
* start date/time.
*/
if (verbose) {
System.out.println("preprocessing...");
}
logLines = gcManager.preprocess(logLines, jvmStartDate);
logLines = gcManager.preprocess(logLines);
}

// Allow logging to be reordered?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class OptionsParser {
options.addOption(OPTION_JVMOPTIONS_SHORT, OPTION_JVMOPTIONS_LONG, true, "JVM options used during JVM run");
options.addOption(OPTION_PREPROCESS_SHORT, OPTION_PREPROCESS_LONG, false, "do preprocessing");
options.addOption(OPTION_STARTDATETIME_SHORT, OPTION_STARTDATETIME_LONG, true,
"JVM start datetime (yyyy-MM-dd HH:mm:ss.SSS) to convert uptime to datestamp");
"JVM start datetime (yyyy-MM-dd HH:mm:ss.SSS) to convert uptime to datestamp in reporting");
options.addOption(OPTION_THRESHOLD_SHORT, OPTION_THRESHOLD_LONG, true,
"threshold (0-100) for throughput bottleneck reporting");
options.addOption(OPTION_REORDER_SHORT, OPTION_REORDER_LONG, false, "reorder logging by timestamp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,9 @@ public boolean isPreprocessed() {
*
* @param logLines
* Raw garbage collection logging.
* @param jvmStartDate
* The date and time the JVM was started.
* @return Preprocessed garbage collection logging.
*/
public List<String> preprocess(List<String> logLines, Date jvmStartDate) {
public List<String> preprocess(List<String> logLines) {
if (logLines == null)
throw new IllegalArgumentException("logLines == null!!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void testSafepointSummaryTotals() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down
26 changes: 13 additions & 13 deletions src/test/java/org/eclipselabs/garbagecat/domain/TestJvmRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void testApplicationStoppedTimeNoTimestamps() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertEquals((long) 2097502, jvmRun.getDurationTotal(), "GC pause total not correct.");
Expand Down Expand Up @@ -91,7 +91,7 @@ void testCombinedCmsConcurrentApplicationConcurrentTimeLogging() throws IOExcept
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -113,7 +113,7 @@ void testCombinedCmsConcurrentApplicationStoppedTimeLogging() throws IOException
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -284,7 +284,7 @@ void testLoggingToStdOutNot() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.hasAnalysis(org.github.joa.util.Analysis.INFO_GC_LOG_STDOUT.getKey()),
Expand Down Expand Up @@ -469,7 +469,7 @@ void testPrintGcApplicationConcurrentTimeAnalysis() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertTrue(jvmRun.hasAnalysis(org.github.joa.util.Analysis.INFO_PRINT_GC_APPLICATION_CONCURRENT_TIME.getKey()),
Expand All @@ -488,7 +488,7 @@ void testPrintTenuringDistributionPreprocessActionNoSpaceAfterGc() throws IOExce
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -504,7 +504,7 @@ void testRemoveBlankLines() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -529,7 +529,7 @@ void testSplitParallelOldCompactingEventLogging() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -600,7 +600,7 @@ void testSummaryStatsG1ExtRootScanning() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertEquals((long) 400, jvmRun.getExtRootScanningTimeMax(),
Expand Down Expand Up @@ -692,7 +692,7 @@ void testSummaryStatsPartialLog() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -725,7 +725,7 @@ void testSummaryStatsShenandoah() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -753,7 +753,7 @@ void testSummaryStatsStoppedTime() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -786,7 +786,7 @@ void testSummaryStatsUnifiedStoppedTime() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void testTraceClassUnloadingPreprocessing() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void testTruncatedPreprocessing() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ void testParNewConcurrentModeFailureMixedCmsConcurrentJdk8() throws IOException
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -977,7 +977,7 @@ void testParNewPromotionFailedCmsSerialOldPermDataPrintClassHistogramTriggerAcro
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down Expand Up @@ -1127,7 +1127,7 @@ void testSplit3LinesParNewConcurrentModeFailureEventLogging() throws IOException
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -1149,7 +1149,7 @@ void testSplit3LinesParNewPromotionFailedCmsConcurrentModeFailurePermDataEventMa
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -1171,7 +1171,7 @@ void testSplitParNewCmsConcurrentModeFailurePermData() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -1191,7 +1191,7 @@ void testSplitParNewPromotionFailedCmsConcurrentModeFailure() throws IOException
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -1215,7 +1215,7 @@ void testSplitParNewPromotionFailedCmsConcurrentModeFailurePermData() throws IOE
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand All @@ -1242,7 +1242,7 @@ void testSplitPrintHeapAtGcParNewConcurrentModeFailureEventLogging() throws IOEx
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertFalse(jvmRun.getEventTypes().contains(LogEventType.UNKNOWN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void testHeapInspectionInitiatedGc() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertEquals(1, jvmRun.getEventTypes().size(), "Event type count not correct.");
Expand Down Expand Up @@ -394,7 +394,7 @@ void testTriggerHeapDumpInitiatedGc() throws IOException {
GcManager gcManager = new GcManager();
URI logFileUri = testFile.toURI();
List<String> logLines = Files.readAllLines(Paths.get(logFileUri));
logLines = gcManager.preprocess(logLines, null);
logLines = gcManager.preprocess(logLines);
gcManager.store(logLines, false);
JvmRun jvmRun = gcManager.getJvmRun(null, Constants.DEFAULT_BOTTLENECK_THROUGHPUT_THRESHOLD);
assertEquals(1, jvmRun.getEventTypes().size(), "Event type count not correct.");
Expand Down
Loading

0 comments on commit 4af1893

Please sign in to comment.