final Map<String, ListValue> hostTopMap = new HashMap<>(); hostTopKeys.forEach(key -> { hostTopMap.put(key, outMapPack.getList(key)); });
String objName = AgentModelThread.getInstance().getAgentObject(objHash).getObjName(); ListValue idLv = mapPack.getList("id"); ListValue nameLv = mapPack.getList("name"); ListValue statLv = mapPack.getList("stat"); ListValue cpuLv = mapPack.getList("cpu"); ListValue txidLv = mapPack.getList("txid"); ListValue elapsedLv = mapPack.getList("elapsed"); ListValue serviceLv = mapPack.getList("service"); ListValue ipLv = mapPack.getList("ip"); ListValue sqlLv = mapPack.getList("sql"); ListValue subcallLv = mapPack.getList("subcall");
@RequestHandler(RequestCmd.REDEFINE_CLASSES) public Pack redefineClasses(Pack param) { final MapPack p = new MapPack(); ListValue classLv = ((MapPack) param).getList("class"); HashSet<String> paramSet = new HashSet<String>(); for (int i = 0; i < classLv.size(); i++) {
@RequestHandler(RequestCmd.REDEFINE_CLASSES) public Pack redefineClasses(Pack param) { final MapPack p = new MapPack(); ListValue classLv = ((MapPack) param).getList("class"); HashSet<String> paramSet = new HashSet<String>(); for (int i = 0; i < classLv.size(); i++) {
@RequestHandler(RequestCmd.REDEFINE_CLASSES) public Pack redefineClasses(Pack param) { final MapPack p = new MapPack(); ListValue classLv = ((MapPack) param).getList("class"); HashSet<String> paramSet = new HashSet<String>(); for (int i = 0; i < classLv.size(); i++) {
@Override public Summary<ServiceSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<ServiceSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); ListValue errorCntList = dnmPack.getMapPack().getList("error"); ListValue elapsedSumList = dnmPack.getMapPack().getList("elapsed"); ListValue cpuSumList = dnmPack.getMapPack().getList("cpu"); ListValue memSumList = dnmPack.getMapPack().getList("mem"); for(int i = 0; i < idList.size(); i++) { ServiceSummaryItem item = ServiceSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(TextProxy.service.getTextIfNullDefault(date, idList.getInt(i), serverId)) .count(countList.getInt(i)) .errorCount(errorCntList.getInt(i)) .elapsedSum(elapsedSumList.getLong(i)) .cpuSum(cpuSumList.getLong(i)) .memorySum(memSumList.getLong(i)).build(); summary.merge(item); } } return summary; } }
@Override public Summary<AlertSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<AlertSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue titleList = dnmPack.getMapPack().getList("title"); ListValue countList = dnmPack.getMapPack().getList("count"); ListValue levelList = dnmPack.getMapPack().getList("level"); for(int i = 0; i < idList.size(); i++) { AlertSummaryItem item = AlertSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(titleList.getString(i)) .count(countList.getInt(i)) .level(AlertLevelEnum.of(levelList.getInt(i))).build(); summary.merge(item); } } return summary; } }
ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); ListValue errorList = dnmPack.getMapPack().getList("error"); ListValue serviceList = dnmPack.getMapPack().getList("service"); ListValue errorMessageList = dnmPack.getMapPack().getList("message"); ListValue txidList = dnmPack.getMapPack().getList("txid"); ListValue sqlList = dnmPack.getMapPack().getList("sql"); ListValue apiCallList = dnmPack.getMapPack().getList("apicall"); ListValue fullStackList = dnmPack.getMapPack().getList("fullstack");
@Override public Summary<SqlSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<SqlSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); ListValue errorCntList = dnmPack.getMapPack().getList("error"); ListValue elapsedSumList = dnmPack.getMapPack().getList("elapsed"); for(int i = 0; i < idList.size(); i++) { SqlSummaryItem item = SqlSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(TextProxy.sql.getTextIfNullDefault(date, idList.getInt(i), serverId)) .count(countList.getInt(i)) .errorCount(errorCntList.getInt(i)) .elapsedSum(elapsedSumList.getLong(i)).build(); summary.merge(item); } } return summary; } }
@Override public Summary<ApiCallSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<ApiCallSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); ListValue errorCntList = dnmPack.getMapPack().getList("error"); ListValue elapsedSumList = dnmPack.getMapPack().getList("elapsed"); for(int i = 0; i < idList.size(); i++) { ApiCallSummaryItem item = ApiCallSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(TextProxy.apicall.getTextIfNullDefault(date, idList.getInt(i), serverId)) .count(countList.getInt(i)) .errorCount(errorCntList.getInt(i)) .elapsedSum(elapsedSumList.getLong(i)).build(); summary.merge(item); } } return summary; } }
private List<CounterView> retrieveCounterInDay(CounterRequest request, Server server, MapPack paramPack) { List<CounterView> counterViewList = new ArrayList<>(); try(TcpProxy tcpProxy = TcpProxy.getTcpProxy(server)) { tcpProxy.process(RequestCmd.COUNTER_PAST_TIME_ALL, paramPack, in -> { MapPack mapPack = (MapPack) in.readPack(); int objHash = mapPack.getInt(ParamConstant.OBJ_HASH); ListValue timeList = mapPack.getList(ParamConstant.TIME); ListValue valueList = mapPack.getList(ParamConstant.VALUE); List<Double> valueToDoubleList = new ArrayList<>(); for (int i = 0; i < timeList.size(); i++) { valueToDoubleList.add(valueList.getDouble(i)); } AgentObject agentObject = AgentModelThread.getInstance().getAgentObject(objHash); String objType = agentObject.getObjType(); CounterView counterView = CounterView.builder() .objHash(objHash) .objName(agentObject.getObjName()) .name(request.getCounter()) .displayName(server.getCounterEngine().getCounterDisplayName(objType, request.getCounter())) .unit(server.getCounterEngine().getCounterUnit(objType, request.getCounter())) .startTimeMillis(request.getStartTimeMillis()) .endTimeMillis(request.getEndTimeMillis()) .timeList(Arrays.stream(timeList.toObjectArray()).map(Long.class::cast).collect(Collectors.toList())) .valueList(valueToDoubleList) .build(); counterViewList.add(counterView); }); } return counterViewList; }
@Override public Summary<UserAgentSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<UserAgentSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); for(int i = 0; i < idList.size(); i++) { UserAgentSummaryItem item = UserAgentSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(TextProxy.userAgent.getTextIfNullDefault(date, idList.getInt(i), serverId)) .count(countList.getInt(i)).build(); summary.merge(item); } } return summary; } }
@Override public Summary<IpSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<IpSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); for(int i = 0; i < idList.size(); i++) { IpSummaryItem item = IpSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(IPUtil.toString(idList.getInt(i))) .count(countList.getInt(i)).build(); summary.merge(item); } } return summary; } }
@ServiceHandler(RequestCmd.SERVER_DB_DELETE) public void deleteDbFiles(DataInputX din, DataOutputX dout, boolean login) throws IOException { String rootPath = DBCtr.getRootPath(); MapPack param = (MapPack) din.readPack(); ListValue fileLv = param.getList("file"); MapPack m = new MapPack(); if (fileLv != null) { for (int i = 0; i < fileLv.size(); i++) { String filename = fileLv.getString(i); File file = new File(rootPath + filename); deleteFiles(file); } m.put("size", fileLv.size()); } dout.writeByte(TcpFlag.HasNEXT); dout.writePack(m); dout.flush(); } @ServiceHandler(RequestCmd.REMOTE_CONTROL)
@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();
@Override public Summary<UserAgentSummaryItem> toSummary(List<DateAndMapPack> dnmPackList, int serverId) { Summary<UserAgentSummaryItem> summary = new Summary<>(); for (DateAndMapPack dnmPack : dnmPackList) { long date = DateTimeHelper.getDefault().yyyymmdd(dnmPack.getYyyymmdd()); ListValue idList = dnmPack.getMapPack().getList("id"); ListValue countList = dnmPack.getMapPack().getList("count"); for(int i = 0; i < idList.size(); i++) { UserAgentSummaryItem item = UserAgentSummaryItem.builder() .summaryKey(idList.getInt(i)) .summaryKeyName(TextProxy.userAgent.getTextIfNullDefault(date, idList.getInt(i), serverId)) .count(countList.getInt(i)).build(); summary.merge(item); } } return summary; } }