Skip to content

Commit 7ec56ac

Browse files
committed
Merge branch 'feature/#155/support-unified-jvm-logging-format' into develop
2 parents 433d977 + 54d5042 commit 7ec56ac

File tree

58 files changed

+1223
-641
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1223
-641
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ When logfile rotation (-XX:+UseGCLogFileRotation) is enabled, the logfiles can b
1919

2020
Supported verbose:gc formats are:
2121

22-
- partial support for OpenJDK 9 unified logging format -Xlog:gc:<file>
23-
- no heap information is evaluated, but all events with tag "gc" only should be recognised
24-
- required decorations: tags,uptime (others will be ignored or parser might fail)
22+
- some support for OpenJDK 9 unified logging format -Xlog:gc:<file>, the following configurations will work
23+
- -Xlog:gc:file="path-to-file" (uses defaults)
24+
- -Xlog:gc=info:file="path-to-file":tags,uptime,level (minimum configuration needed)
25+
- -Xlog:gc*=trace:file="path-to-file":tags,time,uptime,level
26+
(maximum configuration supported, additional tags ok, but ignored; additional decorations will break parsing)
2527
- Oracle JDK 1.8 -Xloggc:<file> [-XX:+PrintGCDetails] [-XX:+PrintGCDateStamps]
2628
- Sun / Oracle JDK 1.7 with option -Xloggc:<file> [-XX:+PrintGCDetails] [-XX:+PrintGCDateStamps]
2729
- Sun / Oracle JDK 1.6 with option -Xloggc:<file> [-XX:+PrintGCDetails] [-XX:+PrintGCDateStamps]
@@ -32,7 +34,7 @@ Supported verbose:gc formats are:
3234
- HP-UX JDK 1.2/1.3/1.4.x with the option -Xverbosegc
3335
- BEA JRockit 1.4.2/1.5/1.6 with the option -verbose:memory [-Xverbose:gcpause,gcreport] [-Xverbosetimestamp]
3436

35-
Best results are achieved with: -Xloggc:<file> -XX:+PrintGCDetails -XX:+PrintGCDateStamps.
37+
Best results for non unified gc logging Oracle JDKs are achieved with: -Xloggc:<file> -XX:+PrintGCDetails -XX:+PrintGCDateStamps.
3638
A few other options are supported, but most of the information generated is ignored by GCViewer
3739
(the javadoc introduction of
3840
https://github.com/chewiebug/GCViewer/blob/master/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderSun1_6_0.java

src/main/java/com/tagtraum/perf/gcviewer/ctrl/GCModelLoaderGroupTracker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
public interface GCModelLoaderGroupTracker extends PropertyChangeListener {
1515
/**
16+
* @param listener The PropertyChangeListener to be added
1617
* @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
1718
*/
1819
void addPropertyChangeListener(PropertyChangeListener listener);
@@ -36,6 +37,7 @@ public interface GCModelLoaderGroupTracker extends PropertyChangeListener {
3637
void propertyChange(PropertyChangeEvent evt);
3738

3839
/**
40+
* @param listener The PropertyChangeListener to be removed
3941
* @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
4042
*/
4143
void removePropertyChangeListener(PropertyChangeListener listener);

src/main/java/com/tagtraum/perf/gcviewer/ctrl/impl/ViewMenuController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ViewMenuController implements ActionListener, PropertyChangeListene
2424
private GCViewerGui gui;
2525

2626
/**
27-
* @param gui
27+
* @param gui gui to listen for actions
2828
*/
2929
public ViewMenuController(GCViewerGui gui) {
3030
this.gui = gui;

src/main/java/com/tagtraum/perf/gcviewer/imp/AbstractDataReaderSun.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.io.LineNumberReader;
66
import java.io.UnsupportedEncodingException;
77
import java.time.ZonedDateTime;
8-
import java.time.format.DateTimeFormatter;
98
import java.time.format.DateTimeParseException;
109
import java.time.temporal.ChronoUnit;
1110
import java.util.LinkedList;
@@ -17,6 +16,7 @@
1716
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.GcPattern;
1817
import com.tagtraum.perf.gcviewer.model.GCEvent;
1918
import com.tagtraum.perf.gcviewer.model.GCResource;
19+
import com.tagtraum.perf.gcviewer.util.DateHelper;
2020
import com.tagtraum.perf.gcviewer.util.NumberParser;
2121
import com.tagtraum.perf.gcviewer.util.ParseInformation;
2222

@@ -31,7 +31,6 @@
3131
*/
3232
public abstract class AbstractDataReaderSun extends AbstractDataReader {
3333

34-
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
3534
private static final int LENGTH_OF_DATESTAMP = 29;
3635

3736
private static final String CMS_PRINT_PROMOTION_FAILURE = "promotion failure size";
@@ -56,7 +55,9 @@ public abstract class AbstractDataReaderSun extends AbstractDataReader {
5655
protected GcLogType gcLogType;
5756

5857
/**
59-
* Create an instance of this class passing an inputStream an the type of the logfile.
58+
* Create an instance of this class passing an inputStream and the type of the logfile.
59+
*
60+
* @param gcResource information about the resource to be parsed
6061
* @param in inputstream to the log file
6162
* @param gcLogType type of the logfile
6263
* @throws UnsupportedEncodingException if ASCII is not supported
@@ -301,8 +302,8 @@ protected ExtendedType parseType(String line, ParseInformation pos) throws Parse
301302
}
302303

303304

304-
protected ExtendedType extractTypeFromParsedString(String typeName) throws UnknownGcTypeException {
305-
return getDataReaderTools().extractTypeFromParsedString(typeName);
305+
protected ExtendedType extractTypeFromParsedString(String typeName) {
306+
return getDataReaderTools().parseTypeWithCause(typeName);
306307
}
307308

308309
/**
@@ -433,7 +434,7 @@ protected ZonedDateTime parseDatestamp(String line, ParseInformation pos) throws
433434
if (nextIsDatestamp(line, pos)) {
434435
try {
435436
zonedDateTime = ZonedDateTime.parse(line.substring(pos.getIndex(), pos.getIndex() + LENGTH_OF_DATESTAMP - 1),
436-
DATE_TIME_FORMATTER);
437+
DateHelper.DATE_TIME_FORMATTER);
437438
pos.setIndex(pos.getIndex() + LENGTH_OF_DATESTAMP);
438439
if (pos.getFirstDateStamp() == null) {
439440
pos.setFirstDateStamp(zonedDateTime);

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderFacade.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public GCModel loadModel(GCResource gcResource) throws DataReaderException {
8585
*
8686
* @param gcResource the {@link GcResourceSeries} to load
8787
* @return a {@link GCModel} containing all events found in the given {@link GCResource}s that were readable
88-
* @throws DataReaderException
88+
* @throws DataReaderException thrown in case of some parser failure
8989
*/
9090
protected GCModel loadModelFromSeries(GcResourceSeries gcResource) throws DataReaderException {
9191
GcSeriesLoader seriesLoader = new GcSeriesLoader(this);
@@ -106,12 +106,12 @@ private GCModel readModel(GcResourceFile gcResource) throws IOException {
106106
InputStream in = null;
107107
try {
108108
if (url.getProtocol().startsWith("http")) {
109-
AtomicLong cl = new AtomicLong();
109+
AtomicLong atomicContentLength = new AtomicLong();
110110
URLConnection conn = url.openConnection();
111111
in = HttpUrlConnectionHelper.openInputStream((HttpURLConnection) conn,
112112
HttpUrlConnectionHelper.GZIP,
113-
cl);
114-
contentLength = cl.get();
113+
atomicContentLength);
114+
contentLength = atomicContentLength.get();
115115
}
116116
else {
117117
in = url.openStream();

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderIBMi5OS1_4_2.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ public class DataReaderIBMi5OS1_4_2 extends AbstractDataReader {
2727

2828
/**
2929
* Constructor for the IBM i5/OS GC reader.
30+
* @param gcResource information about the resource to be parsed
3031
* @param in InputStream delivering the GC data
31-
* @throws UnsupportedEncodingException
32+
* @throws UnsupportedEncodingException thrown in case the desired encoding is not supported
3233
*/
3334
public DataReaderIBMi5OS1_4_2(GCResource gcResource, InputStream in) throws UnsupportedEncodingException {
3435
super(gcResource, in);

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderTools.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,25 @@ else if ('G' == memUnit) {
6060
* @throws UnknownGcTypeException If <code>typeString</code> can't be converted to an <code>ExtendedType</code>
6161
*/
6262
public ExtendedType parseType(String typeString) throws UnknownGcTypeException {
63-
ExtendedType gcType = extractTypeFromParsedString(typeString.trim());
63+
ExtendedType gcType = parseTypeWithCause(typeString.trim());
6464
if (gcType == null) {
6565
throw new UnknownGcTypeException(typeString);
6666
}
6767

6868
return gcType;
6969
}
7070

71-
public ExtendedType extractTypeFromParsedString(String typeName) {
71+
/**
72+
* Same as @{link {@link #parseType(String)}}, but returns <code>null</code> instead of exception, if no type could
73+
* be found.
74+
*
75+
* @param typeName string representation of the gc event
76+
* @return <code>ExtendedType</code> representing <code>typeString</code>, or <code>null</code> if none could be found
77+
*/
78+
public ExtendedType parseTypeWithCause(String typeName) {
7279
typeName = typeName.trim();
7380
ExtendedType extendedType = null;
74-
String lookupTypeName = typeName.endsWith("--")
75-
? typeName.substring(0, typeName.length()-2)
76-
: typeName;
81+
String lookupTypeName = getLookupTypeName(typeName);
7782
AbstractGCEvent.Type gcType = AbstractGCEvent.Type.lookup(lookupTypeName);
7883
// the gcType may be null because there was a PrintGCCause flag enabled - if so, reparse it with the first paren set stripped
7984
if (gcType == null) {
@@ -91,5 +96,14 @@ public ExtendedType extractTypeFromParsedString(String typeName) {
9196
return extendedType;
9297
}
9398

99+
private String getLookupTypeName(String typeName) {
100+
typeName = typeName.endsWith(":")
101+
? typeName.substring(0, typeName.length()-1)
102+
: typeName;
103+
return typeName.endsWith("--")
104+
? typeName.substring(0, typeName.length()-2)
105+
: typeName;
106+
}
107+
94108

95109
}

0 commit comments

Comments
 (0)