diff --git a/build.gradle b/build.gradle index a7ed86b..6c7a935 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,9 @@ dependencies { implementation project(":mockjava") implementation project(":front-base") implementation 'io.prometheus:simpleclient_httpserver:0.12.0' + implementation 'org.knowhowlab.osgi:sigar:1.6.5_01' + implementation 'io.grpc:grpc-all:1.41.0' + implementation 'org.apache.velocity:velocity-engine-core:2.3' testImplementation 'junit:junit:4.13.2' } diff --git a/src/main/java/org/bdware/server/action/CMActions.java b/src/main/java/org/bdware/server/action/CMActions.java index 3599072..5f7502a 100644 --- a/src/main/java/org/bdware/server/action/CMActions.java +++ b/src/main/java/org/bdware/server/action/CMActions.java @@ -222,7 +222,7 @@ public class CMActions implements OnHashCallback { ret.has("result") ? ret.get("result").toString() : ""); } LOGGER.debug("result of request " + cReq.getRequestID() + ": " + ret); - resultCallback.onResult(ret.toString()); + resultCallback.onResult(ret); } @Override @@ -369,8 +369,7 @@ public class CMActions implements OnHashCallback { ret.put("data", str); String costTime = (System.currentTimeMillis() - start) + ""; ret.put("executeTime", costTime); - String retStr = JsonUtil.toJson(ret); - resultCallback.onResult(retStr); + resultCallback.onResult(ret); } }; rb.onResult(generator.generate(targetPath)); @@ -380,7 +379,7 @@ public class CMActions implements OnHashCallback { Map ret = new HashMap<>(); ret.put("action", "onGenerateReadme"); ret.put("data", bo.toString()); - resultCallback.onResult(JsonUtil.toJson(ret)); + resultCallback.onResult(ret); } } @@ -1932,6 +1931,4 @@ public class CMActions implements OnHashCallback { } - - } \ No newline at end of file diff --git a/src/main/java/org/bdware/server/action/MasterWSAction.java b/src/main/java/org/bdware/server/action/MasterWSAction.java index b3387fa..5f2c491 100644 --- a/src/main/java/org/bdware/server/action/MasterWSAction.java +++ b/src/main/java/org/bdware/server/action/MasterWSAction.java @@ -245,7 +245,7 @@ public class MasterWSAction { } ret.put("data", str); ret.put("executionTime", (System.currentTimeMillis() - curr) + ""); - rc.onResult(JsonUtil.toJson(ret)); + rc.onResult(ret); } }, nodeSize); diff --git a/src/main/java/org/bdware/server/action/p2p/AliveCheckClientAction.java b/src/main/java/org/bdware/server/action/p2p/AliveCheckClientAction.java index ab5a423..2562003 100644 --- a/src/main/java/org/bdware/server/action/p2p/AliveCheckClientAction.java +++ b/src/main/java/org/bdware/server/action/p2p/AliveCheckClientAction.java @@ -1,7 +1,6 @@ package org.bdware.server.action.p2p; import com.google.gson.JsonObject; -import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bdware.heartbeat.HeartBeatUtil; @@ -114,9 +113,7 @@ public class AliveCheckClientAction { int lastSeq = meta.getLastExeSeq(); request.put("lastExe", lastSeq + ""); request.put("master", masterPubkey); - String[] members = - meta.getMembers(); - request.put("members", StringUtils.join(members, ",")); + request.put("members", meta.joinMembers(",")); NetworkManager.instance.sendToNodeCenter( JsonUtil.toJson(request)); MasterElectTimeRecorder.findMasterCrash = diff --git a/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java b/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java index df1c2f4..c7d370e 100644 --- a/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java +++ b/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java @@ -2,7 +2,6 @@ package org.bdware.server.action.p2p; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bdware.sc.*; @@ -74,13 +73,12 @@ public class MasterClientTCPAction { request.put("lastExe", lastSeq + ""); request.put("master", "null"); // 不管之前master是哪个,NC处是null,所有节点重选 if (null != uniNumber) request.put("uniNumber", uniNumber); - String members = - StringUtils.join( - CMActions.manager - .multiContractRecorder - .getMultiContractMeta(contractID) - .getMembers(), - ","); + + String members = CMActions.manager + .multiContractRecorder + .getMultiContractMeta(contractID) + .joinMembers(","); + request.put("members", members); NetworkManager.instance.sendToNodeCenter(JsonUtil.toJson(request)); LOGGER.info("认为合约 " + contractID + " 的master崩溃 当前master为null 向NC发送重选信息"); diff --git a/src/main/java/org/bdware/server/http/CMHttpHandler.java b/src/main/java/org/bdware/server/http/CMHttpHandler.java index 4e1f3b6..286b5d4 100644 --- a/src/main/java/org/bdware/server/http/CMHttpHandler.java +++ b/src/main/java/org/bdware/server/http/CMHttpHandler.java @@ -353,7 +353,7 @@ public class CMHttpHandler extends SimpleChannelInboundHandler { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { LOGGER.warn("catch exception in " + this + ": " + cause.getClass().getSimpleName()); - LOGGER.debug(ExceptionUtil.exceptionToString(cause)); + cause.printStackTrace(); // ctx.close(); } }