コード例 #1
0
  public void endElement(
      String namespaceURI,
      String sName, // simple name
      String qName // qualified name
      ) throws SAXException {
    if ("af".equals(qName)) {
      System.out.println("In AF endElement!");
      if (currentAF != null) {
        GCEvent event = new GCEvent();
        if (!"tenured".equals(currentAF.type)) {
          LOG.warning("Unhandled AF type: " + currentAF.type);
        }
        if (!"global".equals(currentAF.gcType)) {
          LOG.warning("Different GC type: " + currentAF.gcType);
        } else {
          event.setType(AbstractGCEvent.Type.FULL_GC);
        }
        if (currentAF.initialTotalBytes != -1 && currentAF.initialFreeBytes != -1) {
          int preUsed = currentAF.initialTotalBytes - currentAF.initialFreeBytes;
          event.setPreUsed(preUsed);
        }

        if (currentAF.afterTotalBytes != -1 && currentAF.afterFreeBytes != -1) {
          int postUsed = currentAF.afterTotalBytes - currentAF.afterFreeBytes;
          event.setPostUsed(postUsed);
        }

        if (currentAF.afterTotalBytes != -1) {
          event.setTotal(currentAF.afterTotalBytes);
        }

        // event.setTimestamp(currentAF.timestamp.getTime());
        event.setTimestamp(currentAF.elapsedTime);

        if (currentAF.totalTime != -1) {
          event.setPause(currentAF.totalTime);
        }

        if (currentAF.afterSOATotalBytes != -1
            && currentAF.afterSOAFreeBytes != -1
            && currentAF.initialSOAFreeBytes != -1
            && currentAF.initialSOATotalBytes != -1) {
          int preUsed = currentAF.initialSOATotalBytes - currentAF.initialSOAFreeBytes;
          int postUsed = currentAF.afterSOATotalBytes - currentAF.afterSOAFreeBytes;
          final GCEvent detailEvent = new GCEvent();
          detailEvent.setTimestamp(currentAF.elapsedTime);
          detailEvent.setType(AbstractGCEvent.Type.PS_YOUNG_GEN);
          detailEvent.setTenuredDetail(true);
          detailEvent.setPreUsed(preUsed);
          detailEvent.setPostUsed(postUsed);
          detailEvent.setTotal(currentAF.afterSOATotalBytes);
          event.add(detailEvent);
        }

        if (currentAF.afterLOATotalBytes != -1
            && currentAF.afterLOAFreeBytes != -1
            && currentAF.initialLOAFreeBytes != -1
            && currentAF.initialLOATotalBytes != -1) {
          int preUsed = currentAF.initialLOATotalBytes - currentAF.initialLOAFreeBytes;
          int postUsed = currentAF.afterLOATotalBytes - currentAF.afterLOAFreeBytes;
          final GCEvent detailEvent = new GCEvent();
          detailEvent.setTimestamp(currentAF.elapsedTime);
          detailEvent.setType(AbstractGCEvent.Type.PS_OLD_GEN);
          detailEvent.setTenuredDetail(true);
          detailEvent.setPreUsed(preUsed);
          detailEvent.setPostUsed(postUsed);
          detailEvent.setTotal(currentAF.afterLOATotalBytes);
          event.add(detailEvent);
        }

        model.add(event);
        currentTenured = 0;
        currentAF = null;
      } else {
        LOG.warning("Found end <af> tag with no begin tag");
      }
    }
  }
コード例 #2
0
 public GCModel read() throws IOException {
   if (LOG.isLoggable(Level.INFO)) LOG.info("Reading IBM 1.3.0 format...");
   try {
     GCModel model = new GCModel(true);
     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;
           }
         default:
       }
     }
     return model;
   } finally {
     if (in != null)
       try {
         in.close();
       } catch (IOException ioe) {
       }
     if (LOG.isLoggable(Level.INFO)) LOG.info("Reading done.");
   }
 }
コード例 #3
0
 public GCModel read() throws IOException {
   if (LOG.isLoggable(Level.INFO)) LOG.info("Reading IBM 1.3.1 format...");
   try {
     final GCModel model = new GCModel(true);
     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;
           }
           break;
         default:
       }
     }
     // System.err.println(model);
     return model;
   } finally {
     if (in != null)
       try {
         in.close();
       } catch (IOException ioe) {
       }
     if (LOG.isLoggable(Level.INFO)) LOG.info("Done reading.");
   }
 }