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});
      }
    }
  }
 private void restoreState() {
   if (memento == null) return;
   IMemento m = memento.getChild(ID);
   String objType = m.getString("objType");
   String counter = m.getString("counter");
   String sDate = CastUtil.cString(m.getString("sDate"));
   String eDate = CastUtil.cString(m.getString("eDate"));
   int serverId = CastUtil.cint(m.getInteger("serverId"));
   try {
     setInput(sDate, eDate, objType, counter, serverId);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  private void restoreState() {
    if (memento == null) return;
    IMemento m = memento.getChild(ID);

    String date = m.getString("date");
    int objHash = CastUtil.cint(m.getInteger("objHash"));
    String objName = m.getString("objName");
    String counter = m.getString("counter");
    String objType = m.getString("objType");
    int serverId = CastUtil.cint(m.getInteger("serverId"));
    try {
      setInput(date, startTime, endTime, objHash, objName, objType, counter, serverId);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 public void init(IViewSite site) throws PartInitException {
   super.init(site);
   String secId = site.getSecondaryId();
   String[] ids = StringUtil.split(secId, "&");
   this.serverId = CastUtil.cint(ids[0]);
   this.objType = ids[1];
   this.counter = ids[2];
   this.mode = CounterUtil.getTotalMode(objType, counter);
 }
Beispiel #5
0
 @Counter
 public void process(CounterBasket pw) {
   if (CounterConstants.TOMCAT.equals(ObjTypeDetector.objType) == false) {
     return;
   }
   getMBeanServer();
   if ((collectCnt <= 40 && collectCnt % 5 == 0) || ObjTypeDetector.dirtyConfig) {
     if (ObjTypeDetector.dirtyConfig) {
       AgentHeartBeat.clearSubObjects();
       ObjTypeDetector.dirtyConfig = false;
     }
     getContextList();
   }
   collectCnt++;
   for (CtxObj ctx : ctxList) {
     if (ctx.valueType == ValueEnum.DECIMAL) {
       try {
         MeterKey key = new MeterKey(ctx.mbeanHash, ctx.counter);
         long v = CastUtil.clong(server.getAttribute(ctx.mbean, ctx.attrName));
         if (deltas.contains(ctx.counter)) {
           v = getDelta(key, v);
           MeterResource meter = getMeter(key);
           meter.add(v);
           v = (long) meter.getSum(60);
           long sum = (long) meter.getSum(300) / 5;
           pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, new DecimalValue(v));
           pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, new DecimalValue(sum));
         } else {
           MeterResource meter = getMeter(key);
           meter.add(v);
           double d = meter.getAvg(30);
           double avg = meter.getAvg(300);
           FloatValue value = new FloatValue((float) d);
           FloatValue avgValue = new FloatValue((float) avg);
           pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, value);
           pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, avgValue);
         }
       } catch (Exception e) {
         errors.add(ctx.attrName);
         collectCnt = 0;
         Logger.println("A902", e);
       }
     }
   }
   // long cpu2 = SysJMX.getCurrentThreadCPU();
 }
 public void init(IViewSite site) throws PartInitException {
   super.init(site);
   String secId = site.getSecondaryId();
   serverId = CastUtil.cint(secId);
 }
Beispiel #7
0
 // This should be called background thread.
 public static List<String> loadTagString(
     int serverId, String date, List<Value> vList, String tagName) {
   List<String> resultList = new ArrayList<String>();
   if (vList.size() == 0) return resultList;
   Value sample = vList.get(0);
   switch (sample.getValueType()) {
     case ValueEnum.TEXT_HASH:
       ListValue lv = new ListValue();
       for (Value v : vList) {
         lv.add(CastUtil.cint(v.toJavaObject()));
       }
       if (tagName.equals(TagConstants.NAME_OBJECT)) {
         TextProxy.object.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.object.getText(lv.getInt(i)));
         }
       } else if (tagName.equals(TagConstants.NAME_SERVICE)
           || tagName.equals(TagConstants.NAME_SERVICE_ELAPSED)
           || tagName.equals(TagConstants.NAME_SERVICE_BYTES)
           || tagName.equals(TagConstants.NAME_SERVICE_ERRORS)) {
         TextProxy.service.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.service.getText(lv.getInt(i)));
         }
       } else if (tagName.equals(TagConstants.NAME_USER_AGENT)) {
         TextProxy.userAgent.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.userAgent.getText(lv.getInt(i)));
         }
       } else if (tagName.equals(TagConstants.NAME_GROUP)) {
         TextProxy.group.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.group.getText(lv.getInt(i)));
         }
       } else if (tagName.equals(TagConstants.NAME_CITY)) {
         TextProxy.city.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.city.getText(lv.getInt(i)));
         }
       } else if (tagName.equals(TagConstants.NAME_REFERER)) {
         TextProxy.referer.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.referer.getText(lv.getInt(i)));
         }
       } else if (tagName.equals(TagConstants.NAME_ERROR)) {
         TextProxy.error.load(date, lv, serverId);
         for (int i = 0; i < lv.size(); i++) {
           resultList.add(TextProxy.error.getText(lv.getInt(i)));
         }
       }
       break;
     case ValueEnum.DECIMAL:
       if (tagName.equals(TagConstants.NAME_LEVEL)) {
         for (Value v : vList) {
           resultList.add(AlertLevel.getName((byte) ((DecimalValue) v).value));
         }
       } else {
         for (Value v : vList) {
           resultList.add(CastUtil.cString(v.toJavaObject()));
         }
       }
       break;
     case ValueEnum.IP4ADDR:
       for (Value v : vList) {
         resultList.add(v.toString());
       }
       break;
     case ValueEnum.TEXT:
       for (Value v : vList) {
         resultList.add(v.toString());
       }
       break;
     default:
       for (Value v : vList) {
         resultList.add(v.toString());
       }
       break;
   }
   return resultList;
 }