mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
fix: fix bugs
fix bugs in cmconfig.json.template; fix bugs of JsonUtil's usage in TCPClientFrameHandler; update usage of JsonUtil
This commit is contained in:
parent
8c86d4e767
commit
5c19c1570d
@ -11,9 +11,9 @@
|
||||
"withBdledgerClient": "",
|
||||
"enableEventPersistence": false,
|
||||
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
|
||||
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv"
|
||||
"wsPluginActions": "org.bdware.metering.MeteringAction"
|
||||
"clientToAgentPlugins": ""
|
||||
"clientToClusterPlugins": ""
|
||||
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv",
|
||||
"wsPluginActions": "org.bdware.metering.MeteringAction",
|
||||
"clientToAgentPlugins": "",
|
||||
"clientToClusterPlugins": "",
|
||||
"tcpPlugins": ""
|
||||
}
|
@ -34,9 +34,9 @@ import java.util.*;
|
||||
|
||||
public class CMActions implements OnHashCallback {
|
||||
private static final String PARAM_ACTION = "action";
|
||||
private static final JsonObject MISSING_ARGUMENT = JsonUtil.parseString("{\"action\":\"onExecuteResult\",\"executeTime\":-1,"
|
||||
private static final JsonObject MISSING_ARGUMENT = JsonUtil.parseStringAsJsonObject("{\"action\":\"onExecuteResult\",\"executeTime\":-1,"
|
||||
+ "\"status\":\"Error\",\"result\":\"missing arguments\"}");
|
||||
private static final JsonObject INVALID_DOI = JsonUtil.parseString(
|
||||
private static final JsonObject INVALID_DOI = JsonUtil.parseStringAsJsonObject(
|
||||
"{\"action\":\"onExecuteResult\",\"executeTime\":-1,"
|
||||
+ "\"status\":\"Error\",\"result\":\"invalid contract doi\"}");
|
||||
private static final Logger LOGGER = LogManager.getLogger(CMActions.class);
|
||||
@ -247,7 +247,7 @@ public class CMActions implements OnHashCallback {
|
||||
}
|
||||
|
||||
// JsonObject jo =
|
||||
// JsonParser.parseString(args.get("arg").getAsString()).getAsJsonObject();
|
||||
// JsonParser.parseStringAsJsonObject(args.get("arg").getAsString()).getAsJsonObject();
|
||||
// if (!jo.has("action")) {
|
||||
// resultCallback.onResult(MISSING_ARGUMENT);
|
||||
// return;
|
||||
@ -475,7 +475,7 @@ public class CMActions implements OnHashCallback {
|
||||
String data = "failed";
|
||||
String contractID = "";
|
||||
String operation = "";
|
||||
//JsonElement mask = JsonParser.parseString("");
|
||||
//JsonElement mask = JsonParser.parseStringAsJsonObject("");
|
||||
if (args.has("contractID") && args.has("operation") && args.has("arg")) {
|
||||
contractID = args.get("contractID").getAsString();
|
||||
System.out.println(contractID);
|
||||
@ -1852,7 +1852,7 @@ public class CMActions implements OnHashCallback {
|
||||
LOGGER.debug("startContractConfig");
|
||||
// TODO private contract
|
||||
// if (args.has("isPrivate") && args.get("isPrivate").getAsBoolean()) {
|
||||
// args.add("pubkey", JsonParser.parseString(handler.getPubKey()));
|
||||
// args.add("pubkey", JsonParser.parseStringAsJsonObject(handler.getPubKey()));
|
||||
// }
|
||||
boolean type = args.get("type").getAsString().equalsIgnoreCase("TCP");
|
||||
String contract = args.get("contractName").getAsString();
|
||||
|
@ -1607,7 +1607,7 @@ public class FileActions {
|
||||
ret.put("ypk", new File(ypkPath).getName());
|
||||
ret.put(
|
||||
"permissions",
|
||||
JsonUtil.parseString(CMActions.manager.parseYpkPermissions(ypkPath)));
|
||||
JsonUtil.parseStringAsJsonObject(CMActions.manager.parseYpkPermissions(ypkPath)));
|
||||
} catch (Exception e) {
|
||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
||||
e.printStackTrace(new PrintStream(bo));
|
||||
|
@ -175,7 +175,7 @@ public class MasterWSAction {
|
||||
requestConnect.put("connectAll", true);
|
||||
}
|
||||
NetworkManager.instance.sendToNodeCenter(JsonUtil.toJson(requestConnect)); // 向NC发
|
||||
LOGGER.debug(JsonUtil.toJson(requestConnect));
|
||||
LOGGER.debug(JsonUtil.toPrettyJson(requestConnect));
|
||||
boolean isSuccess = waitForConnection(nodeNames);
|
||||
if (!isSuccess) {
|
||||
return;
|
||||
|
@ -173,7 +173,7 @@ public class TemporyTestAction {
|
||||
c.setScript(args.get("script").getAsString());
|
||||
c.setOwner(args.get("owner").getAsString());
|
||||
ContractManager.instance.allocateKeyIfNotExists(c);
|
||||
JsonObject jo = JsonUtil.parseObject(c);
|
||||
JsonObject jo = JsonUtil.parseObjectAsJsonObject(c);
|
||||
jo.addProperty("action", "onAllocateKeyPair");
|
||||
resultCallback.onResult(jo.toString());
|
||||
}
|
||||
|
@ -203,18 +203,17 @@ public class MasterClientTCPAction {
|
||||
}
|
||||
|
||||
public void run1() {
|
||||
// logger.info(
|
||||
// "f "
|
||||
// + new
|
||||
// SimpleDateFormat("yyyy-MM-dd.HH:mm:ss")
|
||||
//
|
||||
// .format(System.currentTimeMillis()));
|
||||
LOGGER.debug(
|
||||
String.format(
|
||||
"f %s",
|
||||
new SimpleDateFormat("yyyy-MM-dd.HH:mm:ss")
|
||||
.format(System.currentTimeMillis())));
|
||||
Map<String, String> ping = new HashMap<>();
|
||||
ping.put("action", "masterPing");
|
||||
handler.sendMsg(JsonUtil.toJson(ping));
|
||||
}
|
||||
};
|
||||
if (checkAliveTask == null)
|
||||
if (null == checkAliveTask)
|
||||
checkAliveTask =
|
||||
new TimerTask() {
|
||||
@Override
|
||||
|
@ -112,7 +112,7 @@ public class TCPClientFrameHandler extends SimpleChannelInboundHandler<Object> {
|
||||
ByteBuf bb = (ByteBuf) frame;
|
||||
JsonObject arg;
|
||||
try {
|
||||
arg = JsonUtil.parseObject(new InputStreamReader(new ByteBufInputStream(bb)));
|
||||
arg = JsonUtil.parseReaderAsJsonObject(new InputStreamReader(new ByteBufInputStream(bb)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Response response = new Response();
|
||||
@ -180,10 +180,10 @@ public class TCPClientFrameHandler extends SimpleChannelInboundHandler<Object> {
|
||||
}
|
||||
if (isOpen()) {
|
||||
try {
|
||||
JsonObject jo = JsonUtil.parseObject(json);
|
||||
JsonObject jo = JsonUtil.parseStringAsJsonObject(json);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("============[MasterClientFrameHandler]JsonParse Error:" + json);
|
||||
LOGGER.warn("JsonParse Error: " + e.getMessage() + "\n\t" + json);
|
||||
}
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(json.getBytes());
|
||||
ctx.channel().writeAndFlush(buf);
|
||||
|
@ -78,7 +78,7 @@ public class MasterProxy implements MasterStub {
|
||||
new ResultCallback() {
|
||||
@Override
|
||||
public void onResult(String ret) {
|
||||
JsonObject result = JsonUtil.parseString(ret);
|
||||
JsonObject result = JsonUtil.parseStringAsJsonObject(ret);
|
||||
ContractManager.instance.extractEventsFromContractResult(
|
||||
null, result, client, request, start);
|
||||
LOGGER.debug(
|
||||
@ -105,7 +105,7 @@ public class MasterProxy implements MasterStub {
|
||||
new ContractResult(
|
||||
ContractResult.Status.Error,
|
||||
new JsonPrimitive("canceled because of queue too long"));
|
||||
cb.onResult(JsonUtil.parseObject(cr));
|
||||
cb.onResult(JsonUtil.parseObjectAsJsonObject(cr));
|
||||
CongestionControl.masterProxyLoad.decrementAndGet();
|
||||
return;
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class MasterProxy implements MasterStub {
|
||||
new ResultCallback() {
|
||||
@Override
|
||||
public void onResult(String str) {
|
||||
cb.onResult(JsonUtil.parseString(str));
|
||||
cb.onResult(JsonUtil.parseStringAsJsonObject(str));
|
||||
CongestionControl.masterProxyLoad.decrementAndGet();
|
||||
}
|
||||
});
|
||||
|
@ -81,7 +81,7 @@ public class CommunicationManager extends BaseFunctionManager {
|
||||
}
|
||||
|
||||
public void handle(String str, String sender) {
|
||||
// JsonObject jsonObject = (JsonObject) JsonParser.parseString(str);
|
||||
// JsonObject jsonObject = (JsonObject) JsonParser.parseStringAsJsonObject(str);
|
||||
// if(jsonObject.has("action")) {
|
||||
// String action = jsonObject.get("action").getAsString();
|
||||
// switch (action) {
|
||||
|
Loading…
Reference in New Issue
Block a user