Esempio n. 1
0
  protected void reload() {
    table.removeAll();
    MapPack mp = ServerDataProxy.getThreadDetail(threadid, serverId);

    String[] names = scouter.util.SortUtil.sort_string(mp.keys(), mp.size());
    for (int i = 0, j = 0; i < names.length; i++) {
      String key = names[i];
      Value value = mp.get(key);
      if ("Stack Trace".equals(key)) {
        stacktrace.setText(CastUtil.cString(value));
        //				JavaColor.setJavaCode(stacktrace, new Cast(value).cString());
        continue;
      }
      String text = null;
      TableItem ti = new TableItem(table, SWT.NONE, j++);
      if (value instanceof TextValue) {
        text = CastUtil.cString(value);
        ti.setText(0, key);
        ti.setText(1, text);
      } else {
        if (value instanceof DecimalValue) {
          text = FormatUtil.print(value, "#,##0");
        } else if (value instanceof DoubleValue || value instanceof FloatValue) {
          text = FormatUtil.print(value, "#,##0.0##");
        }
        ti.setText(new String[] {key, text});
      }
    }
  }
Esempio n. 2
0
  public static StepWrapper[] getProfileData(XLogPack pack, File xLogDir, boolean isSummary) {
    String profilePath;
    if (!isSummary) {
      profilePath = xLogDir.getAbsolutePath() + "/" + profileFileName;
    } else {
      profilePath = xLogDir.getAbsolutePath() + "/" + profileSummaryFileName;
    }
    File profileFile = new File(profilePath);
    if (!profileFile.canRead()) {
      return null;
    }
    byte[] profb = new byte[(int) profileFile.length()];

    try {
      FileInputStream profileInputStream = new FileInputStream(profileFile);
      profileInputStream.read(profb);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    Step[] profile = null;
    try {
      profile = Step.toObjects(profb);
    } catch (IOException e) {
      e.printStackTrace();
    }

    profile = SortUtil.sort(profile);

    HashMap<Integer, Integer> indent = new HashMap<Integer, Integer>();
    long stime = pack.endTime - pack.elapsed;

    StepWrapper[] profWr = new StepWrapper[profile.length];

    int expectedIdx = 0;

    int sSummaryIdx = 1;

    for (int inx = 0; inx < profile.length; inx++) {

      if (profile[inx] instanceof StepSingle) {
        StepSingle sSingle = (StepSingle) profile[inx];
        int space = 0;
        if (indent.containsKey(sSingle.parent)) {
          space = indent.get(sSingle.parent) + 2;
        }
        indent.put(sSingle.index, space);

        profWr[inx] =
            new StepWrapper(sSingle.start_time + stime, sSingle.start_cpu, space, -1, sSingle);

        expectedIdx = sSingle.index + 1;
      } else if (profile[inx] instanceof StepSummary) {
        StepSummary sSummary = (StepSummary) profile[inx];
        profWr[inx] = new StepWrapper(-1, -1, -1, sSummaryIdx, sSummary);
        sSummaryIdx++;
      }
    }

    return profWr;
  }