private void load() {
    final ArrayList<Pack> values = new ArrayList<Pack>();
    TcpProxy tcp = TcpProxy.getTcpProxy(serverId);
    try {
      MapPack param = new MapPack();
      param.put("sDate", sDate);
      param.put("eDate", eDate);
      param.put("objType", objType);
      param.put("counter", counter);

      tcp.process(
          RequestCmd.COUNTER_PAST_LONGDATE_ALL,
          param,
          new INetReader() {
            public void process(DataInputX in) throws IOException {
              Pack pack = in.readPack();
              values.add(pack);
            };
          });

    } catch (Throwable t) {
      ConsoleProxy.errorSafe(t.toString());
    } finally {
      TcpProxy.putTcpProxy(tcp);
    }

    final Map<Long, Double> valueMap =
        ScouterUtil.getLoadTotalMap(counter, values, mode, TimeTypeEnum.FIVE_MIN);

    ExUtil.exec(
        this.canvas,
        new Runnable() {
          public void run() {
            try {
              traceDataProvider.clearTrace();
              Set<Long> timeSet = valueMap.keySet();
              for (long time : timeSet) {
                traceDataProvider.addSample(
                    new Sample(CastUtil.cdouble(time), CastUtil.cdouble(valueMap.get(time))));
              }
            } catch (Throwable t) {
              ConsoleProxy.error(t.toString());
            }
            if (CounterUtil.isPercentValue(objType, counter)) {
              xyGraph.primaryYAxis.setRange(0, 100);
            } else {
              double max = ChartUtil.getMax(traceDataProvider.iterator());
              xyGraph.primaryYAxis.setRange(0, max);
            }
            redraw();
            applyBtn.setEnabled(true);
          }
        });
  }
예제 #2
0
  private void getYesterdayData(String date) {
    final ArrayList<Pack> values = new ArrayList<Pack>();
    TcpProxy tcp = TcpProxy.getTcpProxy(serverId);
    try {
      MapPack param = new MapPack();
      param.put("date", date);
      param.put("objType", objType);
      param.put("counter", counter);

      tcp.process(
          RequestCmd.COUNTER_PAST_DATE_ALL,
          param,
          new INetReader() {
            public void process(DataInputX in) throws IOException {
              Pack p = in.readPack();
              values.add(p);
            };
          });
    } catch (Throwable t) {
      t.printStackTrace();
    } finally {
      TcpProxy.putTcpProxy(tcp);
    }

    final Map<Long, Double> valueMap =
        ScouterUtil.getLoadTotalMap(counter, values, mode, TimeTypeEnum.FIVE_MIN);

    ExUtil.exec(
        this.canvas,
        new Runnable() {
          public void run() {
            yesterdayDataProvider.clearTrace();
            Set<Long> timeSet = valueMap.keySet();
            for (long time : timeSet) {
              yesterdayDataProvider.addSample(
                  new Sample(
                      CastUtil.cdouble(time + DateUtil.MILLIS_PER_DAY),
                      CastUtil.cdouble(valueMap.get(time))));
            }
            yesterdayMax = ChartUtil.getMax(yesterdayDataProvider.iterator());
          }
        });
  }
예제 #3
0
 protected IStatus run(IProgressMonitor monitor) {
   monitor.beginTask("Find " + Hexa32.toString32(gxid), IProgressMonitor.UNKNOWN);
   final LongKeyLinkedMap<Object> xlogMap = new LongKeyLinkedMap<Object>();
   Iterator<Integer> itr = ServerManager.getInstance().getOpenServerList().iterator();
   while (itr.hasNext()) {
     final int serverId = itr.next();
     monitor.subTask(ServerManager.getInstance().getServer(serverId).getName());
     TcpProxy tcp = TcpProxy.getTcpProxy(serverId);
     try {
       MapPack param = new MapPack();
       param.put("date", date);
       param.put("gxid", gxid);
       tcp.process(
           RequestCmd.XLOG_READ_BY_GXID,
           param,
           new INetReader() {
             public void process(DataInputX in) throws IOException {
               Pack p = in.readPack();
               XLogPack xlog = XLogUtil.toXLogPack(p);
               XLogData d = new XLogData(xlog, serverId);
               d.objName = TextProxy.object.getLoadText(date, d.p.objHash, d.serverId);
               xlogMap.putFirst(xlog.txid, d);
             }
           });
     } catch (Throwable th) {
       ConsoleProxy.errorSafe(th.toString());
     } finally {
       TcpProxy.putTcpProxy(tcp);
     }
   }
   ExUtil.exec(
       viewer.getGraphControl(),
       new Runnable() {
         public void run() {
           viewer.setInput(xlogMap);
         }
       });
   return Status.OK_STATUS;
 }
 public void refresh() {
   ScouterUtil.collectGroupObjcts(grpName, serverObjMap);
   isActive = false;
   Iterator<Integer> serverIds = serverObjMap.keySet().iterator();
   final List<Pack> result = new ArrayList<Pack>();
   while (serverIds.hasNext()) {
     int serverId = serverIds.next();
     TcpProxy tcp = TcpProxy.getTcpProxy(serverId);
     try {
       MapPack param = new MapPack();
       param.put("counter", counter);
       param.put("objHash", serverObjMap.get(serverId));
       tcp.process(
           RequestCmd.COUNTER_TODAY_GROUP,
           param,
           new INetReader() {
             public void process(DataInputX in) throws IOException {
               Pack p = in.readPack();
               if (p != null) {
                 result.add(p);
               }
             }
           });
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       TcpProxy.putTcpProxy(tcp);
     }
   }
   final long[] values = new long[(int) (DateUtil.MILLIS_PER_DAY / DateUtil.MILLIS_PER_HOUR)];
   if (result.size() > 0) {
     Map<Long, Double> valueMap =
         ScouterUtil.getLoadTotalMap(counter, result, mode, TimeTypeEnum.FIVE_MIN);
     Iterator<Long> itr = valueMap.keySet().iterator();
     while (itr.hasNext()) {
       long time = itr.next();
       int index = (int) (DateUtil.getDateMillis(time) / DateUtil.MILLIS_PER_HOUR);
       values[index] += valueMap.get(time);
     }
     isActive = true;
   }
   ExUtil.exec(
       this.canvas,
       new Runnable() {
         public void run() {
           if (isActive == true) {
             setActive();
           } else {
             setInactive();
             return;
           }
           double max = 0;
           traceDataProvider.clearTrace();
           for (int i = 0; i < values.length; i++) {
             traceDataProvider.addSample(
                 new Sample(CastUtil.cdouble(i) + 0.5d, CastUtil.cdouble(values[i])));
           }
           max = Math.max(ChartUtil.getMax(traceDataProvider.iterator()), max);
           if (CounterUtil.isPercentValue(objType, counter)) {
             xyGraph.primaryYAxis.setRange(0, 100);
           } else {
             xyGraph.primaryYAxis.setRange(0, max);
           }
           canvas.redraw();
           xyGraph.repaint();
         }
       });
 }
예제 #5
0
  public void refresh() {
    String date = DateUtil.yyyymmdd(TimeUtil.getCurrentTime(serverId) - DateUtil.MILLIS_PER_DAY);
    if (date.equals(yesterday) == false) {
      yesterday = date;
      getYesterdayData(date);
    }
    final ArrayList<Pack> packs = new ArrayList<Pack>();
    TcpProxy tcp = TcpProxy.getTcpProxy(serverId);
    try {
      MapPack param = new MapPack();
      param.put("objType", objType);
      param.put("counter", counter);
      param.put("mode", CounterUtil.getTotalMode(objType, counter));
      isActive = false;
      tcp.process(
          RequestCmd.COUNTER_TODAY_ALL,
          param,
          new INetReader() {
            public void process(DataInputX in) throws IOException {
              packs.add(in.readPack());
            }
          });
    } catch (Throwable t) {
      ConsoleProxy.errorSafe(t.toString());
    } finally {
      TcpProxy.putTcpProxy(tcp);
    }

    final Map<Long, Double> valueMap =
        ScouterUtil.getLoadTotalMap(counter, packs, mode, TimeTypeEnum.FIVE_MIN);
    if (valueMap.size() > 0) {
      isActive = true;
    }

    ExUtil.exec(
        this.canvas,
        new Runnable() {
          public void run() {
            if (isActive) {
              setActive();
            } else {
              setInactive();
            }
            String date = DateUtil.yyyymmdd(TimeUtil.getCurrentTime(serverId));
            try {
              long stime = DateUtil.getTime(date, "yyyyMMdd");
              long etime = stime + DateUtil.MILLIS_PER_DAY;
              xyGraph.primaryXAxis.setRange(stime, etime);
              traceDataProvider.clearTrace();
              Set<Long> timeSet = valueMap.keySet();
              for (long time : timeSet) {
                traceDataProvider.addSample(
                    new Sample(CastUtil.cdouble(time), CastUtil.cdouble(valueMap.get(time))));
              }
              if (CounterUtil.isPercentValue(objType, counter)) {
                xyGraph.primaryYAxis.setRange(0, 100);
              } else {
                double max = ChartUtil.getMax(traceDataProvider.iterator());
                max = Math.max(max, yesterdayMax);
                xyGraph.primaryYAxis.setRange(0, max);
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
            canvas.redraw();
            xyGraph.repaint();
          }
        });
  }