/*public int numTickGroups()
 {
 	return ticks.size();
 }*/
 public String[][] threadInfo() {
   ArrayList<String[]> V = new ArrayList();
   for (Iterator<CMLibrary> e = CMLib.libraries(); e.hasNext(); ) {
     CMLibrary lib = e.next();
     SupportThread thread = lib.getSupportThread();
     if (thread != null) {
       String[] S = new String[3];
       S[0] = thread.getName();
       S[1] = CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
       S[2] = thread.status;
       V.add(S);
     }
   }
   return V.toArray(new String[V.size()][]);
 }
Exemple #2
0
  public String systemReport(String itemCode) {
    long totalMOBMillis = 0;
    long totalMOBTicks = 0;
    long topMOBMillis = 0;
    long topMOBTicks = 0;
    MOB topMOBClient = null;
    for (int s = 0; s < CMLib.sessions().size(); s++) {
      Session S = CMLib.sessions().elementAt(s);
      totalMOBMillis += S.getTotalMillis();
      totalMOBTicks += S.getTotalTicks();
      if (S.getTotalMillis() > topMOBMillis) {
        topMOBMillis = S.getTotalMillis();
        topMOBTicks = S.getTotalTicks();
        topMOBClient = S.mob();
      }
    }

    if (itemCode.equalsIgnoreCase("totalMOBMillis")) return "" + totalMOBMillis;
    else if (itemCode.equalsIgnoreCase("totalMOBMillisTime"))
      return CMLib.english().returnTime(totalMOBMillis, 0);
    else if (itemCode.equalsIgnoreCase("totalMOBMillisTimePlusAverage"))
      return CMLib.english().returnTime(totalMOBMillis, totalMOBTicks);
    else if (itemCode.equalsIgnoreCase("totalMOBTicks")) return "" + totalMOBTicks;
    else if (itemCode.equalsIgnoreCase("topMOBMillis")) return "" + topMOBMillis;
    else if (itemCode.equalsIgnoreCase("topMOBMillisTime"))
      return CMLib.english().returnTime(topMOBMillis, 0);
    else if (itemCode.equalsIgnoreCase("topMOBMillisTimePlusAverage"))
      return CMLib.english().returnTime(topMOBMillis, topMOBTicks);
    else if (itemCode.equalsIgnoreCase("topMOBTicks")) return "" + topMOBTicks;
    else if (itemCode.equalsIgnoreCase("topMOBClient")) {
      if (topMOBClient != null) return topMOBClient.Name();
      return "";
    }

    int totalTickers = 0;
    long totalMillis = 0;
    long totalTicks = 0;
    int topGroupNumber = -1;
    long topGroupMillis = -1;
    long topGroupTicks = 0;
    long topObjectMillis = -1;
    long topObjectTicks = 0;
    int topObjectGroup = 0;
    Tickable topObjectClient = null;
    int num = 0;
    Tick almostTock = null;
    for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) {
      almostTock = e.next();
      totalTickers += almostTock.numTickers();
      totalMillis += almostTock.milliTotal;
      totalTicks += almostTock.tickTotal;
      if (almostTock.milliTotal > topGroupMillis) {
        topGroupMillis = almostTock.milliTotal;
        topGroupTicks = almostTock.tickTotal;
        topGroupNumber = num;
      }
      try {
        for (Iterator et = almostTock.tickers(); et.hasNext(); ) {
          TockClient C = (TockClient) et.next();
          if (C.milliTotal > topObjectMillis) {
            topObjectMillis = C.milliTotal;
            topObjectTicks = C.tickTotal;
            topObjectClient = C.clientObject;
            topObjectGroup = num;
          }
        }
      } catch (NoSuchElementException ex) {
      }
      num++;
    }
    if (itemCode.equalsIgnoreCase("freeMemory"))
      return "" + (Runtime.getRuntime().freeMemory() / 1000);
    else if (itemCode.equalsIgnoreCase("totalMemory"))
      return "" + (Runtime.getRuntime().totalMemory() / 1000);
    else if (itemCode.equalsIgnoreCase("totalTime"))
      return ""
          + CMLib.english().returnTime(System.currentTimeMillis() - CMSecurity.getStartTime(), 0);
    else if (itemCode.equalsIgnoreCase("startTime"))
      return CMLib.time().date2String(CMSecurity.getStartTime());
    else if (itemCode.equalsIgnoreCase("currentTime"))
      return CMLib.time().date2String(System.currentTimeMillis());
    else if (itemCode.equalsIgnoreCase("totalTickers")) return "" + totalTickers;
    else if (itemCode.equalsIgnoreCase("totalMillis")) return "" + totalMillis;
    else if (itemCode.equalsIgnoreCase("totalMillisTime"))
      return CMLib.english().returnTime(totalMillis, 0);
    else if (itemCode.equalsIgnoreCase("totalMillisTimePlusAverage"))
      return CMLib.english().returnTime(totalMillis, totalTicks);
    else if (itemCode.equalsIgnoreCase("totalTicks")) return "" + totalTicks;
    else if (itemCode.equalsIgnoreCase("tickgroupsize")) return "" + ticks.size();
    else if (itemCode.equalsIgnoreCase("topGroupNumber")) return "" + topGroupNumber;
    else if (itemCode.equalsIgnoreCase("topGroupMillis")) return "" + topGroupMillis;
    else if (itemCode.equalsIgnoreCase("topGroupMillisTime"))
      return CMLib.english().returnTime(topGroupMillis, 0);
    else if (itemCode.equalsIgnoreCase("topGroupMillisTimePlusAverage"))
      return CMLib.english().returnTime(topGroupMillis, topGroupTicks);
    else if (itemCode.equalsIgnoreCase("topGroupTicks")) return "" + topGroupTicks;
    else if (itemCode.equalsIgnoreCase("topObjectMillis")) return "" + topObjectMillis;
    else if (itemCode.equalsIgnoreCase("topObjectMillisTime"))
      return CMLib.english().returnTime(topObjectMillis, 0);
    else if (itemCode.equalsIgnoreCase("topObjectMillisTimePlusAverage"))
      return CMLib.english().returnTime(topObjectMillis, topObjectTicks);
    else if (itemCode.equalsIgnoreCase("topObjectTicks")) return "" + topObjectTicks;
    else if (itemCode.equalsIgnoreCase("topObjectGroup")) return "" + topObjectGroup;
    else if (itemCode.toLowerCase().startsWith("thread")) {
      int xstart = "thread".length();
      int xend = xstart;
      while ((xend < itemCode.length()) && (Character.isDigit(itemCode.charAt(xend)))) xend++;
      int threadNum = CMath.s_int(itemCode.substring(xstart, xend));
      int curThreadNum = 0;
      for (Enumeration e = CMLib.libraries(); e.hasMoreElements(); ) {
        CMLibrary lib = (CMLibrary) e.nextElement();
        ThreadEngine.SupportThread thread = lib.getSupportThread();
        if (thread != null) {
          if (curThreadNum == threadNum) {
            String instrCode = itemCode.substring(xend);
            if (instrCode.equalsIgnoreCase("miliTotal")) return "" + thread.milliTotal;
            if (instrCode.equalsIgnoreCase("milliTotal")) return "" + thread.milliTotal;
            if (instrCode.equalsIgnoreCase("status")) return "" + thread.status;
            if (instrCode.equalsIgnoreCase("name")) return "" + thread.getName();
            if (instrCode.equalsIgnoreCase("MilliTotalTime"))
              return CMLib.english().returnTime(thread.milliTotal, 0);
            if (instrCode.equalsIgnoreCase("MiliTotalTime"))
              return CMLib.english().returnTime(thread.milliTotal, 0);
            if (instrCode.equalsIgnoreCase("MilliTotalTimePlusAverage"))
              return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
            if (instrCode.equalsIgnoreCase("MiliTotalTimePlusAverage"))
              return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
            if (instrCode.equalsIgnoreCase("TickTotal")) return "" + thread.tickTotal;
            break;
          }
          curThreadNum++;
        }
      }
    }
    if (itemCode.equalsIgnoreCase("topObjectClient")) {
      if (topObjectClient != null) return topObjectClient.name();
      return "";
    }

    return "";
  }