mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
front: support startMulitipoint with args
fix: ContractClient missing arguments error update: @Router arguments format fix: ContractStatusRecorder null exception
This commit is contained in:
parent
ccdc33424e
commit
2758eb42e4
@ -903,7 +903,8 @@ public class CMActions implements OnHashCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.put("data", manager.startContractAndRedirect(c, System.out)); // createPS()
|
ret.put("data", manager.startContractAndRedirect(c, System.out));
|
||||||
|
ret.put("status", true);
|
||||||
ret.put("cid", c.getID());
|
ret.put("cid", c.getID());
|
||||||
ret.put("executeTime", System.currentTimeMillis() - start);
|
ret.put("executeTime", System.currentTimeMillis() - start);
|
||||||
resultCallback.onResult(ret);
|
resultCallback.onResult(ret);
|
||||||
@ -924,7 +925,7 @@ public class CMActions implements OnHashCallback {
|
|||||||
manager.changeDumpPeriod(c.getID(), args.get("dumpPeriod").getAsString());
|
manager.changeDumpPeriod(c.getID(), args.get("dumpPeriod").getAsString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ReplyUtil.simpleReply(resultCallback, "onStartContract", "Failed: Illegal user");
|
ReplyUtil.replyWithStatus(resultCallback, "onStartContract", false, "Failed: Illegal user");
|
||||||
}
|
}
|
||||||
ExecutionManager.instance.updateLocalContractToNodeCenter();
|
ExecutionManager.instance.updateLocalContractToNodeCenter();
|
||||||
}
|
}
|
||||||
@ -1289,13 +1290,13 @@ public class CMActions implements OnHashCallback {
|
|||||||
ContractMeta meta = manager.statusRecorder.getContractMeta(rc.getContractID());
|
ContractMeta meta = manager.statusRecorder.getContractMeta(rc.getContractID());
|
||||||
Contract contract = meta.contract;
|
Contract contract = meta.contract;
|
||||||
killContractProcess(args, resultCallback);
|
killContractProcess(args, resultCallback);
|
||||||
manager.startContractAndRedirect(contract,System.out);
|
manager.startContractAndRedirect(contract, System.out);
|
||||||
String data = manager.listContractsWithOwner(
|
String data = manager.listContractsWithOwner(
|
||||||
args.get("verifiedPubKey").getAsString(),
|
args.get("verifiedPubKey").getAsString(),
|
||||||
null,
|
null,
|
||||||
args.has("filters") ? args.get("filters").getAsInt() : 0);
|
args.has("filters") ? args.get("filters").getAsInt() : 0);
|
||||||
ReplyUtil.simpleReply(resultCallback, "onListContractProcess", data);
|
ReplyUtil.simpleReply(resultCallback, "onListContractProcess", data);
|
||||||
}else {
|
} else {
|
||||||
ReplyUtil.simpleReply(resultCallback, "onRestartContractProcess", "Failed: Illegal parameters");
|
ReplyUtil.simpleReply(resultCallback, "onRestartContractProcess", "Failed: Illegal parameters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1308,6 +1309,8 @@ public class CMActions implements OnHashCallback {
|
|||||||
for (ContractMeta meta : map.values()) {
|
for (ContractMeta meta : map.values()) {
|
||||||
if (meta.getStatus().equals(ContractStatusEnum.KILLED))
|
if (meta.getStatus().equals(ContractStatusEnum.KILLED))
|
||||||
toRemove.add(meta);
|
toRemove.add(meta);
|
||||||
|
if (meta.getName() == null || meta.getName().length() == 0)
|
||||||
|
toRemove.add(meta);
|
||||||
}
|
}
|
||||||
LOGGER.info("pruneKilledContract!!! size:" + toRemove.size());
|
LOGGER.info("pruneKilledContract!!! size:" + toRemove.size());
|
||||||
for (ContractMeta key : toRemove) {
|
for (ContractMeta key : toRemove) {
|
||||||
@ -1452,14 +1455,14 @@ public class CMActions implements OnHashCallback {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ExecutionManager.instance.updateLocalContractToNodeCenter();
|
ExecutionManager.instance.updateLocalContractToNodeCenter();
|
||||||
ReplyUtil.simpleReply(resultCallback, "onKillAllContract", sb.toString());
|
ReplyUtil.replyWithStatus(resultCallback, "onKillAllContract", true, sb.toString());
|
||||||
manager.stopAllContracts();
|
manager.stopAllContracts();
|
||||||
} else {
|
} else {
|
||||||
manager.stopAllContractsWithOwner(args.get(("verifiedPubKey")).getAsString());
|
manager.stopAllContractsWithOwner(args.get(("verifiedPubKey")).getAsString());
|
||||||
ReplyUtil.simpleReply(resultCallback, "onKillAllContract", "Success");
|
ReplyUtil.replyWithStatus(resultCallback, "onKillAllContract", true, "Success");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ReplyUtil.simpleReply(resultCallback, "onKillAllContract", "Failed: Illegal user");
|
ReplyUtil.replyWithStatus(resultCallback, "onKillAllContract", false, "Failed: Illegal user");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,7 +629,6 @@ public class FileActions {
|
|||||||
String pubKey = args.get("pubKey").getAsString();
|
String pubKey = args.get("pubKey").getAsString();
|
||||||
KeyValueDBUtil.instance.setValue(CMTables.LockedUser.toString(), pubKey, "locked");
|
KeyValueDBUtil.instance.setValue(CMTables.LockedUser.toString(), pubKey, "locked");
|
||||||
ReplyUtil.replyWithStatus(resultCallback, "onLockEdit", true, pubKey);
|
ReplyUtil.replyWithStatus(resultCallback, "onLockEdit", true, pubKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Action(userPermission = 1 << 10)
|
@Action(userPermission = 1 << 10)
|
||||||
|
@ -84,7 +84,7 @@ public class MasterClientTCPAction {
|
|||||||
args.put("nodeSize", contract.getNumOfCopies());
|
args.put("nodeSize", contract.getNumOfCopies());
|
||||||
args.put("masterPubkey", masterPubkey);
|
args.put("masterPubkey", masterPubkey);
|
||||||
args.put("members", members);
|
args.put("members", members);
|
||||||
return ConsistencyPluginManager.getInstance().createContractExecutor(contract.getType(), args);
|
return ConsistencyPluginManager.getInstance().createContractExecutor(contract.getType().name(), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dealRequests(String contractID) {
|
public static void dealRequests(String contractID) {
|
||||||
@ -298,9 +298,9 @@ public class MasterClientTCPAction {
|
|||||||
}
|
}
|
||||||
//TODO master连接
|
//TODO master连接
|
||||||
// contractID2MasterInfo.put(contractID, this); // 记录contractID 和 master之间的对应关系
|
// contractID2MasterInfo.put(contractID, this); // 记录contractID 和 master之间的对应关系
|
||||||
MultiContractMeta cei =
|
MultiContractMeta multiContractMeta =
|
||||||
CMActions.manager.multiContractRecorder.createIfNotExist(contractID);
|
CMActions.manager.multiContractRecorder.createIfNotExist(contractID);
|
||||||
cei.setLastExeSeq(-1);
|
multiContractMeta.setLastExeSeq(-1);
|
||||||
if (!contract.getScriptStr().startsWith("/")) {
|
if (!contract.getScriptStr().startsWith("/")) {
|
||||||
contract.setScript(dumpToDisk(contract, jo));
|
contract.setScript(dumpToDisk(contract, jo));
|
||||||
}
|
}
|
||||||
@ -308,21 +308,21 @@ public class MasterClientTCPAction {
|
|||||||
String[] pp = contract.getScriptStr().split("/");
|
String[] pp = contract.getScriptStr().split("/");
|
||||||
|
|
||||||
String parPath = GlobalConf.instance.publicCompiledDir;
|
String parPath = GlobalConf.instance.publicCompiledDir;
|
||||||
synchronized (cei) { // 合约执行信息
|
synchronized (multiContractMeta) { // 合约执行信息
|
||||||
cei.setYpkName(pp[pp.length - 1]);
|
multiContractMeta.setYpkName(pp[pp.length - 1]);
|
||||||
cei.setMembers(jo.get("members").getAsJsonArray());
|
multiContractMeta.setMembers(jo.get("members").getAsJsonArray());
|
||||||
cei.type = contract.getType();
|
multiContractMeta.type = contract.getType();
|
||||||
cei.key = contract.getKey();
|
multiContractMeta.key = contract.getKey();
|
||||||
cei.publicKey = contract.getPublicKey();
|
multiContractMeta.publicKey = contract.getPublicKey();
|
||||||
if (jo.has("isPrivate") && jo.get("isPrivate").getAsBoolean()) {
|
if (jo.has("isPrivate") && jo.get("isPrivate").getAsBoolean()) {
|
||||||
parPath =
|
parPath =
|
||||||
GlobalConf.instance.privateCompiledDir
|
GlobalConf.instance.privateCompiledDir
|
||||||
+ "/"
|
+ "/"
|
||||||
+ jo.get("pubKey").getAsString();
|
+ jo.get("pubKey").getAsString();
|
||||||
|
|
||||||
cei.setIsPrivate(true);
|
multiContractMeta.setIsPrivate(true);
|
||||||
cei.setPubKeyPath(jo.get("pubKey").getAsString());
|
multiContractMeta.setPubKeyPath(jo.get("pubKey").getAsString());
|
||||||
cei.setYpkName(pp[pp.length - 1]);
|
multiContractMeta.setYpkName(pp[pp.length - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,21 +342,21 @@ public class MasterClientTCPAction {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// 这个地方判定,从参数中的master数据 和 globalConf中的数据 进行对比,如果一致的话,说明该节点为master
|
// 这个地方判定,从参数中的master数据 和 globalConf中的数据 进行对比,如果一致的话,说明该节点为master
|
||||||
cei.setMaster(jo.get("master").getAsString());
|
multiContractMeta.setMaster(jo.get("master").getAsString());
|
||||||
if (contract.getType().needSeq())
|
if (contract.getType().needSeq())
|
||||||
cei.setIsMaster(GlobalConf.getNodeID().equals(jo.get("master").getAsString()));
|
multiContractMeta.setIsMaster(GlobalConf.getNodeID().equals(jo.get("master").getAsString()));
|
||||||
else {
|
else {
|
||||||
cei.setIsMaster(true);
|
multiContractMeta.setIsMaster(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("startup arguments: " + JsonUtil.toJson(contract));
|
LOGGER.debug("startup arguments: " + JsonUtil.toJson(contract));
|
||||||
String ret = CMActions.manager.startContract(contract); // 调用CMActions 里的启动合约的方法,启动结果
|
String ret = CMActions.manager.startContract(contract); // 调用CMActions 里的启动合约的方法,启动结果
|
||||||
|
|
||||||
LOGGER.debug("startup result: " + ret);
|
LOGGER.debug("startup result: " + ret);
|
||||||
CMActions.manager.multiContractRecorder.updateValue(cei);
|
CMActions.manager.multiContractRecorder.updateValue(multiContractMeta);
|
||||||
ContractMeta meta = CMActions.manager.statusRecorder.createIfNotExist(contractID);
|
ContractMeta meta = CMActions.manager.statusRecorder.createIfNotExist(contractID);
|
||||||
|
|
||||||
meta.setContractExecutor(createContractExecutor(contract, contractID, jo.get("master").getAsString(), cei.getMembers())); // 分配不同的Executor
|
meta.setContractExecutor(createContractExecutor(contract, contractID, jo.get("master").getAsString(), multiContractMeta.getMembers())); // 分配不同的Executor
|
||||||
// TODO 合约终止后从数据库中移除,但是为了测试可以人为制造合约终止但不从数据库中移除(异常停止)
|
// TODO 合约终止后从数据库中移除,但是为了测试可以人为制造合约终止但不从数据库中移除(异常停止)
|
||||||
KeyValueDBUtil.instance.setValue(CMTables.UnitContracts.toString(), contractID, "exist");
|
KeyValueDBUtil.instance.setValue(CMTables.UnitContracts.toString(), contractID, "exist");
|
||||||
|
|
||||||
|
@ -119,7 +119,6 @@ public class TCPClientFrameHandler extends SimpleChannelInboundHandler<Object> {
|
|||||||
}
|
}
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
//LOGGER.info("====== TCPClientFrameHandler:" + arg.toString());
|
|
||||||
final String action = arg.get("action").getAsString();
|
final String action = arg.get("action").getAsString();
|
||||||
PubkeyResultCallback pc = new PubkeyResultCallback(master, new ResultCallback() {
|
PubkeyResultCallback pc = new PubkeyResultCallback(master, new ResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
40
src/main/resources/log4j2debug.properties
Normal file
40
src/main/resources/log4j2debug.properties
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
filter.threshold.type=ThresholdFilter
|
||||||
|
filter.threshold.level=debug
|
||||||
|
appender.console.type=Console
|
||||||
|
appender.console.name=STDOUT
|
||||||
|
appender.console.layout.type=PatternLayout
|
||||||
|
appender.console.layout.pattern=%highlight{[%-5p] %d{HH:mm:ss.SSS} %m (%F:%L)[%M]%n}{FATAL=Bright Red,ERROR=Red,WARN=Yellow,INFO=Green,DEBUG=Blue,TRACE=White}
|
||||||
|
|
||||||
|
appender.logrolling.type=RollingFile
|
||||||
|
appender.logrolling.name=infoLogFile
|
||||||
|
appender.logrolling.append=true
|
||||||
|
appender.logrolling.fileName=./log/cm.log
|
||||||
|
appender.logrolling.filePattern=./log/cm-%i.log
|
||||||
|
appender.logrolling.layout.type=PatternLayout
|
||||||
|
appender.logrolling.layout.pattern=[%-5p] %d{HH:mm:ss.SSS} %m (%F:%L)[%M]%n
|
||||||
|
appender.logrolling.policies.type = Policies
|
||||||
|
appender.logrolling.policies.size.type = SizeBasedTriggeringPolicy
|
||||||
|
appender.logrolling.policies.size.size = 100MB
|
||||||
|
appender.logrolling.strategy.type = DefaultRolloverStrategy
|
||||||
|
appender.logrolling.strategy.max = 5
|
||||||
|
|
||||||
|
appender.errrolling.type=RollingFile
|
||||||
|
appender.errrolling.name=errorLogFile
|
||||||
|
appender.errrolling.append=true
|
||||||
|
appender.errrolling.fileName=./log/cm.err
|
||||||
|
appender.errrolling.filePattern=./log/cm-%i.err
|
||||||
|
appender.errrolling.layout.type=PatternLayout
|
||||||
|
appender.errrolling.layout.pattern=[%-5p] %d{HH:mm:ss.SSS} %m (%F:%L)[%M]%n
|
||||||
|
appender.errrolling.policies.type = Policies
|
||||||
|
appender.errrolling.policies.size.type = SizeBasedTriggeringPolicy
|
||||||
|
appender.errrolling.policies.size.size = 100MB
|
||||||
|
appender.errrolling.strategy.type = DefaultRolloverStrategy
|
||||||
|
appender.errrolling.strategy.max = 5
|
||||||
|
|
||||||
|
rootLogger.level=debug
|
||||||
|
rootLogger.appenderRef.stdout.ref=STDOUT
|
||||||
|
rootLogger.appenderRef.errorFile.ref=errorLogFile
|
||||||
|
rootLogger.appenderRef.errorFile.level=error
|
||||||
|
rootLogger.appenderRef.infoFile.ref=infoLogFile
|
||||||
|
rootLogger.appenderRef.infoFile.level=info
|
||||||
|
rootLogger.appenderRef.log.ref=log
|
Loading…
Reference in New Issue
Block a user