public MapPack fetch() { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); Pack pack = null; try { MapPack param = new MapPack(); ListValue objLv = param.newList("objHash"); Map<Integer, AgentObject> agentMap = AgentModelThread.getInstance().getAgentObjectMap(); for (AgentObject p : agentMap.values()) { if (p.getObjType().equals(objType)) { objLv.add(p.getObjHash()); } } pack = tcp.getSingle(RequestCmd.REALTIME_SERVICE_GROUP, param); } catch (Throwable th) { th.printStackTrace(); } finally { TcpProxy.putTcpProxy(tcp); } MapPack m = null; if (pack != null) { m = (MapPack) pack; long time = TimeUtil.getCurrentTime(serverId); m.put("time", time); fiveMinMap.put(time, m); } return m; }
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); } }); }
public void load() { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); MapPack out = null; try { MapPack param = new MapPack(); param.put("date", date); param.put("objHash", objHash); param.put("objType", objType); param.put("counter", counter); param.put("stime", startTime); param.put("etime", endTime); out = (MapPack) tcp.getSingle(RequestCmd.COUNTER_PAST_TIME, param); if (out == null) { return; } } catch (Throwable t) { ConsoleProxy.errorSafe(t.toString()); } finally { TcpProxy.putTcpProxy(tcp); } final ListValue time = out.getList("time"); final ListValue value = out.getList("value"); ExUtil.exec( this.canvas, new Runnable() { public void run() { provider.clearTrace(); for (int i = 0; time != null && i < time.size(); i++) { long tm = CastUtil.clong(time.get(i)); double va = CastUtil.cdouble(value.get(i)); provider.addSample(new Sample(tm, va)); } xyGraph.primaryXAxis.setRange(startTime, endTime); if (CounterUtil.isPercentValue(objType, counter)) { xyGraph.primaryYAxis.setRange(0, 100); } else { xyGraph.primaryYAxis.setRange(0, ChartUtil.getMax(provider.iterator())); } canvas.redraw(); xyGraph.repaint(); } }); }
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; }
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()); } }); }
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; }
protected IStatus run(IProgressMonitor monitor) { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); try { monitor.beginTask("Delete Server Files.....", IProgressMonitor.UNKNOWN); MapPack param = new MapPack(); ListValue fileLv = param.newList("file"); for (int i = 0; i < elements.length; i++) { if (elements[i] instanceof DirObject) { DirObject obj = (DirObject) elements[i]; fileLv.add(obj.name); } } MapPack m = (MapPack) tcp.getSingle(RequestCmd.SERVER_DB_DELETE, param); monitor.done(); int size = m.getInt("size"); ConsoleProxy.infoSafe(size + " directories is deleted."); load(); } catch (Exception e) { e.printStackTrace(); } finally { TcpProxy.putTcpProxy(tcp); } 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(); } }); }
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(); } }); }
public void refresh() { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); Pack p = null; final String date = DateUtil.yyyymmdd(TimeUtil.getCurrentTime(serverId)); try { MapPack param = new MapPack(); param.put( "objHash", agentDailyProxy.getObjHashLv(date, serverId, CounterConstants.MARIA_PLUGIN)); param.put("sdate", date); param.put("edate", date); p = tcp.getSingle(RequestCmd.DB_DAILY_ACTIVITY, param); } catch (Exception e) { ConsoleProxy.errorSafe(e.toString()); } finally { TcpProxy.putTcpProxy(tcp); } if (p == null) { ExUtil.exec( canvas, new Runnable() { public void run() { setTitleImage(Images.inactive); if (fixRange == false) { DbTodayTotalActivityView.this.setContentDescription( date.substring(0, 4) + "-" + date.substring(5, 6) + "-" + date.substring(7, 8)); long stime = DateUtil.yyyymmdd(date); long etime = stime + DateUtil.MILLIS_PER_DAY - 1; xyGraph.primaryXAxis.setRange(stime, etime); } } }); } else { MapPack m = (MapPack) p; final ListValue timeLv = m.getList("time"); final ListValue callLv = m.getList("call"); final ListValue selectLv = m.getList("select"); final ListValue insertLv = m.getList("insert"); final ListValue updateLv = m.getList("update"); final ListValue deleteLv = m.getList("delete"); ExUtil.exec( canvas, new Runnable() { public void run() { setTitleImage(Images.active); CircularBufferDataProvider callProvider = (CircularBufferDataProvider) callTrace.getDataProvider(); CircularBufferDataProvider selectProvider = (CircularBufferDataProvider) selectTrace.getDataProvider(); CircularBufferDataProvider insertProvider = (CircularBufferDataProvider) insertTrace.getDataProvider(); CircularBufferDataProvider updateProvider = (CircularBufferDataProvider) updateTrace.getDataProvider(); CircularBufferDataProvider deleteProvider = (CircularBufferDataProvider) deleteTrace.getDataProvider(); callProvider.clearTrace(); selectProvider.clearTrace(); insertProvider.clearTrace(); updateProvider.clearTrace(); deleteProvider.clearTrace(); for (int i = 0; i < timeLv.size(); i++) { long time = timeLv.getLong(i); double value = deleteLv.getDouble(i); deleteProvider.addSample(new Sample(time, value)); value += updateLv.getDouble(i); updateProvider.addSample(new Sample(time, value)); value += insertLv.getDouble(i); insertProvider.addSample(new Sample(time, value)); value += selectLv.getDouble(i); selectProvider.addSample(new Sample(time, value)); value += callLv.getDouble(i); callProvider.addSample(new Sample(time, value)); } if (fixRange == false) { DbTodayTotalActivityView.this.setContentDescription( date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8)); long stime = DateUtil.yyyymmdd(date); long etime = stime + DateUtil.MILLIS_PER_DAY - 1; xyGraph.primaryXAxis.setRange(stime, etime); double max = ChartUtil.getMax(callProvider.iterator()); xyGraph.primaryYAxis.setRange(0, max); } } }); } }
public void refresh() { TcpProxy tcp = TcpProxy.getTcpProxy(serverId); Value v = null; try { MapPack param = new MapPack(); ListValue objHashLv = AgentModelThread.getInstance().getLiveObjHashLV(serverId, CounterConstants.MARIA_PLUGIN); if (objHashLv.size() > 0) { param.put("objHash", objHashLv); v = tcp.getSingleValue(RequestCmd.DB_REALTIME_ACTIVITY, param); } } catch (Exception e) { ConsoleProxy.errorSafe(e.toString()); } finally { TcpProxy.putTcpProxy(tcp); } if (v == null) { ExUtil.exec( canvas, new Runnable() { public void run() { setTitleImage(Images.inactive); long now = TimeUtil.getCurrentTime(serverId); long stime = now - TIME_RANGE; xyGraph.primaryXAxis.setRange(stime, now + 1); } }); } else { MapValue mv = (MapValue) v; final DecimalValue callValue = new DecimalValue(mv.getLong("call")); final DecimalValue selectValue = new DecimalValue(mv.getLong("select")); final DecimalValue insertValue = new DecimalValue(mv.getLong("insert")); final DecimalValue updateValue = new DecimalValue(mv.getLong("update")); final DecimalValue deleteValue = new DecimalValue(mv.getLong("delete")); ExUtil.exec( canvas, new Runnable() { public void run() { setTitleImage(Images.active); long now = TimeUtil.getCurrentTime(serverId) / REFRESH_INTERVAL * REFRESH_INTERVAL; long stime = now - TIME_RANGE; xyGraph.primaryXAxis.setRange(stime, now + 1); ValueLog valueLog = new ValueLog(); valueLog.time = now; valueLog.delete = deleteValue.value; valueLog.update = updateValue.value; valueLog.insert = insertValue.value; valueLog.select = selectValue.value; valueLog.call = callValue.value; valueLogs.add(valueLog); if (valueLogs.size() > BUFFER_SIZE) { valueLogs.removeFirst(); } if (isStackView) { updateValue.value += deleteValue.value; insertValue.value += updateValue.value; selectValue.value += insertValue.value; callValue.value += selectValue.value; } ((CircularBufferDataProvider) callTrace.getDataProvider()) .addSample(new Sample(now, callValue.value)); ((CircularBufferDataProvider) selectTrace.getDataProvider()) .addSample(new Sample(now, selectValue.value)); ((CircularBufferDataProvider) insertTrace.getDataProvider()) .addSample(new Sample(now, insertValue.value)); ((CircularBufferDataProvider) updateTrace.getDataProvider()) .addSample(new Sample(now, updateValue.value)); ((CircularBufferDataProvider) deleteTrace.getDataProvider()) .addSample(new Sample(now, deleteValue.value)); xyGraph.primaryYAxis.setRange(0, getMaxYValue()); } private double getMaxYValue() { if (isStackView) { return ChartUtil.getMax( ((CircularBufferDataProvider) callTrace.getDataProvider()).iterator()); } double value = ChartUtil.getMax( ((CircularBufferDataProvider) callTrace.getDataProvider()).iterator()); value = Math.max( value, ChartUtil.getMax( ((CircularBufferDataProvider) selectTrace.getDataProvider()).iterator())); value = Math.max( value, ChartUtil.getMax( ((CircularBufferDataProvider) insertTrace.getDataProvider()).iterator())); value = Math.max( value, ChartUtil.getMax( ((CircularBufferDataProvider) updateTrace.getDataProvider()).iterator())); value = Math.max( value, ChartUtil.getMax( ((CircularBufferDataProvider) deleteTrace.getDataProvider()).iterator())); return value; } }); } }