mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-09 01:14:06 +00:00
add update node manager
This commit is contained in:
parent
e93c07ed84
commit
7c91416350
@ -1,62 +1,77 @@
|
||||
# 配置项
|
||||
|
||||
## 示例格式
|
||||
|
||||
```json
|
||||
{
|
||||
"cmi":"",
|
||||
"debug":"",
|
||||
"disableDoRepo":false,
|
||||
"disableLocalLhs":false,
|
||||
"doipCertPath":"",
|
||||
"doipLhsAddress":"",
|
||||
"doipPort":-1,
|
||||
"doipUserHandle":"",
|
||||
"enableEventPersistence":false,
|
||||
"enableSsl":"./ssl/chained.pem:./ssl/domain.pem",
|
||||
"ip":"127.0.0.1",
|
||||
"isLAN":true,
|
||||
"overwrite":false,
|
||||
"servicePort":21030,
|
||||
"textFileSuffixes":".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv",
|
||||
"withBdledgerClient":"./runnable/bdledger_mac",
|
||||
"withBdledgerServer":false,
|
||||
"cmi": "",
|
||||
"debug": "",
|
||||
"disableDoRepo": false,
|
||||
"disableLocalLhs": false,
|
||||
"doipCertPath": "",
|
||||
"doipLhsAddress": "",
|
||||
"doipPort": -1,
|
||||
"doipUserHandle": "",
|
||||
"enableEventPersistence": false,
|
||||
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
|
||||
"ip": "127.0.0.1",
|
||||
"isLAN": true,
|
||||
"overwrite": false,
|
||||
"servicePort": 21030,
|
||||
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv",
|
||||
"withBdledgerClient": "./runnable/bdledger_mac",
|
||||
"withBdledgerServer": false,
|
||||
"consistencyPlugins": "./libs/custom-plugin.jar",
|
||||
"startContract": [],
|
||||
"datachainConf": "021.node.internetapi.cn:21121"
|
||||
}
|
||||
```
|
||||
|
||||
## consistencyPlugins 配置
|
||||
|
||||
下述四项插件使用字符串分割,如需添加多项,以逗号分隔,在cmconfig.json里修改如:
|
||||
|
||||
``````
|
||||
"consistencyPlugins": "xxx/xxx.jar,xxx/xxx.jar"
|
||||
``````
|
||||
|
||||
## 通讯插件配置
|
||||
|
||||
下述四项插件使用字符串分割,如需添加多项,在cmconfig.json里修改如:
|
||||
|
||||
``````
|
||||
"wsPluginActions": "org.bdware.metering.MeteringAction"
|
||||
``````
|
||||
|
||||
1. wsPluginActions: WS端,包括contractManagerFrameHandler和CMHttpHandler
|
||||
2. clientToAgentPlugins: client -> cluster 包括MasterClientFrameHandler
|
||||
3. clientToClusterPlugins:[], client -> NodeCenterClientHandler
|
||||
4. tcpPlugins:tcp 包括TcpserverFrameHandler
|
||||
|
||||
## startContract配置说明
|
||||
|
||||
其中startConfig.json为json数组结构,格式如下:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"path": "./BDWareProjectDir/publicCompiled/xxx.ypk",
|
||||
"owner": "",
|
||||
"killBeforeStart": "",
|
||||
"createParam": {}
|
||||
},
|
||||
{
|
||||
...
|
||||
|
||||
}
|
||||
]
|
||||
```
|
||||
path为必填配置项。表示启动的ypk的路径。
|
||||
owner为可选配置,不填时,使用NodeManger的key作为Owner。
|
||||
killBeforeStart为可选配置,填写kill的合约名称。
|
||||
createParam为可选配置。表示合约的启动参数。
|
||||
```
|
||||
|
||||
## datachainConf 配置说明
|
||||
|
||||
1.针对Window Docker/Mac Docker
|
||||
可使用`"datachainConf":"host.docker.internal:2401"`进行配置。
|
||||
2.针对Linux Docker,可通过查看`docker 0`的网卡IP进行设置。
|
||||
|
@ -168,6 +168,9 @@ public class CMHttpServer {
|
||||
Contract c = new Contract();
|
||||
c.setScript(f.getAbsolutePath());
|
||||
c.setType(ContractExecType.Sole);
|
||||
if (jo.has("killBeforeStart")) {
|
||||
ContractManager.instance.stopContract(jo.get("killBeforeStart").getAsString());
|
||||
}
|
||||
if (jo.has("owner"))
|
||||
c.setOwner(jo.get("owner").getAsString());
|
||||
else
|
||||
@ -182,7 +185,7 @@ public class CMHttpServer {
|
||||
},
|
||||
10, TimeUnit.SECONDS);
|
||||
}
|
||||
if (cmdConf.datachainConf!=null){
|
||||
if (cmdConf.datachainConf != null) {
|
||||
GlobalConf.resetDataChain(cmdConf.datachainConf);
|
||||
}
|
||||
if (cmdConf.overwrite) {
|
||||
|
@ -76,22 +76,23 @@ public class MultiRequestInfo {
|
||||
if (-1 == cei.curExeSeq)
|
||||
cei.curExeSeq = mri.seq;
|
||||
//logger.info("调试位置 3 cei.curExeSeq=" + cei.curExeSeq + " MultiRequestInfo 执行请求 " + request.seq + " uniID=" + uniID + " Thread-id=" + Thread.currentThread().getId());
|
||||
String data2 = CMActions.manager.executeLocally(request, null);
|
||||
// logger.info("本地执行的结果为\n" + data2);
|
||||
Map<String, String> ret = new HashMap<>();
|
||||
ret.put("action", "receiveTrustfullyResult");
|
||||
SM2KeyPair keyPair = GlobalConf.instance.keyPair;
|
||||
ret.put("nodeID", keyPair.getPublicKeyStr());
|
||||
int seq = request.seq;
|
||||
CMActions.manager.executeLocallyAsync(request, new ResultCallback() {
|
||||
@Override
|
||||
public void onResult(String str) {
|
||||
Map<String, String> ret = new HashMap<>();
|
||||
ret.put("action", "receiveTrustfullyResult");
|
||||
SM2KeyPair keyPair = GlobalConf.instance.keyPair;
|
||||
ret.put("nodeID", keyPair.getPublicKeyStr());
|
||||
int seq = request.seq;
|
||||
|
||||
ret.put("responseID", uniID);
|
||||
ret.put("executeTime", (System.currentTimeMillis() - start) + "");
|
||||
ret.put("data", data2);
|
||||
mri.countIncrease();
|
||||
|
||||
//logger.info("返回 uniID=" + uniID + " 的结果");
|
||||
|
||||
mri.callbackMap.get(uniID).onResult(JsonUtil.toJson(ret));
|
||||
ret.put("responseID", uniID);
|
||||
ret.put("executeTime", (System.currentTimeMillis() - start) + "");
|
||||
ret.put("data", str);
|
||||
mri.countIncrease();
|
||||
//logger.info("返回 uniID=" + uniID + " 的结果");
|
||||
mri.callbackMap.get(uniID).onResult(JsonUtil.toJson(ret));
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
public synchronized void countIncrease() {
|
||||
|
@ -42,6 +42,31 @@ public class UserManagerAction {
|
||||
handler = contractManagerFrameHandler;
|
||||
}
|
||||
|
||||
@Action(userPermission = 0)
|
||||
public void resetNodeManager(JsonObject json, ResultCallback resultCallback) {
|
||||
getNodeRole(json, new ResultCallback() {
|
||||
@Override
|
||||
public void onResult(String str) {
|
||||
if (str.contains("NodeManager")) {
|
||||
if (json.has("newPubKey")) {
|
||||
String newPubKey = json.get("newPubKey").getAsString();
|
||||
KeyValueDBUtil.instance.setValue(CMTables.ConfigDB.toString(), NodeManager, newPubKey);
|
||||
KeyValueDBUtil.instance.setValue(
|
||||
CMTables.NodeRole.toString(), newPubKey, "NodeManager");
|
||||
resultCallback.onResult("{\"action\":\"onResetNodeManager\",\"data\":\"success\",\"pubKey\":\""
|
||||
+ newPubKey + "\"}");
|
||||
} else {
|
||||
//just keep the same
|
||||
resultCallback.onResult("{\"action\":\"onResetNodeManager\",\"data\":\"success\",\"pubKey\":\""
|
||||
+ getPubKey(json) + "\"}");
|
||||
}
|
||||
} else {
|
||||
resultCallback.onResult("{\"action\":\"onResetNodeManager\",\"data\":\"failed, no permission\"}");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Action(userPermission = 0)
|
||||
public void getSessionID(JsonObject json, ResultCallback resultCallback) {
|
||||
|
@ -278,15 +278,17 @@ public class NodeCenterClientController implements NodeCenterConn {
|
||||
String requestID = jo.get("requestID").getAsString();
|
||||
String requesterNodeID = jo.get("requesterNodeID").getAsString();
|
||||
String crStr = jo.get("contractRequest").getAsString();
|
||||
String cr =
|
||||
CMActions.manager.executeLocally(
|
||||
JsonUtil.fromJson(crStr, ContractRequest.class), null);
|
||||
JsonObject ret = new JsonObject();
|
||||
ret.addProperty("action", "onReceiveContractExecution");
|
||||
ret.addProperty("requestID", requestID);
|
||||
ret.addProperty("requesterNodeID", requesterNodeID);
|
||||
ret.addProperty("contractResult", cr);
|
||||
sendMsg(JsonUtil.toJson(ret));
|
||||
CMActions.manager.executeLocallyAsync(JsonUtil.fromJson(crStr, ContractRequest.class), new ResultCallback() {
|
||||
@Override
|
||||
public void onResult(String str) {
|
||||
JsonObject ret = new JsonObject();
|
||||
ret.addProperty("action", "onReceiveContractExecution");
|
||||
ret.addProperty("requestID", requestID);
|
||||
ret.addProperty("requesterNodeID", requesterNodeID);
|
||||
ret.addProperty("contractResult", str);
|
||||
sendMsg(JsonUtil.toJson(ret));
|
||||
}
|
||||
},null);
|
||||
}
|
||||
|
||||
@Action(async = true)
|
||||
|
Loading…
Reference in New Issue
Block a user