public List<KeyValueData> getBulk(final String keySpace, final List<String> paramList, final Server server) { MapPack paramPack = new MapPack(); paramPack.put(ParamConstant.KEY_SPACE, keySpace); paramPack.put(ParamConstant.KEY, ListValue.ofStringValueList(paramList)); MapPack resultPack ; try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(server)) { resultPack = (MapPack) tcpProxy.getSingle(RequestCmd.GET_CUSTOM_KV_BULK, paramPack); } List<KeyValueData> resultList = new ArrayList<>(); for (String key : resultPack.keySet()) { resultList.add(new KeyValueData(key, resultPack.getText(key))); } return resultList; } }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; MapPack other = (MapPack) obj; if (size() != other.size()) return false; Set<String> keySet = keySet(); for (String key : keySet) { Value v1 = get(key); Value v2 = other.get(key); if (v2 == null) { return false; } if (v1.toJavaObject().equals(v2.toJavaObject()) == false) { return false; } } return true; }
@RequestHandler(RequestCmd.BATCH_ACTIVE_STACK) public Pack getActiveStack(Pack param) { MapPack pack = new MapPack(); String key = ((MapPack)param).getText("key"); MapPack map = Main.batchMap.get(key); if(map != null){ String stackContents = map.getText("lastStack"); long gapTime = System.currentTimeMillis() - (map.getLong("startTime") + map.getLong("elapsedTime")); stackContents = new StringBuilder(stackContents.length()+ 100).append("Stack before ").append(((int)(gapTime/1000L))).append(" seconds\n\n").append(stackContents).toString(); pack.put("stack", stackContents); } return pack; } }
final int COUNT_PER_PAGE = 100; MapPack mPack = (MapPack) param; int page = mPack.getInt("page"); if (page < 1) { page = 1; String filter = mPack.getText("filter"); MapPack p = new MapPack(); ListValue indexLv = p.newList("index"); ListValue typeLv = p.newList("type"); ListValue nameLv = p.newList("name"); ListValue superClassLv = p.newList("superClass"); ListValue interfacesLv = p.newList("interfaces"); ListValue resourceLv = p.newList("resource"); p.put("page", page); p.put("totalPage", 0); p.put("totalPage", (totalCount / COUNT_PER_PAGE) + 1); int start = (page - 1) * COUNT_PER_PAGE; for (int i = start; i < start + COUNT_PER_PAGE; i++) {
public static LoginRequest loginInternal(Server server, String user, String encPassword){ LoginRequest result = new LoginRequest(); try { MapPack param = new MapPack(); param.put("id", user); param.put("pass", encPassword); param.put("version", Version.getClientFullVersion()); param.put("hostname", SysJMX.getHostName()); param.put("internal", "true"); result.errorMessage = "Network connection failed"; } else { long session = out.getLong("session"); String error = out.getText("error"); if(error != null && session == 0L){ result.success = false; long time = out.getLong("time"); String serverName = out.getText("server_id"); String type = out.getText("type"); String version = out.getText("version"); String recommendedClientVersion = out.getText("client_version"); String email = out.getText("email"); String timezone = out.getText("timezone"); int soTimeOut = out.getInt("so_time_out"); server.setTimezone(timezone); server.setSoTimeOut(soTimeOut); Value value = out.get("policy"); if (value != null) {
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 List<KeyValueData> setBulk(final String keySpace, final Map<String, String> paramMap, long ttl, final Server server) { MapPack mapPack = new MapPack(); mapPack.put(ParamConstant.KEY_SPACE, keySpace); mapPack.put(ParamConstant.KEY_VALUE, MapValue.ofStringValueMap(paramMap)); mapPack.put(ParamConstant.TTL, ttl); MapPack resultPack ; try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(server)) { resultPack = (MapPack) tcpProxy.getSingle(RequestCmd.SET_CUSTOM_KV_BULK, mapPack); } List<KeyValueData> resultList = new ArrayList<>(); for (String key : resultPack.keySet()) { resultList.add(new KeyValueData(key, resultPack.getBoolean(key))); } return resultList; }
@RequestHandler(RequestCmd.SET_CONFIGURE_WAS) public Pack setAgentConfigure(Pack param) { final String setConfig = ((MapPack) param).getText("setConfig"); boolean success = Configure.getInstance().saveText(setConfig); if (success) { Configure.getInstance().reload(true); } MapPack p = new MapPack(); p.put("result", String.valueOf(success)); return p; }
@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; }
MapPack mapPack = new MapPack(); mapPack.put(ParamConstant.OBJ_HASH, objHash); final MapPack outMapPack = (MapPack) tcpProxy.getSingle(RequestCmd.HOST_TOP, mapPack); if (outMapPack == null) { final Map<String, ListValue> hostTopMap = new HashMap<>(); hostTopKeys.forEach(key -> { hostTopMap.put(key, outMapPack.getList(key)); });
MapPack paramPack = new MapPack(); if (request instanceof CounterAvgRequestByType) { paramPack.put(ParamConstant.OBJ_TYPE, ((CounterAvgRequestByType) request).getObjType()); } else if (request instanceof CounterAvgRequestByObjHashes) { ListValue objHashLv = paramPack.newList(ParamConstant.OBJ_HASH); for (Integer objHash : ((CounterAvgRequestByObjHashes) request).getObjHashes()) { objHashLv.add(objHash); paramPack.put(ParamConstant.SDATE, request.getStartYmd()); paramPack.put(ParamConstant.EDATE, request.getEndYmd()); paramPack.put(ParamConstant.COUNTER, request.getCounter()); tcpProxy.process(RequestCmd.COUNTER_PAST_LONGDATE_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);
public RealTimeAlertView retrieveRealTimeAlert(final RealTimeAlertRequest request) { MapPack paramPack = new MapPack(); paramPack.put(ParamConstant.OFFSET_LOOP, request.getLoop()); paramPack.put(ParamConstant.OFFSET_INDEX, request.getIndex()); paramPack.put(ParamConstant.OBJ_TYPE, request.getObjType()); RealTimeAlertView alertView = new RealTimeAlertView(); List<SAlert> alertList = new ArrayList<>(); alertView.setAlerts(alertList); try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(request.getServerId())) { tcpProxy.process(RequestCmd.ALERT_REAL_TIME, paramPack, in -> { Pack packet = in.readPack(); if (packet instanceof MapPack) { MapPack metaPack = (MapPack) packet; alertView.setOffset1(metaPack.getLong(ParamConstant.OFFSET_LOOP)); alertView.setOffset2(metaPack.getInt(ParamConstant.OFFSET_INDEX)); } else { AlertPack alertPack = (AlertPack) packet; alertList.add(SAlert.of(alertPack)); } }); } return alertView; } }
public String getText(String key) { Value v = get(key); if (v instanceof TextValue) { return ((TextValue) v).value; } return null; }
public MapValue toMapValue() { return toMapPack().toMapValue(); }
@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();
int objHash = mapPack.getInt("objHash"); 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");
@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; } }
public static SActiveServiceStepCount of(MapPack mapPack) { return new SActiveServiceStepCount( mapPack.getInt(ParamConstant.OBJ_HASH), AgentModelThread.getInstance().getAgentObject(mapPack.getInt(ParamConstant.OBJ_HASH)).getObjName(), mapPack.getInt(ParamConstant.ACTIVE_SERVICE_STEP1), mapPack.getInt(ParamConstant.ACTIVE_SERVICE_STEP2), mapPack.getInt(ParamConstant.ACTIVE_SERVICE_STEP3)); } }