mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
feat: support debug cp
This commit is contained in:
parent
f0cc46c7af
commit
9dba1ff749
@ -4,6 +4,7 @@ import com.google.gson.JsonObject;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bdware.sc.ContractClient;
|
import org.bdware.sc.ContractClient;
|
||||||
|
import org.bdware.sc.ContractManager;
|
||||||
import org.bdware.sc.ContractMeta;
|
import org.bdware.sc.ContractMeta;
|
||||||
import org.bdware.sc.ContractStatusEnum;
|
import org.bdware.sc.ContractStatusEnum;
|
||||||
import org.bdware.sc.bean.Contract;
|
import org.bdware.sc.bean.Contract;
|
||||||
@ -154,4 +155,37 @@ public class TemporyTestAction {
|
|||||||
jo.put("recoverStatus", MasterServerRecoverMechAction.recoverStatus);
|
jo.put("recoverStatus", MasterServerRecoverMechAction.recoverStatus);
|
||||||
resultCallback.onResult(JsonUtil.toPrettyJson(jo));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ public class MasterClientTCPAction {
|
|||||||
run1();
|
run1();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
this.cancel();
|
HeartBeatUtil.getInstance().cancel(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ public class MasterServerTCPAction {
|
|||||||
checkAliveTask,
|
checkAliveTask,
|
||||||
MasterClientTCPAction.sendDelay,
|
MasterClientTCPAction.sendDelay,
|
||||||
MasterClientTCPAction.checkDelay);
|
MasterClientTCPAction.checkDelay);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void notifyNodeOffline(String contractID, String nodeID) {
|
private static void notifyNodeOffline(String contractID, String nodeID) {
|
||||||
@ -413,8 +414,8 @@ public class MasterServerTCPAction {
|
|||||||
Set<String> contracts = new HashSet<>();
|
Set<String> contracts = new HashSet<>();
|
||||||
String nodeID = handler.pubKey;
|
String nodeID = handler.pubKey;
|
||||||
if (nodeID == null) {
|
if (nodeID == null) {
|
||||||
LOGGER.info("nodeID == null");
|
LOGGER.info("nodeID == null " + this);
|
||||||
this.cancel();
|
HeartBeatUtil.getInstance().cancel(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +139,7 @@ public class NetworkManager {
|
|||||||
@Override
|
@Override
|
||||||
protected void initChannel(SocketChannel arg0) {
|
protected void initChannel(SocketChannel arg0) {
|
||||||
arg0.pipeline()
|
arg0.pipeline()
|
||||||
//
|
|
||||||
// .addLast(new IdleStateHandler(5, 0, 0,
|
|
||||||
// TimeUnit.SECONDS))
|
|
||||||
.addLast(new DelimiterCodec())
|
.addLast(new DelimiterCodec())
|
||||||
// .addLast(new IdleStateHandler(10, 0, 0))
|
|
||||||
//
|
|
||||||
// .addLast(new HeartBeatDecode())
|
|
||||||
.addLast(new TCPServerFrameHandler());
|
.addLast(new TCPServerFrameHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user