Ejemplo n.º 1
0
 private StackFileInfo processStackFile(
     StackFileInfo stackFileInfo,
     ParserConfig config,
     String filter,
     boolean isRecent,
     boolean isInclude) {
   try {
     StackParser parser = StackParser.getParser(config, filter, isInclude);
     parser.analyze(stackFileInfo);
     stackFileInfo = postSTackFile(stackFileInfo, config, filter, isRecent);
   } catch (RuntimeException ex) {
     StackParser.removeAllAnalyzedFile(stackFileInfo);
     throw ex;
   }
   return stackFileInfo;
 }
Ejemplo n.º 2
0
  public static StackFileInfo loadAnalyzedInfo(String filename) {
    String endString =
        new StringBuilder(20)
            .append(StackParser.INFO_EXT)
            .append('.')
            .append(INFO_EXTENSION)
            .toString();
    if (!filename.endsWith(endString))
      throw new RuntimeException(filename + " is not a Scouter analyzed info file!");

    String stackFilename = filename.substring(0, filename.indexOf(endString) - 1);

    StackFileInfo stackFileInfo = new StackFileInfo(stackFilename);

    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new FileReader(new File(filename)));

      String line = null;
      int lineCount = 0;
      ArrayList<String> timeList = new ArrayList<String>();
      ArrayList<String> threadStatusList = new ArrayList<String>();

      while ((line = reader.readLine()) != null) {
        line = line.trim();
        if (line.length() == 0) continue;
        if (lineCount == 0) {
          ParserConfigReader ConfigReader = new ParserConfigReader(line);
          ParserConfig config = ConfigReader.read();
          stackFileInfo.setParserConfig(config);
          StackParser parser = StackParser.getParser(config, null, true);
          stackFileInfo.setUsedParser(parser);
        } else if (lineCount == 1) {
          StringTokenizer token = new StringTokenizer(line, "\t");
          String value = null;
          int index = 0;
          while (token.hasMoreElements()) {
            value = token.nextToken();
            if (index == 0) {
              stackFileInfo.setDumpCount(Integer.parseInt(value));
            } else if (index == 1) {
              stackFileInfo.setTotalWorkerCount(Integer.parseInt(value));
            } else if (index == 2) {
              stackFileInfo.setTotalWorkingCount(Integer.parseInt(value));
            } else if (index == 3) {
              stackFileInfo.setTotalSecond(Integer.parseInt(value));
            } else {
              threadStatusList.add(value);
            }
            index++;
          }
        } else {
          timeList.add(line);
        }
        lineCount++;
      }
      if (timeList.size() > 0) {
        stackFileInfo.setTimeList(timeList);
      }
      if (threadStatusList.size() > 0) {
        stackFileInfo.setThreadStatusList(threadStatusList);
      }

      loadStackAnalyzedInfo(stackFileInfo);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    } finally {
      try {
        if (reader != null) reader.close();
      } catch (Exception ex) {
      }
    }
    return stackFileInfo;
  }