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