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 aeb5adc..ab5a423 100644 --- a/src/main/java/org/bdware/server/action/p2p/AliveCheckClientAction.java +++ b/src/main/java/org/bdware/server/action/p2p/AliveCheckClientAction.java @@ -21,12 +21,12 @@ import java.util.Map; import java.util.TimerTask; public class AliveCheckClientAction { - private static final Logger LOGGER = LogManager.getLogger(AliveCheckClientAction.class); - protected boolean waitForSetNode = false; - public static final int sendDelay = 2000; public static final int checkDelay = 5000; + private static final Logger LOGGER = LogManager.getLogger(AliveCheckClientAction.class); + private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd.HH:mm:ss"); private final String masterPubkey; + protected boolean waitForSetNode = false; TimerTask sendPingTask; TimerTask checkAliveTask; private long lastMasterPongTime = System.currentTimeMillis(); @@ -66,7 +66,7 @@ public class AliveCheckClientAction { LOGGER.debug( String.format( "f %s", - new SimpleDateFormat("yyyy-MM-dd.HH:mm:ss") + DATE_FORMAT .format(System.currentTimeMillis()))); Map ping = new HashMap<>(); ping.put("action", "masterPing"); @@ -93,10 +93,9 @@ public class AliveCheckClientAction { long cur = System.currentTimeMillis(); if (cur - lastMasterPongTime >= (2 * sendDelay)) { LOGGER.info( - "lastMasterPongTime=" - + new SimpleDateFormat("yyyy-MM-dd.HH:mm:ss") - .format(lastMasterPongTime) - + " 认为master崩溃!"); + "master maybe crash down, because lastMasterPongTime=" + + DATE_FORMAT.format(lastMasterPongTime) + + "!"); // 向NC发通知重新选举master,如果NC没有收到所有节点的重选请求,就认为是这个节点和master连接断开 // 这个节点需要重连master @@ -107,9 +106,9 @@ public class AliveCheckClientAction { for (MultiContractMeta meta : CMActions.manager.multiContractRecorder.getStatus().values()) { if (meta.getMasterNode().equals(masterPubkey)) { LOGGER.info( - "认为合约 " + "master of contract " + meta.getContractID() - + " 的master崩溃 master=" + + " maybe crash down! master=" + masterPubkey); request.put("contractID", meta.getContractID()); int lastSeq = meta.getLastExeSeq(); @@ -130,8 +129,7 @@ public class AliveCheckClientAction { }; lastMasterPongTime = System.currentTimeMillis(); LOGGER.info( - "设置 lastMasterPongTime=" - + new SimpleDateFormat("yyyy-MM-dd.HH:mm:ss").format(lastMasterPongTime)); + "lastMasterPongTime=" + DATE_FORMAT.format(lastMasterPongTime)); HeartBeatUtil.getInstance().schedule(sendPingTask, sendDelay / 2, checkDelay); HeartBeatUtil.getInstance().schedule(checkAliveTask, sendDelay, checkDelay); } diff --git a/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java b/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java index 79a2cbf..77b0499 100644 --- a/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java +++ b/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java @@ -324,7 +324,7 @@ public class NodeCenterClientController implements NodeCenterConn { @Action(async = true) public void onQueryNodeAddress(JsonObject jo, ResultCallback cb) { - LOGGER.info("onQueryNodeAddress:" + jo.toString()); + LOGGER.debug("onQueryNodeAddress:" + jo.toString()); sync.wakeUp(jo.get("responseID").getAsString(), jo.toString()); } @@ -349,7 +349,8 @@ public class NodeCenterClientController implements NodeCenterConn { sendMsg(JsonUtil.toJson(req)); //TODO use async instead? ContractResult cr = sync.syncSleep(requestID); - LOGGER.info("connectToNode result:" + JsonUtil.toJson(cr)); + LOGGER.debug("result: " + JsonUtil.toJson(cr)); + LOGGER.info("node " + pubKey + " succeed!"); if (!cr.result.equals(JsonNull.INSTANCE)) { try { JsonObject jo = cr.result.getAsJsonObject(); diff --git a/src/main/java/org/bdware/server/trustedmodel/AgentManager.java b/src/main/java/org/bdware/server/trustedmodel/AgentManager.java index a03b741..5b949c5 100644 --- a/src/main/java/org/bdware/server/trustedmodel/AgentManager.java +++ b/src/main/java/org/bdware/server/trustedmodel/AgentManager.java @@ -70,7 +70,7 @@ public class AgentManager implements AgentPeerManagerIntf { @Override public boolean deliverEvent(String pubKey, String event) { if (null != pubKey && !CMActions.manager.nodeCenterConn.getNodeId().equals(pubKey)) { - LOGGER.info("Deliver event message in node " + pubKey.substring(0, 6)); + LOGGER.info("Deliver event message to node " + pubKey.substring(0, 6)); JsonObject msg = new JsonObject(); msg.addProperty("action", "deliverEvent"); msg.addProperty("data", event);