public static void buildXLogData(final String date, StyledText text, XLogPack p, int serverId) { final int servId = serverId; String error = TextProxy.error.getLoadText(date, p.error, servId); String objName = TextProxy.object.getLoadText(date, p.objHash, servId); int slen = 0; java.util.List<StyleRange> sr = new ArrayList<StyleRange>(); Color red = text.getDisplay().getSystemColor(SWT.COLOR_RED); final StringBuffer sb = new StringBuffer(); sb.append("► txid = ").append(Hexa32.toString32(p.txid)).append("\n"); sb.append("► objName = ").append(objName).append("\n"); sb.append("► endtime = ").append(DateUtil.timestamp(p.endTime)).append("\n"); sb.append("► elapsed = ").append(FormatUtil.print(p.elapsed, "#,##0")).append(" ms\n"); sb.append("► service = ").append(TextProxy.service.getText(p.service)).append("\n"); if (error != null) { sb.append("► error = "); slen = sb.length(); sb.append(error).append("\n"); sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL)); } sb.append("► ipaddr=" + IPUtil.toString(p.ipaddr) + ", "); sb.append("userid=" + p.userid); sb.append("\n► cpu=" + FormatUtil.print(p.cpu, "#,##0") + " ms, "); sb.append("bytes=" + p.bytes + ", "); sb.append("status=" + p.status); if (p.sqlCount > 0) { sb.append("\n► sqlCount=" + p.sqlCount + ", "); sb.append("sqlTime=" + FormatUtil.print(p.sqlTime, "#,##0") + " ms"); } if (p.apicallCount > 0) { sb.append("\n► ApiCallCount=" + p.apicallCount + ", "); sb.append("ApiCallTime=" + FormatUtil.print(p.apicallTime, "#,##0") + " ms"); } String t = TextProxy.userAgent.getLoadText(date, p.userAgent, serverId); if (StringUtil.isNotEmpty(t)) { sb.append("\n► userAgent=" + t); } t = TextProxy.referer.getLoadText(date, p.referer, serverId); if (StringUtil.isNotEmpty(t)) { sb.append("\n► referer=" + t); } t = TextProxy.group.getLoadText(date, p.group, serverId); if (StringUtil.isNotEmpty(t)) { sb.append("\n► group=" + t); } sb.append("\n"); text.setText(sb.toString()); text.setStyleRanges(sr.toArray(new StyleRange[sr.size()])); }
public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ALERT "); sb.append(DateUtil.timestamp(time)); sb.append(" objType=").append(objType); sb.append(" objHash=").append(Hexa32.toString32(objHash)); sb.append(" level=").append(level); sb.append(" title=").append(title); sb.append(" message=").append(message); sb.append(" tags=").append(tags); return sb.toString(); }
public static synchronized void boot() { if (booted) return; booted = true; CounterExecutingManager.load(); ReqestHandlingProxy.load(); Configure.getInstance().printConfig(); long seed = System.currentTimeMillis() ^ (((long) SysJMX.getProcessPID()) << 32); KeyGen.setSeed(seed); Logger.println("A100", "agent boot seed=" + Hexa32.toString32(seed)); PluginLoader.getInstance(); }
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; }
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 searchByGxId(String date, long gxId) { this.date = date; this.gxid = gxId; this.setPartName("GxID - " + Hexa32.toString32(gxId)); loadByGxId(); }
public static void buildProfile( final String date, StyledText text, XLogPack pack, StepWrapper[] orgProfiles, int pageNum, int rowPerPage, Button prevBtn, Button nextBtn, Button startBtn, Button endBtn, int length, int serverId, int searchLineIndex, boolean isSummary) { String spaceStr = ""; String astarStr = ""; for (int j = 0; j < length; j++) { spaceStr += " "; astarStr += "*"; } if (orgProfiles == null) { orgProfiles = new StepWrapper[0]; } boolean lastPage = false; int startIdx = pageNum * rowPerPage; int lastIdx = (pageNum * rowPerPage) + rowPerPage; if (lastIdx >= orgProfiles.length) { lastIdx = orgProfiles.length; lastPage = true; } int ix = 0; StepWrapper[] profiles = new StepWrapper[lastIdx - startIdx]; for (int inx = startIdx; inx < lastIdx; inx++) { profiles[ix] = orgProfiles[inx]; ix++; } int slen = 0; java.util.List<StyleRange> sr = new ArrayList<StyleRange>(); Color blue = text.getDisplay().getSystemColor(SWT.COLOR_BLUE); Color dmagenta = text.getDisplay().getSystemColor(SWT.COLOR_DARK_MAGENTA); Color red = text.getDisplay().getSystemColor(SWT.COLOR_RED); Color yellow = text.getDisplay().getSystemColor(SWT.COLOR_YELLOW); Color dgreen = text.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN); final StringBuffer sb = new StringBuffer(); sb.append( "------------------------------------------------------------------------------------------\n"); sb.append( " p# " + spaceStr + "# " + spaceStr + " TIME T-GAP CPU CONTENTS\n"); sb.append( "------------------------------------------------------------------------------------------\n"); if (profiles.length == 0) { sb.append("\n ( No xlog profile collected ) "); text.setText(sb.toString()); text.setStyleRanges(sr.toArray(new StyleRange[sr.size()])); return; } long stime = pack.endTime - pack.elapsed; long prev_tm = stime; if (pageNum > 0) { prev_tm = orgProfiles[startIdx - 1].time; } long prev_cpu = 0; if (pageNum > 0) { prev_cpu = orgProfiles[startIdx - 1].cpu; } if (pageNum == 0) { sb.append(" " + spaceStr + " "); sb.append(" "); sb.append("[" + astarStr + "]"); sb.append(" "); sb.append(DateUtil.getLogTime(stime)); sb.append(" "); sb.append(String.format("%6s", "0")); sb.append(" "); sb.append(String.format("%6s", "0")); sb.append(" start transaction \n"); } long tm = pack.endTime; long cpu = pack.cpu; for (int i = 0; i < profiles.length; i++) { if (profiles[i].step instanceof StepSummary) { int p1 = sb.length(); sb.append(spaceStr).append(" "); sb.append(String.format("[%0" + length + "d]", profiles[i].sSummaryIdx)); sb.append(" "); int lineHead = sb.length() - p1; StepSummary sum = (StepSummary) profiles[i].step; switch (sum.getStepType()) { case StepEnum.METHOD_SUM: MethodSum p = (MethodSum) sum; slen = sb.length(); String m = TextProxy.method.getText(p.hash); if (m == null) m = Hexa32.toString32(p.hash); sb.append(m).append(" "); if (searchLineIndex == profiles[i].sSummaryIdx) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, blue, SWT.NORMAL)); } sb.append(" count=").append(FormatUtil.print(p.count, "#,##0")); sb.append(" time=").append(FormatUtil.print(p.elapsed, "#,##0")).append(" ms"); sb.append(" cpu=").append(FormatUtil.print(p.cputime, "#,##0")); sb.append("\n"); break; case StepEnum.SQL_SUM: SqlSum sql = (SqlSum) sum; slen = sb.length(); ProfileText.toString(sb, sql, serverId); if (searchLineIndex == profiles[i].sSummaryIdx) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, blue, SWT.NORMAL)); } sb.append("\n"); break; case StepEnum.APICALL_SUM: ApiCallSum apicall = (ApiCallSum) sum; slen = sb.length(); ProfileText.toString(sb, apicall); if (searchLineIndex == profiles[i].sSummaryIdx) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL)); } sb.append("\n"); break; case StepEnum.SOCKET_SUM: XLogProfileView.isSummary = true; SocketSum socketSum = (SocketSum) sum; slen = sb.length(); ProfileText.toString(sb, socketSum); sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL)); sb.append("\n"); break; } continue; } StepSingle stepSingle = (StepSingle) profiles[i].step; tm = profiles[i].time; cpu = profiles[i].cpu; int p1 = sb.length(); String pid = String.format("[%0" + length + "d]", stepSingle.parent); sb.append((stepSingle.parent == -1) ? spaceStr + " " : pid); sb.append(" "); sb.append(String.format("[%0" + length + "d]", stepSingle.index)); sb.append(" "); sb.append(DateUtil.getLogTime(tm)); sb.append(" "); sb.append(String.format("%6s", FormatUtil.print(tm - prev_tm, "#,##0"))); sb.append(" "); sb.append(String.format("%6s", FormatUtil.print(cpu - prev_cpu, "#,##0"))); sb.append(" "); int lineHead = sb.length() - p1; int space = profiles[i].indent; while (space > 0) { sb.append(" "); space--; } switch (stepSingle.getStepType()) { case StepEnum.METHOD: slen = sb.length(); ProfileText.toString(sb, (MethodStep) stepSingle); if (searchLineIndex == stepSingle.index) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } break; case StepEnum.METHOD2: slen = sb.length(); ProfileText.toString(sb, (MethodStep) stepSingle); if (searchLineIndex == stepSingle.index) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } MethodStep2 m2 = (MethodStep2) stepSingle; if (m2.error != 0) { slen = sb.length(); sb.append("\n").append(TextProxy.error.getText(m2.error)); sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL)); } break; case StepEnum.SQL: case StepEnum.SQL2: case StepEnum.SQL3: SqlStep sql = (SqlStep) stepSingle; slen = sb.length(); ProfileText.toString(sb, sql, serverId, lineHead, false); if (searchLineIndex == stepSingle.index) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, blue, SWT.NORMAL)); } if (sql.error != 0) { slen = sb.length(); sb.append("\n").append(TextProxy.error.getText(sql.error)); sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL)); } break; case StepEnum.MESSAGE: slen = sb.length(); ProfileText.toString(sb, (MessageStep) stepSingle); if (searchLineIndex == stepSingle.index) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, dgreen, SWT.NORMAL)); } break; case StepEnum.HASHED_MESSAGE: slen = sb.length(); ProfileText.toString(sb, (HashedMessageStep) stepSingle); if (searchLineIndex == stepSingle.index) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, dgreen, SWT.NORMAL)); } break; case StepEnum.APICALL: ApiCallStep apicall = (ApiCallStep) stepSingle; slen = sb.length(); ProfileText.toString(sb, apicall); if (searchLineIndex == stepSingle.index) { sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow)); } else { sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL)); } if (apicall.error != 0) { slen = sb.length(); sb.append("\n").append(TextProxy.error.getText(apicall.error)); sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL)); } break; case StepEnum.SOCKET: SocketStep socket = (SocketStep) stepSingle; slen = sb.length(); ProfileText.toString(sb, socket); sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL)); if (socket.error != 0) { slen = sb.length(); sb.append("\n").append(TextProxy.error.getText(socket.error)); sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL)); } break; } sb.append("\n"); prev_cpu = cpu; prev_tm = tm; } if (lastPage) { nextBtn.setEnabled(false); endBtn.setEnabled(false); tm = pack.endTime; cpu = pack.cpu; // slen = sb.length(); sb.append(" " + spaceStr + " "); sb.append(" "); sb.append("[" + astarStr + "]"); sb.append(" "); sb.append(DateUtil.getLogTime(tm)); sb.append(" "); if (!isSummary) { sb.append(String.format("%6s", FormatUtil.print(tm - prev_tm, "#,##0"))); } else { sb.append(String.format("%6s", FormatUtil.print(pack.elapsed, "#,##0"))); } sb.append(" "); sb.append(String.format("%6s", FormatUtil.print(cpu - prev_cpu, "#,##0"))); sb.append(" end of transaction \n"); // sr.add(ProfileText.style(slen, sb.length() - slen, dblue, SWT.NORMAL)); sb.append( "------------------------------------------------------------------------------------------\n"); } else { nextBtn.setEnabled(true); endBtn.setEnabled(true); } if (pageNum == 0) { prevBtn.setEnabled(false); startBtn.setEnabled(false); } else { prevBtn.setEnabled(true); startBtn.setEnabled(true); } text.setText(sb.toString()); text.setStyleRanges(sr.toArray(new StyleRange[sr.size()])); }