Esempio n. 1
0
  public void analyze(StackFileInfo stackFile) {
    m_stackFile = stackFile;
    m_stackFile.clearAll();
    m_stackFile.setUsedParser(this);
    m_stackFile.setParserConfig(m_config);

    init();

    m_progressBarWindow =
        new ProgressBarWindow(
            MainProcessor.instance().getParentComposite().getShell(), "Stack log file Analyzing");

    try {
      process();
      makeTotalSecond();
    } finally {
      if (m_workingThread_writer != null) {
        try {
          m_workingThread_writer.close();
        } catch (Exception e) {
        }
      }

      m_progressBarWindow.close();
    }

    if (m_filter != null) {
      String stackFilename = m_stackFile.getFilename();
      String ext =
          new StringBuilder(20)
              .append('_')
              .append(WORKINGTHREAD_EXT)
              .append('.')
              .append(EXTENSION)
              .toString();
      int index = stackFilename.indexOf(ext);
      if (index > 0) {
        stackFilename =
            new StringBuilder(200)
                .append(stackFilename.substring(0, index))
                .append('.')
                .append(m_filter)
                .toString();
        m_stackFile.setFilename(stackFilename);
      }
    }

    saveAll();
    clearAll();
    m_stackFile = null;
  }
Esempio 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;
  }