@RequestHandler(RequestCmd.OBJECT_DUMP_FILE_LIST) public Pack getDumpFileList(Pack param) { MapPack result = new MapPack(); ListValue nameLv = result.newList("name"); ListValue sizeLv = result.newList("size"); ListValue lastModifedLv = result.newList("last_modified"); File dumpDir = Configure.getInstance().dump_dir; if (dumpDir.canRead()) { for (File file : dumpDir.listFiles()) { if (file.isFile()) { nameLv.add(file.getName()); sizeLv.add(file.length()); lastModifedLv.add(file.lastModified()); } } } return result; }
public static MapPack getThreadList() { ThreadMXBean tmb = ManagementFactory.getThreadMXBean(); long[] thread = tmb.getAllThreadIds(); MapPack pack = new MapPack(); ListValue id = pack.newList("id"); ListValue name = pack.newList("name"); ListValue stat = pack.newList("stat"); ListValue cpu = pack.newList("cpu"); for (int i = 0; i < thread.length; i++) { ThreadInfo fo = tmb.getThreadInfo(thread[i]); if (fo == null) { continue; } id.add(fo.getThreadId()); name.add(fo.getThreadName()); stat.add(fo.getThreadState().toString()); cpu.add(tmb.getThreadCpuTime(thread[i]) / 1000000); } return pack; }
public static MapPack getThreadList() { ThreadMXBean tmb = ManagementFactory.getThreadMXBean(); long[] thread = tmb.getAllThreadIds(); MapPack pack = new MapPack(); ListValue id = pack.newList("id"); ListValue name = pack.newList("name"); ListValue stat = pack.newList("stat"); ListValue cpu = pack.newList("cpu"); for (int i = 0; i < thread.length; i++) { ThreadInfo fo = tmb.getThreadInfo(thread[i]); if (fo == null) { continue; } id.add(fo.getThreadId()); name.add(fo.getThreadName()); stat.add(fo.getThreadState().toString()); cpu.add(tmb.getThreadCpuTime(thread[i]) / 1000000); } return pack; }
public static MapPack getThreadList() { ThreadMXBean tmb = ManagementFactory.getThreadMXBean(); long[] thread = tmb.getAllThreadIds(); MapPack pack = new MapPack(); ListValue id = pack.newList("id"); ListValue name = pack.newList("name"); ListValue stat = pack.newList("stat"); ListValue cpu = pack.newList("cpu"); for (int i = 0; i < thread.length; i++) { ThreadInfo fo = tmb.getThreadInfo(thread[i]); if (fo == null) { continue; } id.add(fo.getThreadId()); name.add(fo.getThreadName()); stat.add(fo.getThreadState().toString()); cpu.add(tmb.getThreadCpuTime(thread[i]) / 1000000); } return pack; }
@RequestHandler(RequestCmd.OBJECT_DUMP_FILE_LIST) public Pack getDumpFileList(Pack param) { MapPack result = new MapPack(); ListValue nameLv = result.newList("name"); ListValue sizeLv = result.newList("size"); ListValue lastModifedLv = result.newList("last_modified"); File dumpDir = Configure.getInstance().dump_dir; if (dumpDir.canRead()) { for (File file : dumpDir.listFiles()) { if (file.isFile()) { nameLv.add(file.getName()); sizeLv.add(file.length()); lastModifedLv.add(file.lastModified()); } } } return result; }
public static MapPack getThreadList() { ThreadMXBean tmb = ManagementFactory.getThreadMXBean(); long[] thread = tmb.getAllThreadIds(); MapPack pack = new MapPack(); ListValue id = pack.newList("id"); ListValue name = pack.newList("name"); ListValue stat = pack.newList("stat"); ListValue cpu = pack.newList("cpu"); for (int i = 0; i < thread.length; i++) { ThreadInfo fo = tmb.getThreadInfo(thread[i]); if (fo == null) { continue; } id.add(fo.getThreadId()); name.add(fo.getThreadName()); stat.add(fo.getThreadState().toString()); cpu.add(tmb.getThreadCpuTime(thread[i]) / 1000000); } return pack; }
public static MapPack getThreadList() { ThreadMXBean tmb = ManagementFactory.getThreadMXBean(); long[] thread = tmb.getAllThreadIds(); MapPack pack = new MapPack(); ListValue id = pack.newList("id"); ListValue name = pack.newList("name"); ListValue stat = pack.newList("stat"); ListValue cpu = pack.newList("cpu"); for (int i = 0; i < thread.length; i++) { ThreadInfo fo = tmb.getThreadInfo(thread[i]); if (fo == null) { continue; } id.add(fo.getThreadId()); name.add(fo.getThreadName()); stat.add(fo.getThreadState().toString()); cpu.add(tmb.getThreadCpuTime(thread[i]) / 1000000); } return pack; }
@RequestHandler(RequestCmd.OBJECT_LIST_HEAP_DUMP) public Pack listHeapDump(Pack param) { MapPack p = new MapPack(); ListValue nameLv = p.newList("name"); ListValue sizeLv = p.newList("size"); File hprofDir = new File(folderName); if (hprofDir.exists() == false) { return null; } File[] fileList = hprofDir.listFiles(new ContentFilter()); if (fileList != null && fileList.length > 0) { for (int i = 0; i < fileList.length; i++) { File f = fileList[i]; if (/* f.isFile() && */f.getName().endsWith(fileExt)) { nameLv.add(f.getName()); sizeLv.add(f.length()); } } return p; } return p; }
@RequestHandler(RequestCmd.OBJECT_LIST_HEAP_DUMP) public Pack listHeapDump(Pack param) { MapPack p = new MapPack(); ListValue nameLv = p.newList("name"); ListValue sizeLv = p.newList("size"); File hprofDir = new File(folderName); if (hprofDir.exists() == false) { return null; } File[] fileList = hprofDir.listFiles(new ContentFilter()); if (fileList != null && fileList.length > 0) { for (int i = 0; i < fileList.length; i++) { File f = fileList[i]; if (/* f.isFile() && */f.getName().endsWith(fileExt)) { nameLv.add(f.getName()); sizeLv.add(f.length()); } } return p; } return p; }
@ServiceHandler(RequestCmd.SERVER_DB_LIST) public void listDbFiles(DataInputX din, DataOutputX dout, boolean login) throws IOException { String rootPath = DBCtr.getRootPath(); MapPack m = new MapPack(); ListValue nameLv = m.newList("name"); ListValue sizeLv = m.newList("size"); ListValue lastModifiedLv = m.newList("lastModified"); File dbDir = new File(rootPath); long totalLength = 0; if (dbDir.exists() && dbDir.isDirectory()) { totalLength = collectDirectory(dbDir, nameLv, sizeLv, lastModifiedLv, dbDir.getAbsolutePath()); } if (SystemUtil.IS_JAVA_1_5 == false) { m.put("free", dbDir.getUsableSpace()); } m.put("total", totalLength); dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); dout.flush(); } @ServiceHandler(RequestCmd.SERVER_DB_DELETE)
ListValue keyLv = p.newList("key"); ListValue hostLv = p.newList("host"); ListValue portLv = p.newList("port"); ListValue countLv = p.newList("count"); ListValue serviceLv = p.newList("service"); ListValue txidLv = p.newList("txid"); ListValue orderLv = p.newList("order"); ListValue stackLv = p.newList("stack");
IToolsMain toolsMain = (IToolsMain) c.newInstance(); List<String> out = toolsMain.heaphisto(0, 100000, "all"); ListValue lv = m.newList("heaphisto"); for (int i = 0; i < out.size(); i++) { lv.add(out.get(i));
private List<Pack> retrieveXLogPacksByTxids(MultiXLogRequest xlogRequest) { MapPack param = new MapPack(); param.put(ParamConstant.DATE, xlogRequest.getYyyymmdd()); ListValue xlogLv = param.newList(XLOG_TXID); xlogRequest.getTxidList().forEach(xlogLv::add); List<Pack> results; try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(xlogRequest.getServerId())) { results = tcpProxy.process(RequestCmd.XLOG_LOAD_BY_TXIDS, param); } return results; }
public void retrieveText(DictionaryRequest dictionaryRequest, INetReader reader) { try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(dictionaryRequest.getServerId())) { for (Map.Entry<String, Set<SDictionaryText>> textSetEntry : dictionaryRequest.getDictSets().entrySet()) { MapPack paramPack = new MapPack(); paramPack.put(ParamConstant.DATE, dictionaryRequest.getYyyymmdd()); paramPack.put(ParamConstant.TEXT_TYPE, textSetEntry.getKey()); ListValue dictKeyLV = paramPack.newList(ParamConstant.TEXT_DICTKEY); for (SDictionaryText dictionaryText : textSetEntry.getValue()) { dictKeyLV.add(dictionaryText.getDictKey()); } tcpProxy.process(RequestCmd.GET_TEXT_PACK, paramPack, reader); } } } }
/** * retrieve realtime interaction counter value by objtype of objhash * */ private List<InteractionCounterData> retrieveRealTimeByObjTypeOrObjHashes(final String objType, final Set<Integer> objHashSet, final Server server) { MapPack paramPack = new MapPack(); paramPack.put(ParamConstant.OBJ_TYPE, objType); ListValue objHashLv = paramPack.newList(ParamConstant.OBJ_HASH); if (objHashSet != null) { for (Integer objHash : objHashSet) { objHashLv.add(objHash); } } List<InteractionCounterData> resultList = new ArrayList<>(); try(TcpProxy tcpProxy = TcpProxy.getTcpProxy(server)) { tcpProxy.process(RequestCmd.INTR_COUNTER_REAL_TIME_BY_OBJ, paramPack, in -> { resultList.add(InteractionCounterData.of((InteractionPerfCounterPack) in.readPack(), server.getId())); }); } return resultList; } }
@RequestHandler(OBJECT_THREAD_LIST) public Pack threadList(Pack param) { MapPack mpack = ThreadUtil.getThreadList(); ListValue ids = mpack.getList("id"); ListValue txid = mpack.newList("txid"); ListValue elapsed = mpack.newList("elapsed"); ListValue service = mpack.newList("service"); for (int i = 0; i < ids.size(); i++) { long tid = CastUtil.clong(ids.get(i)); TraceContext ctx = TraceContextManager.getContext(tid); if (ctx != null) { txid.add(new TextValue(Hexa32.toString32(ctx.txid))); service.add(new TextValue(ctx.serviceName)); long etime = System.currentTimeMillis() - ctx.startTime; elapsed.add(new DecimalValue(etime)); } else { txid.add(new NullValue()); elapsed.add(new NullValue()); service.add(new NullValue()); } } return mpack; } Configure conf = Configure.getInstance();
@RequestHandler(OBJECT_THREAD_LIST) public Pack threadList(Pack param) { MapPack mpack = ThreadUtil.getThreadList(); ListValue ids = mpack.getList("id"); ListValue txid = mpack.newList("txid"); ListValue elapsed = mpack.newList("elapsed"); ListValue service = mpack.newList("service"); for (int i = 0; i < ids.size(); i++) { long tid = CastUtil.clong(ids.get(i)); TraceContext ctx = TraceContextManager.getContext(tid); if (ctx != null) { txid.add(new TextValue(Hexa32.toString32(ctx.txid))); service.add(new TextValue(ctx.serviceName)); long etime = System.currentTimeMillis() - ctx.startTime; elapsed.add(new DecimalValue(etime)); } else { txid.add(new NullValue()); elapsed.add(new NullValue()); service.add(new NullValue()); } } return mpack; } Configure conf = Configure.getInstance();
ListValue objHashLv = paramPack.newList(ParamConstant.OBJ_HASH); for (Integer objHash : ((CounterRequestByObjHashes) request).getObjHashes()) { objHashLv.add(objHash);
/** * handle realtime xlog */ public void handleRealTimeXLog(final RealTimeXLogRequest xLogRequest, final INetReader reader) { boolean isFirst = false; int firstRetrieveLimit = 10000; if (xLogRequest.getXLogLoop() == 0 && xLogRequest.getXLogIndex() == 0) { isFirst = true; } String cmd = isFirst ? RequestCmd.TRANX_REAL_TIME_GROUP_LATEST : RequestCmd.TRANX_REAL_TIME_GROUP; MapPack paramPack = new MapPack(); paramPack.put(ParamConstant.OFFSET_INDEX, xLogRequest.getXLogIndex()); paramPack.put(ParamConstant.OFFSET_LOOP, xLogRequest.getXLogLoop()); paramPack.put(ParamConstant.XLOG_COUNT, firstRetrieveLimit); ListValue objHashLv = paramPack.newList(ParamConstant.OBJ_HASH); for (Integer hash : xLogRequest.getObjHashes()) { objHashLv.add(hash); } RealTimeXLogView xLogView = new RealTimeXLogView(); List<SXLog> xLogList = new ArrayList<>(); xLogView.setXLogs(xLogList); try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(xLogRequest.getServerId())) { tcpProxy.process(cmd, paramPack, reader); } }
/** * retrieve XLog List for paging access * * @param pageableXLogRequest */ public void handlePageableXLog(final PageableXLogRequest pageableXLogRequest, final INetReader reader) { MapPack paramPack = new MapPack(); paramPack.put(ParamConstant.DATE, pageableXLogRequest.getYyyymmdd()); paramPack.put(ParamConstant.XLOG_START_TIME, pageableXLogRequest.getStartTimeMillis()); paramPack.put(XLOG_TXID, pageableXLogRequest.getLastTxid()); paramPack.put(ParamConstant.XLOG_END_TIME, pageableXLogRequest.getEndTimeMillis()); paramPack.put(ParamConstant.XLOG_LAST_BUCKET_TIME, pageableXLogRequest.getLastXLogTime()); paramPack.put(ParamConstant.XLOG_PAGE_COUNT, pageableXLogRequest.getPageCount()); ListValue objHashLv = paramPack.newList(ParamConstant.OBJ_HASH); for (Integer hash : pageableXLogRequest.getObjHashes()) { objHashLv.add(hash); } PageableXLogView view = new PageableXLogView(); List<SXLog> xLogList = new ArrayList<>(); view.setXLogs(xLogList); try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(pageableXLogRequest.getServerId())) { tcpProxy.process(RequestCmd.TRANX_LOAD_TIME_GROUP_V2, paramPack, reader); } }