feat: support debug cp

This commit is contained in:
CaiHQ 2021-11-02 15:03:25 +08:00
parent f0cc46c7af
commit 9dba1ff749
4 changed files with 38 additions and 9 deletions

View File

@ -4,6 +4,7 @@ import com.google.gson.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.sc.ContractClient;
import org.bdware.sc.ContractManager;
import org.bdware.sc.ContractMeta;
import org.bdware.sc.ContractStatusEnum;
import org.bdware.sc.bean.Contract;
@ -154,4 +155,37 @@ public class TemporyTestAction {
jo.put("recoverStatus", MasterServerRecoverMechAction.recoverStatus);
resultCallback.onResult(JsonUtil.toPrettyJson(jo));
}
@Action(async = true)
public void getAgentConfig(JsonObject args, ResultCallback resultCallback) {
JsonObject jo = new JsonObject();
jo.addProperty("action", "onGetAgentConfig");
jo.addProperty("cmi", ContractClient.cmi);
jo.addProperty("dbPath", ContractManager.dbPath);
jo.addProperty("cPort", ContractManager.cPort.getCMPort());
jo.addProperty("port", ContractManager.cPort.getPortAndInc());
resultCallback.onResult(jo.toString());
}
@Action(async = true)
public void allocateKeyPair(JsonObject args, ResultCallback resultCallback) {
Contract c = new Contract();
c.setScript(args.get("script").getAsString());
c.setOwner(args.get("owner").getAsString());
ContractManager.instance.allocateKeyIfNotExists(c);
JsonObject jo = JsonUtil.parseObject(c);
jo.addProperty("action", "onAllocateKeyPair");
resultCallback.onResult(jo.toString());
}
@Action(async = true)
public void reconnectAll(JsonObject args, ResultCallback resultCallback) {
ContractManager.instance.reconnectContractProcess();
String data = ContractManager.instance.listContractsWithOwner(
args.get("owner").getAsString(), null, 0);
JsonObject ret = new JsonObject();
ret.addProperty("data", data);
ret.addProperty("action", "onReconnectAll");
resultCallback.onResult(ret);
}
}

View File

@ -220,7 +220,7 @@ public class MasterClientTCPAction {
run1();
} catch (Throwable t) {
t.printStackTrace();
this.cancel();
HeartBeatUtil.getInstance().cancel(this);
}
}

View File

@ -83,6 +83,7 @@ public class MasterServerTCPAction {
checkAliveTask,
MasterClientTCPAction.sendDelay,
MasterClientTCPAction.checkDelay);
}
private static void notifyNodeOffline(String contractID, String nodeID) {
@ -413,8 +414,8 @@ public class MasterServerTCPAction {
Set<String> contracts = new HashSet<>();
String nodeID = handler.pubKey;
if (nodeID == null) {
LOGGER.info("nodeID == null");
this.cancel();
LOGGER.info("nodeID == null " + this);
HeartBeatUtil.getInstance().cancel(this);
return;
}

View File

@ -139,13 +139,7 @@ public class NetworkManager {
@Override
protected void initChannel(SocketChannel arg0) {
arg0.pipeline()
//
// .addLast(new IdleStateHandler(5, 0, 0,
// TimeUnit.SECONDS))
.addLast(new DelimiterCodec())
// .addLast(new IdleStateHandler(10, 0, 0))
//
// .addLast(new HeartBeatDecode())
.addLast(new TCPServerFrameHandler());
}
});