Ejemplo n.º 1
0
  private void reanalyzeStackFileInfo() {
    TreeItem item = getSelectedRootItemFromMainTree();
    if (item == null) {
      return;
    }

    StackFileInfo stackFileInfo = (StackFileInfo) item.getData();
    if (stackFileInfo == null) {
      return;
    }

    try {
      ParserConfigReader reader =
          new ParserConfigReader(stackFileInfo.getParserConfig().getConfigFilename());
      ParserConfig config = reader.read();

      StackParser.removeAllAnalyzedFile(stackFileInfo);

      processStackFile(stackFileInfo, config, null, false, true);
    } catch (RuntimeException ex) {
      closeStackFileInfo();
      throw ex;
    }
    item.removeAll();
    item.setText(stackFileInfo.toTreeInfo());
    addMainTreeSubItem(item, stackFileInfo.getStackAnalyzedInfoList());
    item.setExpanded(true);

    clearTable();
  }
Ejemplo n.º 2
0
  private ParserConfig selectAdoptiveParserConfig() {
    PreferenceManager prefManager = PreferenceManager.get();
    String configFile = prefManager.getCurrentParserConfig();
    if (m_isDefaultConfiguration) {
      configFile = XMLReader.DEFAULT_XMLCONFIG;
    }

    if (configFile == null) {
      MessageBox messageBox =
          new MessageBox(
              m_parentComposite.getShell(),
              SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.APPLICATION_MODAL);
      messageBox.setText("Check Setting selection");
      messageBox.setMessage(
          "The configuration file is not selected.\r\nDo you want to use the default configuration?");
      int result = messageBox.open();
      if (result == SWT.YES) {
        configFile = XMLReader.DEFAULT_XMLCONFIG;
      } else {
        configFile = selectCurrentParserConfig();
        if (configFile == null) {
          throw new RuntimeException("Parser config file is not selected!");
        }
      }
    }

    ParserConfigReader reader = new ParserConfigReader(configFile);
    return reader.read();
  }
Ejemplo n.º 3
0
  public void analyzeFilterStack(String inputFilter, boolean isInclude) {
    String filter = null;
    if (inputFilter == null) {
      filter = getSelectedAnalyzedFunction();
    } else {
      filter = inputFilter;
    }

    if (filter == null) return;

    StackFileInfo stackFileInfo = getSelectedStackFileInfo();
    if (stackFileInfo == null) return;

    ParserConfigReader reader =
        new ParserConfigReader(stackFileInfo.getParserConfig().getConfigFilename());
    ParserConfig config = reader.read();

    StackFileInfo filteredStackFileInfo =
        processStackFile(
            StackParser.getWorkingThreadFilename(stackFileInfo.getFilename()),
            config,
            filter,
            false,
            isInclude);
    addProcessedStack(filteredStackFileInfo);
  }
Ejemplo n.º 4
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;
  }