Beispiel #1
0
  @SuppressWarnings("unchecked")
  private void saveAll() {
    m_stackFile.setDumpCount(m_dumpCount);
    m_stackFile.setTotalWorkerCount(m_totalWorkerCount);
    m_stackFile.setTotalWorkingCount(m_totalWorkingCount);
    m_stackFile.setTotalSecond(m_totalSecond);

    StackAnalyzedInfo info = saveStackAnalyzedInfo(m_topList, TOP_NAME, TOP_EXT);
    if (info != null) m_stackFile.addStackAnalyzedInfo(info);
    info = saveStackAnalyzedInfo(m_sqlList, SQL_NAME, SQL_EXT);
    if (info != null) m_stackFile.addStackAnalyzedInfo(info);
    info = saveStackAnalyzedInfo(m_serviceList, SERVICE_NAME, SERVICE_EXT);
    if (info != null) m_stackFile.addStackAnalyzedInfo(info);
    info = saveStackAnalyzedInfo(m_logList, LOG_NAME, LOG_EXT);
    if (info != null) m_stackFile.addStackAnalyzedInfo(info);

    for (int i = 0; i < m_analyzerCount; i++) {
      info =
          saveStackAnalyzedInfo(
              m_analyzerList[i], m_analyzer.get(i).getName(), m_analyzer.get(i).getExtension());
      if (info != null) m_stackFile.addStackAnalyzedInfo(info);
    }

    // unique Stack
    info = saveUniqueStackAnalyzedInfo(m_uniqueStackMap, UNIQUE_NAME, UNIQUE_EXT);
    if (info != null) m_stackFile.addStackAnalyzedInfo(info);

    if (m_timeList.size() > 0) {
      m_stackFile.setTimeList(m_timeList);
    }
    if (m_threadStatusList.size() > 0) {
      m_stackFile.setThreadStatusList(m_threadStatusList);
    }

    saveAnalyzedInfo();
  }
Beispiel #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;
  }