Package com.tagtraum.perf.gcviewer.model

Examples of com.tagtraum.perf.gcviewer.model.GCEvent


            final GCEvent event) throws ParseException {
               
        int currentIndex = pos.getIndex();
        boolean currentIndexHasChanged = true;
        while (hasNextDetail(line, pos) && currentIndexHasChanged) {
            final GCEvent detailEvent = new GCEvent();
            try {
                if (nextCharIsBracket(line, pos)) {
                    detailEvent.setDateStamp(event.getDatestamp());
                    detailEvent.setTimestamp(event.getTimestamp());
                }
                else {
                    Date datestamp = parseDatestamp(line, pos);
                    detailEvent.setDateStamp(datestamp);
                    detailEvent.setTimestamp(getTimestamp(line, pos, datestamp));
                }
                detailEvent.setExtendedType(parseType(line, pos));
                if (nextIsTimestamp(line, pos) || nextIsDatestamp(line, pos)) {
                    parseDetailEventsIfExist(line, pos, detailEvent);
                }
                if (detailEvent.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE) {
                    setMemoryAndPauses(detailEvent, line, pos);
                }
                else if (detailEvent.getExtendedType().getPattern() == GcPattern.GC_MEMORY) {
                    setMemory(detailEvent, line, pos);
                    skipBlanksAndCommas(line, pos);
                    if (line.indexOf("]", pos.getIndex()) == pos.getIndex()) {
                        pos.setIndex(pos.getIndex() + 1);
                    }
                }
                else {
                    detailEvent.setPause(parsePause(line, pos));
                }
                event.add(detailEvent);
            }
            catch (UnknownGcTypeException e) {
                skipUntilEndOfDetail(line, pos, e);
View Full Code Here


        boolean gcSummary = false;
        try {
            GCModel model = new GCModel();
            model.setFormat(GCModel.Format.SUN_X_LOG_GC);
            String line = null;
            GCEvent event = null;
            int nurserySize = -1;
            while ((line = in.readLine()) != null) {
                final int memoryIndex = line.indexOf(MEMORY_MARKER);
                if (memoryIndex == -1) {
                    if (LOG.isLoggable(Level.FINE)) LOG.fine("Ignoring line " + in.getLineNumber() + ". Missing \"[memory ]\" marker: " + line);
                    continue;
                }
                if (line.endsWith(MEMORY_MARKER)) {
                    continue;
                }
                final int startTimeIndex = memoryIndex + MEMORY_MARKER.length();

                // print some special statements to the log.
                if (!gcSummary) {
                    gcSummary = line.endsWith("Memory usage report");
                }
                if (gcSummary) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("Prefetch distance") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("GC strategy") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.toLowerCase().indexOf("heap size:") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    final int nurserySizeStart = line.indexOf(NURSERY_SIZE);
                    final int nurserySizeEnd = line.indexOf('K', nurserySizeStart + NURSERY_SIZE.length());
                    if (nurserySizeStart != -1) {
                        nurserySize = Integer.parseInt(line.substring(nurserySizeStart + NURSERY_SIZE.length(), nurserySizeEnd));
                    }
                    continue;
                }
                else if (line.substring(startTimeIndex).startsWith("<")) {
                    // ignore
                    if (LOG.isLoggable(Level.FINE)) LOG.fine(line.substring(startTimeIndex));
                    continue;
                }

                final int colon = line.indexOf(':', startTimeIndex);
                if (colon == -1) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "). Missing colon after start time: " + line);
                    continue;
                }
                event = new GCEvent();

                // set timestamp
                final String timestampString = line.substring(startTimeIndex, colon);
                final int minus = timestampString.indexOf('-');
                if (minus == -1) {
                    event.setTimestamp(NumberParser.parseDouble(timestampString));
                }
                else {
                    event.setTimestamp(NumberParser.parseDouble(timestampString.substring(0, minus)));
                }

                // set type
                final int typeStart = skipSpaces(colon+1, line);
                int typeEnd = typeStart;
                while (!Character.isDigit(line.charAt(++typeEnd))) {}
                final AbstractGCEvent.Type type = AbstractGCEvent.Type.lookup("jrockit." + line.substring(typeStart, typeEnd).trim());
                if (type == null) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info("Failed to determine type: " + line.substring(startTimeIndex));
                    continue;
                }
                event.setType(type);

                // before
                final int startBefore = typeEnd;
                final int endBefore = line.indexOf('K', startBefore);
                event.setPreUsed(Integer.parseInt(line.substring(startBefore, endBefore)));

                // after
                final int startAfter = endBefore+3;
                final int endAfter = line.indexOf('K', startAfter);
                event.setPostUsed(Integer.parseInt(line.substring(startAfter, endAfter)));

                // total
                final int startTotal = line.indexOf('(', endAfter) + 1;
                final int endTotal = line.indexOf('K', startTotal);
                event.setTotal(Integer.parseInt(line.substring(startTotal, endTotal)));

                // pause
                final int startPause = line.indexOf(',', endTotal) + 2;
                final int endPause = line.indexOf(' ', startPause);
                event.setPause(NumberParser.parseDouble(line.substring(startPause, endPause)) / 1000.0d);
                model.add(event);

                // add artificial detail events
                if (nurserySize != -1 && event.getExtendedType().getGeneration() == Generation.YOUNG) {
                    GCEvent detailEvent = new GCEvent();
                    detailEvent.setExtendedType(event.getExtendedType());
                    detailEvent.setTimestamp(event.getTimestamp());
                    detailEvent.setTotal(nurserySize);
                    event.add(detailEvent);
                }
                if (nurserySize != -1 && event.getExtendedType().getGeneration() == Generation.TENURED) {
                    GCEvent detailEvent = new GCEvent();
                    detailEvent.setExtendedType(event.getExtendedType());
                    detailEvent.setTimestamp(event.getTimestamp());
                    detailEvent.setTotal(event.getTotal() - nurserySize);
                    event.add(detailEvent);
                }
            }
            return model;
        } finally {
View Full Code Here

        try {
            GCModel model = new GCModel();
            model.setFormat(GCModel.Format.IBM_VERBOSE_GC);
            int state = 0;
            String line = null;
            AbstractGCEvent<GCEvent> lastEvent = new GCEvent();
            GCEvent event = null;
            while ((line = in.readLine()) != null) {
                String trimmedLine = line.trim();
                if ((!trimmedLine.equals("")) && (!trimmedLine.startsWith("<GC: ")) && (!(trimmedLine.startsWith("<") && trimmedLine.endsWith(">")))) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "): " + line);
                    state = 0;
                }
                switch (state) {
                    case 0:
                        if (line.indexOf("Allocation Failure.") != -1) {
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            event.setTimestamp(lastEvent.getTimestamp() + parseTimeSinceLastAF(line));
                            state++;
                            break;
                        }
                    case 1:
                        if (line.indexOf("managing allocation failure, action=1") != -1) {
                            event.setPreUsed(parsePreUsed(line));
                            state++;
                            break;
                        }
                    case 2:
                        if (line.indexOf("freed") != -1 && line.indexOf("unloaded") == -1) {
                            event.setPostUsed(parsePostUsed(line));
                            event.setTotal(parseTotalAfterGC(line));
                            state++;
                            break;
                        }
                    case 3:
                        if (line.indexOf("expanded heap by ") != -1) {
                            event.setTotal(parseTotalAfterHeapExpansion(line));
                            state++;
                            break;
                        }
                    case 4:
                        if (line.indexOf("completed in ") != -1) {
                            event.setPause(parsePause(line));
                            model.add(event);
                            lastEvent = event;
                            event = null;
                            state = 0;
                        }
View Full Code Here

        try {
            GCModel model = new GCModel();
            model.setFormat(GCModel.Format.SUN_1_2_2VERBOSE_GC);
            String line = null;
            boolean timeline = false;
            AbstractGCEvent<GCEvent> lastEvent = new GCEvent();
            GCEvent event = null;
            while ((line = in.readLine()) != null) {
                if (!timeline) {
                    if (line.endsWith("milliseconds since last GC>")) {
                        timeline = true;
                        double time = Integer.parseInt(line.substring(5, line.indexOf(' ', 5)));
                        event = new GCEvent();
                        event.setTimestamp(lastEvent.getTimestamp() + (time/1000.0d));
                    }
                } else {
                    timeline = false;
                    // we have a time, so now we expect a either expansion or freed objects
                    if (line.indexOf("expanded object space by") != -1) {
                        // expansion
                        int endIndex = line.indexOf(' ', "<GC: expanded object space by ".length());
                        //int incBy = Integer.parseInt(line.substring("<GC: expanded object space by ".length(), endIndex));
                        int beginIndex = endIndex + " to ".length();
                        int incTo = Integer.parseInt(line.substring(beginIndex, line.indexOf(' ', beginIndex)));
                        int percentUsed = Integer.parseInt(line.substring(line.length() - "XX% free>".length(), line.length() - "% free>".length()));
                        event.setPostUsed((int)((incTo * percentUsed / 1024L / 100l)));
                        event.setPreUsed(event.getPostUsed());
                        event.setTotal((int)(incTo / 1024L));
                        event.setType(AbstractGCEvent.Type.GC);
                        event.setPause(0);
                        model.add(event);
                        lastEvent = event;
                    } else if (line.indexOf(" freed ") != -1 && line.indexOf(" objects, ") != -1) {
                        // freed objects
                        int startIndex = line.indexOf(',') + 2;
                        int endIndex = line.indexOf(' ', startIndex);
                        int freed = Integer.parseInt(line.substring(startIndex, endIndex));
                        startIndex = line.indexOf("in ") + 3;
                        endIndex = line.indexOf(' ', startIndex);
                        int pause = Integer.parseInt(line.substring(startIndex, endIndex));
                        startIndex = line.indexOf('(') + 1;
                        endIndex = line.indexOf('/', startIndex);
                        int postFree = Integer.parseInt(line.substring(startIndex, endIndex));
                        startIndex = line.indexOf('/') + 1;
                        endIndex = line.indexOf(')', startIndex);
                        int total = Integer.parseInt(line.substring(startIndex, endIndex));

                        event.setPostUsed((total - postFree) / 1024);
                        event.setPreUsed((total - postFree + freed) / 1024);
                        //event.setPostUsed(event.getPreUsed());
                        event.setTotal(total / 1024);
                        event.setType(AbstractGCEvent.Type.GC);
                        event.setPause((pause) / 1000.0d);
                        model.add(event);
                        lastEvent = event;
                        /*
                        event = new GCEvent();
                        event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
View Full Code Here

        if (LOG.isLoggable(Level.INFO)) LOG.info("Reading HP-UX 1.2-1.4.0 format...");
        try {
            GCModel model = new GCModel();
            model.setFormat(GCModel.Format.SUN_X_LOG_GC);
            String line = null;
            GCEvent event = null;
            while ((line = in.readLine()) != null) {
                StringTokenizer st = new StringTokenizer(line, " ");
                if (st.countTokens() != 20) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "). Wrong number of tokens ("+st.countTokens()+"): " + line);
                    continue;
                }
                if (!"<GC:".equals(st.nextToken())) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "). Expected \"<GC:\" in " + line);
                    continue;
                }
                event = new GCEvent();
                /*
                %1:  Indicates the cause of the garbage collection.
                     -1:  indicates a Scavenge (GC of New Generation only)
                    0-6:  indicates a Full GC (collection of all spaces in the
                          Java Heap)
                     Reason:
                        0:  Call to System.gc
                        1:  Old Generation full
                        2:  Permanent Generation full
                        3:  Train Generation full
                        4:  Old generation expanded on last scavenge
                        5:  Old generation too full to scavenge
                        6:  FullGCAlot
                */
                final int reason = Integer.parseInt(st.nextToken());
                event.setType(findType(reason));
                // %2:  Program time at the beginning of the collection, in seconds
                event.setTimestamp(NumberParser.parseDouble(st.nextToken()));
                // %3:  Garbage collection invocation.  Counts of Scavenge and
                // Full GCs are maintained separately
                st.nextToken();
                // %4:  Size of the object allocation request that forced the GC, in bytes
                st.nextToken();
                // %5:  Tenuring threshold - determines how long the new born object
                // remains in the New Generation
                st.nextToken();
                // Eden Sub-space (within the New Generation)
                // %6:  Before
                // %7:  After
                // %8:  Capacity
                final long edenBefore = Long.parseLong(st.nextToken());
                final long edenAfter = Long.parseLong(st.nextToken());
                final long edenCapacity = Long.parseLong(st.nextToken());
                /*
                GCEvent edenEvent = new GCEvent();
                edenEvent.setType(AbstractGCEvent.Type.DEF_NEW);
                edenEvent.setPreUsed((int)(edenBefore / 1024));
                edenEvent.setPostUsed((int)(edenAfter / 1024));
                edenEvent.setTotal((int)(edenCapacity / 1024));
                */

                // Survivor Sub-space (within the New Generation)
                // %9:   Before
                // %10:  After
                // %11:  Capacity
                final long survivorBefore = Long.parseLong(st.nextToken());
                final long survivorAfter = Long.parseLong(st.nextToken());
                final long survivorCapacity = Long.parseLong(st.nextToken());
                /*
                GCEvent survivorEvent = new GCEvent();
                survivorEvent.setType(AbstractGCEvent.Type.DEF_NEW);
                survivorEvent.setPreUsed((int)(survivorBefore / 1024));
                survivorEvent.setPostUsed((int)(survivorAfter / 1024));
                survivorEvent.setTotal((int)(survivorCapacity / 1024));
                */

                // Since we don't distinguish between survivor spaces and eden, we add things up.
                GCEvent newEvent = new GCEvent();
                newEvent.setType(AbstractGCEvent.Type.DEF_NEW);
                newEvent.setPreUsed((int)((survivorBefore + edenBefore) / 1024));
                newEvent.setPostUsed((int)((survivorAfter + edenAfter) / 1024));
                newEvent.setTotal((int)((survivorCapacity + edenCapacity) / 1024));

                // Old Generation
                // %12:  Before
                // %13:  After
                // %14:  Capacity
                final long oldBefore = Long.parseLong(st.nextToken());
                final long oldAfter = Long.parseLong(st.nextToken());
                final long oldCapacity = Long.parseLong(st.nextToken());
                GCEvent oldEvent = new GCEvent();
                oldEvent.setType(AbstractGCEvent.Type.TENURED);
                oldEvent.setPreUsed((int)(oldBefore / 1024));
                oldEvent.setPostUsed((int)(oldAfter / 1024));
                oldEvent.setTotal((int)(oldCapacity / 1024));

                // Permanent Generation (Storage of Reflective Objects)
                // %15:  Before
                // %16:  After
                // %17:  Capacity
                final long permBefore = Long.parseLong(st.nextToken());
                final long permAfter = Long.parseLong(st.nextToken());
                final long permCapacity = Long.parseLong(st.nextToken());
                GCEvent permEvent = new GCEvent();
                permEvent.setType(AbstractGCEvent.Type.PERM);
                permEvent.setPreUsed((int)(permBefore / 1024));
                permEvent.setPostUsed((int)(permAfter / 1024));
                permEvent.setTotal((int)(permCapacity / 1024));

                // %18:  Time taken in seconds to finish the gc
                final double pause = NumberParser.parseDouble(st.nextToken());
                event.setPause(pause);
                event.setPreUsed(newEvent.getPreUsed() + oldEvent.getPreUsed());
View Full Code Here

            String line;
            ParseInformation parsePosition = new ParseInformation(0);
            Matcher gcPauseMatcher = PATTERN_GC_PAUSE.matcher("");
            Matcher linesMixedMatcher = PATTERN_LINES_MIXED.matcher("");
            Matcher ergonomicsMatcher = PATTERN_G1_ERGONOMICS.matcher("");
            GCEvent gcEvent = null;
            int lineNumber = 0;
            String beginningOfLine = null;

            while ((line = in.readLine()) != null) {
                ++lineNumber;
                parsePosition.setLineNumber(lineNumber);
                parsePosition.setIndex(0);
                if ("".equals(line)) {
                    continue;
                }
                try {
                    // filter out lines that don't need to be parsed
                    if (startsWith(line, EXCLUDE_STRINGS, false)) {
                        continue;
                    }
                    else if (line.indexOf(APPLICATION_TIME) > 0) {
                        continue;
                    }
                    else if (startsWith(line, LOG_INFORMATION_STRINGS, false)) {
                        LOG.info(line);
                        continue;
                    }
                   
                    // remove G1 ergonomics pieces
                    if (line.indexOf(G1_ERGONOMICS) >= 0) {
                        ergonomicsMatcher.reset(line);
                        if (ergonomicsMatcher.matches()) {
                            String firstMatch = (ergonomicsMatcher.group(1));
                            if (firstMatch.length() > 0 && line.indexOf(SOFT_REFERENCE) < 0) {
                                beginningOfLine = firstMatch;
                            }
                            continue;
                        }
                    }

                    // if a new timestamp occurs in the middle of a line, that should be treated as a new line
                    // -> the rest of the old line appears on the next line
                    linesMixedMatcher.reset(line);
                    if (linesMixedMatcher.matches()) {
                        if (line.indexOf("concurrent") > 0) {
                            // 1st pattern (complete concurrent collection follows)
                          beginningOfLine = linesMixedMatcher.group(1);
                          model.add(parseLine(linesMixedMatcher.group(2), parsePosition));
                          parsePosition.setIndex(0);
                          continue; // rest of collection is on the next line, so continue there
                        }
                        else if (line.indexOf(SOFT_REFERENCE) > 0 && line.indexOf(Type.FULL_GC.getName()) > 0) {
                            // for Full GCs, SoftReference entries are treated as unknown detail events
                            // -> parseLine can do this
                        }
                        else if (line.endsWith("secs]")) {
                            // all other patterns: some timestamps follow that are part of a concurrent collection
                            // but the rest of the line is the rest of the same collection
                            StringBuilder realLine = new StringBuilder();
                            realLine.append(linesMixedMatcher.group(1));
                            int toSpaceIndex = line.indexOf(TO_SPACE_OVERFLOW);
                            int initialMarkIndex = line.indexOf(INITIAL_MARK);
                            if (toSpaceIndex > 0 && realLine.length() < toSpaceIndex) {
                                realLine.append(" ").append(TO_SPACE_OVERFLOW);
                            }
                            if (initialMarkIndex > 0 && realLine.length() < initialMarkIndex) {
                                realLine.append(" ").append(INITIAL_MARK);
                            }
                            realLine.append(line.substring(line.lastIndexOf(",")));
                            line = realLine.toString();
                        }
                        else {
                            throw new ParseException("unexpected mixed line", line, parsePosition);
                        }
                    }
                    else if (beginningOfLine != null) {
                        // filter output of -XX:+PrintReferencePolicy away
                        if (line.indexOf(SOFT_REFERENCE) >= 0) {
                            line = line.substring(line.lastIndexOf(","));
                        }
                       
                        // not detailed log but mixed line
                        line = beginningOfLine + line;
                        beginningOfLine = null;
                    }
                   
                    if (line.endsWith(MARK_STACK_IS_FULL)) {
                        // "Mark stack is full" message is treated as part of the event name
                        beginningOfLine = line;
                        continue;
                    }
                    else if (isPrintTenuringDistribution(line)) {
                        beginningOfLine = line;
                        continue;
                    }
                   
                    // the following case is special for -XX:+PrintGCDetails and must be treated
                    // different from the other cases occurring in G1 standard mode
                    // 0.356: [GC pause (young), 0.00219944 secs] -> GC_PAUSE pattern but GC_MEMORY_PAUSE
                    //   event (has extensive details)
                    // all other GC types are the same as in standard G1 mode.
                    gcPauseMatcher.reset(line);
                    if (gcPauseMatcher.matches()) {
                        ExtendedType type = extractTypeFromParsedString(gcPauseMatcher.group(GC_PAUSE_GROUP_TYPE));

                        if (type != null && type.getPattern().compareTo(GcPattern.GC_MEMORY_PAUSE) == 0) {
                            // detailed G1 events start with GC_MEMORY pattern, but are of type GC_MEMORY_PAUSE

                            gcEvent = new G1GcEvent();
                            Date datestamp = parseDatestamp(gcPauseMatcher.group(GC_PAUSE_GROUP_DATESTAMP), parsePosition);
                            gcEvent.setDateStamp(datestamp);
                            double timestamp = 0;
                            if (gcPauseMatcher.group(GC_PAUSE_GROUP_TIMESTAMP) == null) {
                                timestamp = getTimestamp(line, parsePosition, datestamp);
                            }
                            else {
                                timestamp = NumberParser.parseDouble(gcPauseMatcher.group(GC_PAUSE_GROUP_TIMESTAMP));
                            }
                            gcEvent.setTimestamp(timestamp);
                            gcEvent.setExtendedType(type);
                            gcEvent.setPause(NumberParser.parseDouble(gcPauseMatcher.group(GC_PAUSE_GROUP_PAUSE)));
                           
                            // now parse the details of this event
                            lineNumber = parseDetails(in, model, parsePosition, lineNumber, gcEvent, beginningOfLine);
                            beginningOfLine = null;
                            continue;
                        }
                        else {
                            // real GC_PAUSE events like some concurrent events
                            model.add(parseLine(line, parsePosition));
                        }
                    }
                    else if (line.indexOf(Type.FULL_GC.getName()) > 0) {
                        // since jdk 1.8 full gc events in G1 have detailed heap sizing information on the next line
                        GCEvent fullGcEvent = (GCEvent) parseLine(line, parsePosition);
                        if (!in.markSupported()) {
                            LOG.warning("input stream does not support marking!");
                        }
                        else {
                            in.mark(200);
View Full Code Here

        // memory part looks like
        //    [Eden: 8192K(8192K)->0B(8192K) Survivors: 0B->8192K Heap: 8192K(16M)->7895K(16M)]
       
        // parse Eden
        pos.setIndex(line.indexOf("Eden:"));
        GCEvent youngEvent = new GCEvent();
        youngEvent.setDateStamp(event.getDatestamp());
        youngEvent.setTimestamp(event.getTimestamp());
        youngEvent.setExtendedType(parseType(line, pos));
        setMemoryExtended(youngEvent, line, pos);
       
        // add survivors
        pos.setIndex(line.indexOf("Survivors:") + "Survivors:".length() + 1);
        GCEvent survivorsEvent = new GCEvent();
        setMemoryExtended(survivorsEvent, line, pos);
        youngEvent.setPreUsed(youngEvent.getPreUsed() + survivorsEvent.getPreUsed());
        youngEvent.setPostUsed(youngEvent.getPostUsed() + survivorsEvent.getPostUsed());
        youngEvent.setTotal(youngEvent.getTotal() + survivorsEvent.getPostUsed());
       
        event.add(youngEvent);

        // parse heap size
        pos.setIndex(line.indexOf("Heap:") + "Heap:".length() + 1);
        setMemoryExtended(event, line, pos);
       
        // parse Metaspace
        if (line.indexOf("Metaspace:") > 0) {
            pos.setIndex(line.indexOf("Metaspace:"));
            GCEvent metaSpace = new GCEvent();
            metaSpace.setDateStamp(event.getDatestamp());
            metaSpace.setTimestamp(event.getTimestamp());
            metaSpace.setExtendedType(parseType(line, pos));
            setMemoryExtended(metaSpace, line, pos);
           
            event.add(metaSpace);
        }
       
View Full Code Here

                vmOpEvent.setTimestamp(timestamp);
                vmOpEvent.setExtendedType(type);
                vmOpEvent.setPause(parsePause(line, pos));
            }
            else {
                ae = new GCEvent();
                GCEvent event = (GCEvent) ae;
                event.setDateStamp(datestamp);
                event.setTimestamp(timestamp);
                event.setExtendedType(type);
                // Java 7 can have detailed event at this position like this
                // 0.197: [GC remark 0.197: [GC ref-proc, 0.0000070 secs], 0.0005297 secs]
                // or when PrintDateTimeStamps is on like:
                // 2013-09-09T06:45:45.825+0000: 83146.942: [GC remark 2013-09-09T06:45:45.825+0000: 83146.943: [GC ref-proc, 0.0069100 secs], 0.0290090 secs]
                    parseDetailEventsIfExist(line, pos, event);
               
                if (event.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE) {
                    setMemoryAndPauses(event, line, pos);
                }
                else {
                    event.setPause(parsePause(line, pos));
                }
            }
            return ae;
        }
        catch (RuntimeException rte) {
View Full Code Here

        try {
            final GCModel model = new GCModel();
            model.setFormat(GCModel.Format.IBM_VERBOSE_GC);
            int state = 0;
            String line = null;
            GCEvent lastEvent = new GCEvent();
            GCEvent event = null;
            long basetime = 0;
            cycleStartGCFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
            while ((line = in.readLine()) != null) {
                final String trimmedLine = line.trim();
                if (!"".equals(trimmedLine) && !trimmedLine.startsWith("<GC: ") && !trimmedLine.startsWith("<")) {
                    System.err.println("Malformed line (" + in.getLineNumber() + "): " + line);
                    state = 0;
                }
                switch (state) {
                    case 0:
                        if (line.indexOf("Allocation Failure.") != -1) {
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            event.setTimestamp(lastEvent.getTimestamp() + parseTimeSinceLastAF(line));
                            // stay in state 0
                            break;
                        }
                        else if (line.indexOf("GC cycle started") != -1) { // can apparently occur without AF
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            final long time = parseGCCycleStart(line);
                            if (basetime == 0) basetime = time;
                            event.setTimestamp((time - basetime)/1000.0d);
                            state++;
                            break;
                        } else if (line.indexOf("managing allocation failure, action=3") != -1) {
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
                            event.setPreUsed(parsePreUsedAFAction3(line));
                            event.setPostUsed(event.getPreUsed());
                            state = 2;
                            break;
                        }
                        break;
                    case 1:
                        if (line.indexOf("freed") != -1 && line.indexOf("unloaded") == -1) {
                            event.setPreUsed(parsePreUsed(line));
                            event.setPostUsed(parsePostUsed(line));
                            event.setTotal(parseTotalAfterGC(line));
                            event.setPause(parsePause(line));
                            model.add(event);
                            lastEvent = event;
                            event = null;
                            state = 0;
                            break;
                        }
                        break;
                    case 2:
                        if (line.indexOf("expanded heap by ") != -1 || line.indexOf("expanded heap fully by ") != -1) {
                            event.setTotal(parseTotalAfterHeapExpansion(line));
                            state++;
                            break;
                        }
                        break;
                    case 3:
                        if (line.indexOf("completed in ") != -1) {
                            event.setPause(parsePause(line) - lastEvent.getPause());
                            model.add(event);
                            lastEvent = event;
                            event = null;
                            state = 0;
                        }
View Full Code Here

                vmOpEvent.setTimestamp(timestamp);
                vmOpEvent.setExtendedType(type);
                vmOpEvent.setPause(parsePause(line, pos));
            }
            else {
                ae = new GCEvent();
                GCEvent event = (GCEvent) ae;
               
                event.setDateStamp(datestamp);
                event.setTimestamp(timestamp);
                event.setExtendedType(type);
                // now add detail gcevents, should they exist
                parseDetailEventsIfExist(line, pos, event);
                if (event.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE
                    || event.getExtendedType().getPattern() == GcPattern.GC_MEMORY) {
                   
                    setMemory(event, line, pos);
                }
                // then more detail events follow (perm gen is usually here)
                parseDetailEventsIfExist(line, pos, event);
                if (event.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE
                        || event.getExtendedType().getPattern() == GcPattern.GC_PAUSE) {
                   
                    event.setPause(parsePause(line, pos));
                }
            }
            return ae;
        }
        catch (RuntimeException rte) {
View Full Code Here

TOP

Related Classes of com.tagtraum.perf.gcviewer.model.GCEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.