Exemple #1
0
  public void open(int serverId) {
    close();
    Server server = ServerManager.getInstance().getServer(serverId);
    if (server == null) {
      return;
    }
    try {
      socket = new Socket();
      ///
      socket.setKeepAlive(true);
      socket.setTcpNoDelay(true);
      // socket.setSoLinger(true, 0);
      ///
      socket.connect(new InetSocketAddress(server.getIp(), server.getPort()), 3000);
      socket.setTcpNoDelay(true);
      socket.setSoTimeout(4000);
      in = new DataInputX(new BufferedInputStream(socket.getInputStream()));
      out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream()));

      // *************//
      out.writeInt(NetCafe.TCP_CLIENT);
      out.flush();
      // *************//
      if (server.isConnected() == false) {
        System.out.println("Success to connect " + server.getIp() + ":" + server.getPort());
        server.setConnected(true);
      }
    } catch (Throwable t) {
      t.printStackTrace();
      close();
      server.setConnected(false);
    }
  }
 public void setInput(long stime, long etime) {
   this.stime = stime;
   this.etime = etime;
   try {
     setViewTab(objType, counter1, serverId);
     Server server = ServerManager.getInstance().getServer(serverId);
     CounterEngine ce = server.getCounterEngine();
     String counterName = ce.getCounterDisplayName(objType, counter1);
     desc =
         "ⓢ"
             + server.getName()
             + " | (Past All) "
             + counterName
             + "("
             + ce.getCounterUnit(objType, counter1)
             + ") "
             + DateUtil.format(stime, "yyyyMMdd HH:mm:ss")
             + " ~ "
             + DateUtil.format(etime, "HH:mm:ss");
     this.xyGraph.primaryXAxis.setRange(stime, etime);
   } catch (Exception e1) {
     e1.printStackTrace();
   }
   Set<Integer> keySet = dataMap.keySet();
   for (Integer key : keySet) {
     TracePair tp = dataMap.get(key);
     xyGraph.removeTrace(tp.totalTrace);
     xyGraph.removeTrace(tp.activeTrace);
   }
   dataMap.clear();
   load();
 }
 public void createPartControl(Composite parent) {
   Server server = ServerManager.getInstance().getServer(serverId);
   if (server != null)
     displayObjType = server.getCounterEngine().getDisplayNameObjectType(objType);
   this.setPartName(displayObjType + " - Service[Throughput]");
   super.createPartControl(parent);
 }
Exemple #4
0
 protected IStatus run(IProgressMonitor monitor) {
   monitor.beginTask("Find " + Hexa32.toString32(xlogData.p.txid), IProgressMonitor.UNKNOWN);
   final LongKeyLinkedMap<XLogData> xlogMap = new LongKeyLinkedMap<XLogData>();
   xlogMap.put(xlogData.p.txid, xlogData);
   long callerId = xlogData.p.caller;
   boolean found = true;
   while (found && callerId != 0) {
     found = false;
     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("txid", callerId);
         Pack p = tcp.getSingle(RequestCmd.XLOG_READ_BY_TXID, param);
         if (p != null) {
           XLogPack xlog = XLogUtil.toXLogPack(p);
           XLogData d = new XLogData(xlog, serverId);
           d.objName = TextProxy.object.getLoadText(date, d.p.objHash, serverId);
           xlogMap.put(xlog.txid, d);
           callerId = xlog.caller;
           found = true;
           break;
         }
       } catch (Throwable th) {
         ConsoleProxy.errorSafe(th.toString());
         callerId = 0;
       } finally {
         TcpProxy.putTcpProxy(tcp);
       }
     }
   }
   ExUtil.exec(
       viewer.getGraphControl(),
       new Runnable() {
         public void run() {
           viewer.setInput(xlogMap);
         }
       });
   return Status.OK_STATUS;
 }
  public void setInput(
      String date,
      long startTime,
      long endTime,
      int objHash,
      String objName,
      String objType,
      String counter,
      int serverId)
      throws Exception {
    this.date = date;
    this.objHash = objHash;
    this.objName = objName;
    this.objType = objType;
    this.counter = counter;
    this.serverId = serverId;

    this.startTime = startTime;
    this.endTime = endTime;

    String date2 = date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
    Server server = ServerManager.getInstance().getServer(serverId);
    String svrName = "";
    String counterDisplay = "";
    String counterUnit = "";
    if (server != null) {
      svrName = server.getName();
      counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter);
      counterUnit = server.getCounterEngine().getCounterUnit(objType, counter);
    }
    desc =
        "ⓢ"
            + svrName
            + " | (Pasttime) ["
            + objName
            + "]["
            + date2
            + "] "
            + counterDisplay
            + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : "");
    setViewTab(objType, counter, serverId);

    if (this.trace != null) {
      this.trace.setName(objName);
      this.trace.setTraceColor(AgentColorManager.getInstance().assignColor(objType, objHash));
      ChartUtil.addSolidLine(
          xyGraph, provider, AgentColorManager.getInstance().assignColor(objType, objHash));
    }

    ExUtil.asyncRun(
        new Runnable() {
          public void run() {
            load();
          }
        });
  }
  public void setInput(String sDate, String eDate, String objType, String counter, int serverId)
      throws Exception {
    this.sDate = sDate;
    this.eDate = eDate;
    this.objType = objType;
    this.counter = counter;
    this.mode = CounterUtil.getTotalMode(objType, counter);
    this.serverId = serverId;
    setViewTab(objType, counter, serverId, false);

    Server server = ServerManager.getInstance().getServer(serverId);
    String counterUnit = "";
    String counterDisplay = "";
    if (server != null) {
      counterUnit = server.getCounterEngine().getCounterUnit(objType, counter);
      counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter);
      desc =
          "(Period) ["
              + sDate.substring(0, 4)
              + "-"
              + sDate.substring(4, 6)
              + "-"
              + sDate.substring(6, 8)
              + " ~ "
              + eDate.substring(0, 4)
              + "-"
              + eDate.substring(4, 6)
              + "-"
              + eDate.substring(6, 8)
              + "] Total "
              + counterDisplay;
    }
    serverText.setText(
        "ⓢ"
            + ((server == null) ? "?" : server.getName())
            + " |"
            + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : ""));

    stime = DateUtil.getTime(sDate, "yyyyMMdd");
    etime = DateUtil.getTime(eDate, "yyyyMMdd") + DateUtil.MILLIS_PER_DAY;
    this.xyGraph.primaryXAxis.setRange(stime, etime);

    sDateText.setText(DateUtil.format(stime, "yyyy-MM-dd"));
    eDateText.setText(DateUtil.format(etime - 1, "yyyy-MM-dd"));

    buffer = (int) ((etime - stime) / DateUtil.MILLIS_PER_FIVE_MINUTE);
    traceDataProvider.setBufferSize(buffer);

    ExUtil.asyncRun(
        new Runnable() {
          public void run() {
            load();
          }
        });
  }
Exemple #7
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;
 }
  private void duplicateView() {
    Server server = ServerManager.getInstance().getServer(serverId);
    String counterDisplay = "";
    if (server != null) {
      counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter);
    }

    Action duplicateAction =
        new OpenPastLongDateTotalAction(
            window,
            counterDisplay,
            objType,
            counter,
            Images.getCounterImage(objType, counter, serverId),
            sDate,
            eDate,
            serverId);
    duplicateAction.run();
  }
  private void checkDir() {
    String service = TextProxy.service.getText(xLogData.p.service).replaceAll("/", "_");
    if (service.length() > 80) {
      service = service.substring(0, 80);
    }
    String serverName = ServerManager.getInstance().getServer(serverId).getName();
    String dir =
        RCPUtil.getWorkingDirectory()
            + "/"
            + serverName
            + "/"
            + yyyymmdd
            + xLogData.objName
            + "/"
            + xLogDirName;

    File rootDir = new File(dir);
    File[] fs = rootDir.listFiles();
    if (fs != null) {
      workingDir =
          dir
              + "/"
              + "["
              + String.format("%03d-", (fs.length + 1))
              + DateUtil.format(date, "HHmmss")
              + "]"
              + txid
              + "_"
              + service
              + "/";
      for (File f : fs) {
        String dirPath = f.getAbsolutePath();
        if (f.isDirectory() && dirPath != null && dirPath.indexOf(txid + "_" + service) != -1) {
          workingDir = dirPath + "/";
          break;
        }
      }
    } else {
      workingDir =
          dir + "/" + "[001-" + DateUtil.format(date, "HHmmss") + "]" + txid + "_" + service + "/";
    }
  }
public class CounterTodayGroupCountView extends ScouterViewPart implements Refreshable {
  public static final String ID = CounterTodayGroupCountView.class.getName();

  protected RefreshThread thread;
  private String grpName;
  private String objType;
  private String counter;
  private String mode;
  private Server defaultServer = ServerManager.getInstance().getDefaultServer();
  protected XYGraph xyGraph;
  IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  private Map<Integer, ListValue> serverObjMap = new HashMap<Integer, ListValue>();
  protected CircularBufferDataProvider traceDataProvider;
  protected Trace trace;
  protected FigureCanvas canvas;
  int xAxisUnitWidth;
  int lineWidth;

  public void init(IViewSite site) throws PartInitException {
    super.init(site);
    String secId = site.getSecondaryId();
    statusMessage = secId;
    String[] datas = secId.split("&");
    grpName = datas[0];
    objType = datas[1];
    counter = datas[2];
  }

  public void createPartControl(Composite parent) {
    String displayCounter =
        defaultServer.getCounterEngine().getCounterDisplayName(objType, counter);
    String objectDisplay = defaultServer.getCounterEngine().getDisplayNameObjectType(objType);
    setPartName(grpName + " - " + displayCounter);
    mode = CounterUtil.getTotalMode(objType, counter);
    desc = grpName + " | (Today) [" + objectDisplay + "] " + displayCounter;
    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    parent.setLayout(layout);
    parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE));
    parent.setBackgroundMode(SWT.INHERIT_FORCE);
    canvas = new FigureCanvas(parent);
    canvas.setScrollBarVisibility(FigureCanvas.NEVER);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    canvas.addControlListener(
        new ControlListener() {
          boolean lock = false;

          public void controlResized(ControlEvent e) {
            org.eclipse.swt.graphics.Rectangle r = canvas.getClientArea();
            if (!lock) {
              lock = true;
              if (ChartUtil.isShowDescriptionAllowSize(r.height)) {
                CounterTodayGroupCountView.this.setContentDescription(desc);
              } else {
                CounterTodayGroupCountView.this.setContentDescription("");
              }
              r = canvas.getClientArea();
              lock = false;
            }
            if (xyGraph == null) return;
            xyGraph.setSize(r.width, r.height);
            lineWidth = r.width / 30;
            trace.setLineWidth(lineWidth);
            xAxisUnitWidth =
                xyGraph.primaryXAxis.getValuePosition(1, false)
                    - xyGraph.primaryXAxis.getValuePosition(0, false);
          }

          public void controlMoved(ControlEvent e) {}
        });

    canvas.addMouseListener(
        new MouseListener() {
          public void mouseUp(MouseEvent e) {
            writedValueMode = false;
            canvas.redraw();
          }

          public void mouseDown(MouseEvent e) {
            writeValue(e.x);
          }

          public void mouseDoubleClick(MouseEvent e) {}
        });

    xyGraph = new XYGraph();
    xyGraph.setShowLegend(false);

    canvas.setContents(xyGraph);

    xyGraph.primaryXAxis.setDateEnabled(false);
    xyGraph.primaryXAxis.setShowMajorGrid(false);

    xyGraph.primaryYAxis.setAutoScale(true);
    xyGraph.primaryYAxis.setShowMajorGrid(true);

    xyGraph.primaryXAxis.setTitle("");
    xyGraph.primaryYAxis.setTitle("");

    traceDataProvider = new CircularBufferDataProvider(true);
    traceDataProvider.setBufferSize(24);
    traceDataProvider.setCurrentXDataArray(new double[] {});
    traceDataProvider.setCurrentYDataArray(new double[] {});

    this.xyGraph.primaryXAxis.setRange(0, 24);

    // create the trace
    trace = new Trace("TotalCount", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider);

    // set trace property
    trace.setPointStyle(PointStyle.NONE);
    // trace.getXAxis().setFormatPattern("HH");
    trace.getYAxis().setFormatPattern("#,##0");

    trace.setLineWidth(15);
    trace.setTraceType(TraceType.BAR);
    trace.setAreaAlpha(200);
    trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR);

    // add the trace to xyGraph
    xyGraph.addTrace(trace);

    thread = new RefreshThread(this, 5000);
    thread.start();
    thread.setName(
        this.toString()
            + " - "
            + "objType:"
            + objType
            + ", counter:"
            + counter
            + ", grpName:"
            + grpName);
  }

  private boolean isActive = false;

  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();
          }
        });
  }

  boolean writedValueMode = false;
  int lastWritedX;

  public void writeValue(int ex) {
    double x = xyGraph.primaryXAxis.getPositionValue(ex, false);
    int index = (int) x;
    if (index < 0) {
      return;
    }
    Sample sample = (Sample) trace.getDataProvider().getSample(index);
    if (sample != null) {
      double y = sample.getYValue();
      int height = xyGraph.primaryYAxis.getValuePosition(y, false);
      int startX = xyGraph.primaryXAxis.getValuePosition((int) x, false);
      GC gc = new GC(canvas);
      Font font = new Font(null, "Verdana", 10, SWT.BOLD);
      gc.setFont(font);
      String value = FormatUtil.print(y, "#,###");
      Point textSize = gc.textExtent(value);
      gc.drawText(value, startX + (xAxisUnitWidth - textSize.x) / 2, height - 20, true);
      int ground = xyGraph.primaryYAxis.getValuePosition(0, false);
      gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
      gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_MAGENTA));
      gc.drawRectangle(
          startX + (xAxisUnitWidth - lineWidth) / 2, height, lineWidth, ground - height);
      gc.fillRectangle(
          startX + (xAxisUnitWidth - lineWidth) / 2, height, lineWidth, ground - height);
      gc.dispose();
      writedValueMode = true;
      lastWritedX = ex;
    }
  }

  public void setFocus() {
    statusMessage =
        desc
            + " - setInput(String objType:"
            + objType
            + ", String counter:"
            + counter
            + ", int grpName:"
            + grpName
            + ")";
    super.setFocus();
  }

  @Override
  public void dispose() {
    super.dispose();
    if (this.thread != null) {
      this.thread.shutdown();
    }
  }
}
  public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    parent.setLayout(layout);
    parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE));
    parent.setBackgroundMode(SWT.INHERIT_FORCE);

    window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    man = getViewSite().getActionBars().getToolBarManager();

    man.add(
        new Action("Reload", ImageUtil.getImageDescriptor(Images.refresh)) {
          public void run() {
            yesterday = null;
            yesterdayDataProvider.clearTrace();
            traceDataProvider.clearTrace();
            thread.interrupt();
          }
        });

    canvas = new FigureCanvas(parent);
    canvas.setScrollBarVisibility(FigureCanvas.NEVER);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));

    canvas.addControlListener(
        new ControlListener() {
          boolean lock = false;

          public void controlResized(ControlEvent e) {
            org.eclipse.swt.graphics.Rectangle r = canvas.getClientArea();
            if (!lock) {
              lock = true;
              if (ChartUtil.isShowDescriptionAllowSize(r.height)) {
                CounterTodayTotalView.this.setContentDescription(desc);
              } else {
                CounterTodayTotalView.this.setContentDescription("");
              }
              r = canvas.getClientArea();
              lock = false;
            }
            xyGraph.setSize(r.width, r.height);
          }

          public void controlMoved(ControlEvent e) {}
        });

    xyGraph = new XYGraph();
    xyGraph.setShowLegend(false);
    // xyGraph.setShowTitle(false);

    canvas.setContents(xyGraph);

    xyGraph.primaryXAxis.setDateEnabled(true);
    xyGraph.primaryXAxis.setShowMajorGrid(true);

    xyGraph.primaryYAxis.setAutoScale(true);
    xyGraph.primaryYAxis.setShowMajorGrid(true);

    xyGraph.primaryXAxis.setTitle("");
    xyGraph.primaryYAxis.setTitle("");

    ScouterUtil.addShowTotalValueListener(canvas, xyGraph);

    createDataProvider();
    createYesterdayProvider();

    canvas.addKeyListener(
        new KeyListener() {
          public void keyReleased(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.F5) {
              yesterday = null;
              yesterdayDataProvider.clearTrace();
              traceDataProvider.clearTrace();
              thread.interrupt();
            }
          }
        });

    String date = DateUtil.yyyymmdd(TimeUtil.getCurrentTime(serverId));

    Server server = ServerManager.getInstance().getServer(serverId);
    String svrName = "";
    String counterDisplay = "";
    String counterUnit = "";
    if (server != null) {
      svrName = server.getName();
      counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter);
      counterUnit = server.getCounterEngine().getCounterUnit(objType, counter);
    }
    desc =
        "ⓢ"
            + svrName
            + " | (Today) ["
            + date.substring(0, 4)
            + "-"
            + date.substring(4, 6)
            + "-"
            + date.substring(6, 8)
            + "] Total "
            + counterDisplay
            + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : "");
    try {
      setViewTab(objType, counter, serverId);
    } catch (Exception e1) {
      e1.printStackTrace();
    }

    thread = new RefreshThread(this, 10000);
    thread.setName(
        this.toString()
            + " - "
            + "objType:"
            + objType
            + ", counter:"
            + counter
            + ", serverId:"
            + serverId);
    thread.start();
  }
  public void createPartControl(Composite parent) {
    Server server = ServerManager.getInstance().getServer(serverId);
    this.setPartName("DB Activity[" + server.getName() + "]");
    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    parent.setLayout(layout);
    parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE));
    parent.setBackgroundMode(SWT.INHERIT_FORCE);
    canvas = new FigureCanvas(parent);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    canvas.setScrollBarVisibility(FigureCanvas.NEVER);
    canvas.addControlListener(
        new ControlListener() {
          public void controlMoved(ControlEvent arg0) {}

          public void controlResized(ControlEvent arg0) {
            Rectangle r = canvas.getClientArea();
            xyGraph.setSize(r.width, r.height);
          }
        });

    xyGraph = new XYGraph();
    xyGraph.setShowLegend(true);
    xyGraph.setShowTitle(false);
    canvas.setContents(xyGraph);

    xyGraph.primaryXAxis.setDateEnabled(true);
    xyGraph.primaryXAxis.setShowMajorGrid(true);
    xyGraph.primaryYAxis.setAutoScale(true);
    xyGraph.primaryYAxis.setShowMajorGrid(true);
    xyGraph.primaryXAxis.setFormatPattern("HH:mm:ss");
    xyGraph.primaryYAxis.setFormatPattern("#,##0");

    xyGraph.primaryXAxis.setTitle("");
    xyGraph.primaryYAxis.setTitle("");

    CircularBufferDataProvider callProvider = new CircularBufferDataProvider(true);
    callProvider.setBufferSize(BUFFER_SIZE);
    callProvider.setCurrentXDataArray(new double[] {});
    callProvider.setCurrentYDataArray(new double[] {});
    callTrace = new Trace("Call (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, callProvider);
    callTrace.setPointStyle(PointStyle.NONE);
    callTrace.setTraceType(TraceType.AREA);
    callTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    callTrace.setAreaAlpha(255);
    callTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_BLUE));
    xyGraph.addTrace(callTrace);

    CircularBufferDataProvider selectProvider = new CircularBufferDataProvider(true);
    selectProvider.setBufferSize(BUFFER_SIZE);
    selectProvider.setCurrentXDataArray(new double[] {});
    selectProvider.setCurrentYDataArray(new double[] {});
    selectTrace =
        new Trace("Select (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, selectProvider);
    selectTrace.setPointStyle(PointStyle.NONE);
    selectTrace.setTraceType(TraceType.AREA);
    selectTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    selectTrace.setAreaAlpha(255);
    selectTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_CYAN));
    xyGraph.addTrace(selectTrace);

    CircularBufferDataProvider insertProvider = new CircularBufferDataProvider(true);
    insertProvider.setBufferSize(BUFFER_SIZE);
    insertProvider.setCurrentXDataArray(new double[] {});
    insertProvider.setCurrentYDataArray(new double[] {});
    insertTrace =
        new Trace("Insert (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, insertProvider);
    insertTrace.setPointStyle(PointStyle.NONE);
    insertTrace.setTraceType(TraceType.AREA);
    insertTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    insertTrace.setAreaAlpha(255);
    insertTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_GRAY));
    xyGraph.addTrace(insertTrace);

    CircularBufferDataProvider updateProvider = new CircularBufferDataProvider(true);
    updateProvider.setBufferSize(BUFFER_SIZE);
    updateProvider.setCurrentXDataArray(new double[] {});
    updateProvider.setCurrentYDataArray(new double[] {});
    updateTrace =
        new Trace("Update (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, updateProvider);
    updateTrace.setPointStyle(PointStyle.NONE);
    updateTrace.setTraceType(TraceType.AREA);
    updateTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    updateTrace.setAreaAlpha(255);
    updateTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_GREEN));
    xyGraph.addTrace(updateTrace);

    CircularBufferDataProvider deleteProvider = new CircularBufferDataProvider(true);
    deleteProvider.setBufferSize(BUFFER_SIZE);
    deleteProvider.setCurrentXDataArray(new double[] {});
    deleteProvider.setCurrentYDataArray(new double[] {});
    deleteTrace =
        new Trace("Delete (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, deleteProvider);
    deleteTrace.setPointStyle(PointStyle.NONE);
    deleteTrace.setTraceType(TraceType.AREA);
    deleteTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    deleteTrace.setAreaAlpha(255);
    deleteTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_MAGENTA));
    xyGraph.addTrace(deleteTrace);

    ScouterUtil.addHorizontalRangeListener(
        xyGraph.getPlotArea(), new OpenDigestTableAction(serverId), true);

    IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
    Action fixRangeAct =
        new Action("Pin Range", IAction.AS_CHECK_BOX) {
          public void run() {
            fixRange = isChecked();
          }
        };
    fixRangeAct.setImageDescriptor(ImageUtil.getImageDescriptor(Images.pin));
    man.add(fixRangeAct);

    thread = new RefreshThread(this, REFRESH_INTERVAL);
    thread.start();
  }
  private void load() {
    CounterEngine counterEngine =
        ServerManager.getInstance().getServer(serverId).getCounterEngine();
    new Job("Load " + counterEngine.getCounterDisplayName(objType, counter1)) {
      protected IStatus run(IProgressMonitor monitor) {
        final Map<Integer, MapPack> valueMap1 = new HashMap<Integer, MapPack>();
        final Map<Integer, MapPack> valueMap2 = new HashMap<Integer, MapPack>();
        TcpProxy tcp = TcpProxy.getTcpProxy(serverId);
        try {
          MapPack param = new MapPack();
          param.put("stime", stime);
          param.put("etime", etime);
          param.put("objType", objType);
          param.put("counter", counter1);

          tcp.process(
              RequestCmd.COUNTER_PAST_TIME_ALL,
              param,
              new INetReader() {
                public void process(DataInputX in) throws IOException {
                  MapPack mpack = (MapPack) in.readPack();
                  int objHash = mpack.getInt("objHash");
                  valueMap1.put(objHash, mpack);
                };
              });

          param.put("counter", counter2);

          tcp.process(
              RequestCmd.COUNTER_PAST_TIME_ALL,
              param,
              new INetReader() {
                public void process(DataInputX in) throws IOException {
                  MapPack mpack = (MapPack) in.readPack();
                  int objHash = mpack.getInt("objHash");
                  valueMap2.put(objHash, mpack);
                };
              });

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

        ExUtil.exec(
            canvas,
            new Runnable() {
              public void run() {
                double max = 0;
                for (MapPack mpack : valueMap1.values()) {
                  try {
                    int objHash = mpack.getInt("objHash");
                    ListValue time = mpack.getList("time");
                    ListValue value1 = mpack.getList("value");
                    ListValue value2 = valueMap2.get(objHash).getList("value");

                    TracePair tp =
                        getTracePair(
                            objType,
                            objHash,
                            (int) ((etime - stime) / (DateUtil.MILLIS_PER_SECOND * 2)));
                    CircularBufferDataProvider maxProvider =
                        (CircularBufferDataProvider) tp.totalTrace.getDataProvider();
                    CircularBufferDataProvider valueProvider =
                        (CircularBufferDataProvider) tp.activeTrace.getDataProvider();
                    maxProvider.clearTrace();
                    valueProvider.clearTrace();
                    for (int i = 0; time != null && i < time.size(); i++) {
                      long x = time.getLong(i);
                      maxProvider.addSample(new Sample(x, CastUtil.cdouble(value1.get(i))));
                      valueProvider.addSample(new Sample(x, CastUtil.cdouble(value2.get(i))));
                    }
                    max = Math.max(ChartUtil.getMax(maxProvider.iterator()), max);
                  } catch (Throwable th) {
                  }
                }
                if (CounterUtil.isPercentValue(objType, counter1)) {
                  xyGraph.primaryYAxis.setRange(0, 100);
                } else {
                  xyGraph.primaryYAxis.setRange(0, max);
                }
                redraw();
              }
            });

        return Status.OK_STATUS;
      }
    }.schedule();
  }
 public void createPartControl(Composite parent) {
   this.setPartName(
       "DataManagement[" + ServerManager.getInstance().getServer(serverId).getName() + "]");
   parent.setLayout(new GridLayout(1, true));
   labelComp = new Composite(parent, SWT.NONE);
   labelComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
   labelComp.setLayout(new RowLayout());
   totalLabel = new Label(parent, SWT.NONE);
   totalLabel.setText("                                                ");
   Composite treeComp = new Composite(parent, SWT.BORDER);
   treeComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   tree = new Tree(treeComp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
   tree.setHeaderVisible(true);
   viewer = new TreeViewer(tree);
   tree.setLinesVisible(true);
   final TreeColumn nameColumn = new TreeColumn(tree, SWT.LEFT);
   nameColumn.setAlignment(SWT.LEFT);
   nameColumn.setText("Name");
   nameColumn.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           TreeLabelSorter sorter = (TreeLabelSorter) viewer.getComparator();
           sorter.setColumn(nameColumn);
         }
       });
   final TreeColumn sizeColumn = new TreeColumn(tree, SWT.RIGHT);
   sizeColumn.setAlignment(SWT.RIGHT);
   sizeColumn.setText("Size");
   sizeColumn.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           TreeLabelSorter sorter = (TreeLabelSorter) viewer.getComparator();
           sorter.setColumn(sizeColumn);
         }
       });
   final TreeColumn timeColumn = new TreeColumn(tree, SWT.CENTER);
   timeColumn.setAlignment(SWT.CENTER);
   timeColumn.setText("Last Modified");
   timeColumn.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           TreeLabelSorter sorter = (TreeLabelSorter) viewer.getComparator();
           sorter.setColumn(timeColumn);
         }
       });
   TreeColumnLayout layout = new TreeColumnLayout();
   treeComp.setLayout(layout);
   layout.setColumnData(nameColumn, new ColumnWeightData(30));
   layout.setColumnData(sizeColumn, new ColumnWeightData(20));
   layout.setColumnData(timeColumn, new ColumnWeightData(20));
   viewer.setContentProvider(new DirContentProvider());
   viewer.setLabelProvider(new LockLabelProvider());
   viewer.setComparator(
       new TreeLabelSorter(viewer)
           .setCustomCompare(
               new TreeLabelSorter.ICustomCompare() {
                 public int doCompare(TreeColumn col, int index, Object o1, Object o2) {
                   if (o1 instanceof DirObject && o2 instanceof DirObject) {
                     DirObject dirObj1 = (DirObject) o1;
                     DirObject dirObj2 = (DirObject) o2;
                     switch (index) {
                       case 0:
                         return dirObj1.name.compareTo(dirObj2.name);
                       case 1:
                         long gap = dirObj1.size - dirObj2.size;
                         if (gap > 0) {
                           return 1;
                         } else if (gap < 0) {
                           return -1;
                         } else {
                           return 0;
                         }
                       case 2:
                         gap = dirObj1.lastModified - dirObj2.lastModified;
                         if (gap > 0) {
                           return 1;
                         } else if (gap < 0) {
                           return -1;
                         } else {
                           return 0;
                         }
                     }
                   }
                   return 0;
                 }
               }));
   viewer.setInput(dirMap);
   IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
   man.add(
       new Action("Collapse All", ImageUtil.getImageDescriptor(Images.collapse)) {
         public void run() {
           viewer.collapseAll();
         }
       });
   man.add(new Separator());
   man.add(
       new Action("Reload", ImageUtil.getImageDescriptor(Images.refresh)) {
         public void run() {
           load();
         }
       });
   load();
   createContextMenu(
       viewer,
       new IMenuListener() {
         public void menuAboutToShow(IMenuManager manager) {
           fillTreeViewerContextMenu(manager);
         }
       });
 }