Skip to content

Commit

Permalink
Merge branch 'feature/#155/support-unified-jvm-logging-format' into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
chewiebug committed Feb 25, 2018
2 parents 433d977 + 54d5042 commit 7ec56ac
Show file tree
Hide file tree
Showing 58 changed files with 1,223 additions and 641 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ When logfile rotation (-XX:+UseGCLogFileRotation) is enabled, the logfiles can b

Supported verbose:gc formats are:

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

Best results are achieved with: -Xloggc:<file> -XX:+PrintGCDetails -XX:+PrintGCDateStamps.
Best results for non unified gc logging Oracle JDKs are achieved with: -Xloggc:<file> -XX:+PrintGCDetails -XX:+PrintGCDateStamps.
A few other options are supported, but most of the information generated is ignored by GCViewer
(the javadoc introduction of
https://github.com/chewiebug/GCViewer/blob/master/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderSun1_6_0.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
public interface GCModelLoaderGroupTracker extends PropertyChangeListener {
/**
* @param listener The PropertyChangeListener to be added
* @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
*/
void addPropertyChangeListener(PropertyChangeListener listener);
Expand All @@ -36,6 +37,7 @@ public interface GCModelLoaderGroupTracker extends PropertyChangeListener {
void propertyChange(PropertyChangeEvent evt);

/**
* @param listener The PropertyChangeListener to be removed
* @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
*/
void removePropertyChangeListener(PropertyChangeListener listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ViewMenuController implements ActionListener, PropertyChangeListene
private GCViewerGui gui;

/**
* @param gui
* @param gui gui to listen for actions
*/
public ViewMenuController(GCViewerGui gui) {
this.gui = gui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.LineNumberReader;
import java.io.UnsupportedEncodingException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.LinkedList;
Expand All @@ -17,6 +16,7 @@
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.GcPattern;
import com.tagtraum.perf.gcviewer.model.GCEvent;
import com.tagtraum.perf.gcviewer.model.GCResource;
import com.tagtraum.perf.gcviewer.util.DateHelper;
import com.tagtraum.perf.gcviewer.util.NumberParser;
import com.tagtraum.perf.gcviewer.util.ParseInformation;

Expand All @@ -31,7 +31,6 @@
*/
public abstract class AbstractDataReaderSun extends AbstractDataReader {

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

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

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


protected ExtendedType extractTypeFromParsedString(String typeName) throws UnknownGcTypeException {
return getDataReaderTools().extractTypeFromParsedString(typeName);
protected ExtendedType extractTypeFromParsedString(String typeName) {
return getDataReaderTools().parseTypeWithCause(typeName);
}

/**
Expand Down Expand Up @@ -433,7 +434,7 @@ protected ZonedDateTime parseDatestamp(String line, ParseInformation pos) throws
if (nextIsDatestamp(line, pos)) {
try {
zonedDateTime = ZonedDateTime.parse(line.substring(pos.getIndex(), pos.getIndex() + LENGTH_OF_DATESTAMP - 1),
DATE_TIME_FORMATTER);
DateHelper.DATE_TIME_FORMATTER);
pos.setIndex(pos.getIndex() + LENGTH_OF_DATESTAMP);
if (pos.getFirstDateStamp() == null) {
pos.setFirstDateStamp(zonedDateTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public GCModel loadModel(GCResource gcResource) throws DataReaderException {
*
* @param gcResource the {@link GcResourceSeries} to load
* @return a {@link GCModel} containing all events found in the given {@link GCResource}s that were readable
* @throws DataReaderException
* @throws DataReaderException thrown in case of some parser failure
*/
protected GCModel loadModelFromSeries(GcResourceSeries gcResource) throws DataReaderException {
GcSeriesLoader seriesLoader = new GcSeriesLoader(this);
Expand All @@ -106,12 +106,12 @@ private GCModel readModel(GcResourceFile gcResource) throws IOException {
InputStream in = null;
try {
if (url.getProtocol().startsWith("http")) {
AtomicLong cl = new AtomicLong();
AtomicLong atomicContentLength = new AtomicLong();
URLConnection conn = url.openConnection();
in = HttpUrlConnectionHelper.openInputStream((HttpURLConnection) conn,
HttpUrlConnectionHelper.GZIP,
cl);
contentLength = cl.get();
atomicContentLength);
contentLength = atomicContentLength.get();
}
else {
in = url.openStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public class DataReaderIBMi5OS1_4_2 extends AbstractDataReader {

/**
* Constructor for the IBM i5/OS GC reader.
* @param gcResource information about the resource to be parsed
* @param in InputStream delivering the GC data
* @throws UnsupportedEncodingException
* @throws UnsupportedEncodingException thrown in case the desired encoding is not supported
*/
public DataReaderIBMi5OS1_4_2(GCResource gcResource, InputStream in) throws UnsupportedEncodingException {
super(gcResource, in);
Expand Down
24 changes: 19 additions & 5 deletions src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,25 @@ else if ('G' == memUnit) {
* @throws UnknownGcTypeException If <code>typeString</code> can't be converted to an <code>ExtendedType</code>
*/
public ExtendedType parseType(String typeString) throws UnknownGcTypeException {
ExtendedType gcType = extractTypeFromParsedString(typeString.trim());
ExtendedType gcType = parseTypeWithCause(typeString.trim());
if (gcType == null) {
throw new UnknownGcTypeException(typeString);
}

return gcType;
}

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

private String getLookupTypeName(String typeName) {
typeName = typeName.endsWith(":")
? typeName.substring(0, typeName.length()-1)
: typeName;
return typeName.endsWith("--")
? typeName.substring(0, typeName.length()-2)
: typeName;
}


}
Loading

0 comments on commit 7ec56ac

Please sign in to comment.