mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
add update node manager
This commit is contained in:
parent
e93c07ed84
commit
7c91416350
@ -1,5 +1,7 @@
|
|||||||
# 配置项
|
# 配置项
|
||||||
|
|
||||||
## 示例格式
|
## 示例格式
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"cmi": "",
|
"cmi": "",
|
||||||
@ -24,39 +26,52 @@
|
|||||||
"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
|
||||||
|
@ -76,8 +76,9 @@ 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
|
||||||
|
public void onResult(String str) {
|
||||||
Map<String, String> ret = new HashMap<>();
|
Map<String, String> ret = new HashMap<>();
|
||||||
ret.put("action", "receiveTrustfullyResult");
|
ret.put("action", "receiveTrustfullyResult");
|
||||||
SM2KeyPair keyPair = GlobalConf.instance.keyPair;
|
SM2KeyPair keyPair = GlobalConf.instance.keyPair;
|
||||||
@ -86,13 +87,13 @@ public class MultiRequestInfo {
|
|||||||
|
|
||||||
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() {
|
||||||
int tmp = count.incrementAndGet();
|
int tmp = count.incrementAndGet();
|
||||||
|
@ -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,16 +278,18 @@ 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)
|
||||||
public void onReceiveContractExecution(JsonObject jo, ResultCallback resultCallback) {
|
public void onReceiveContractExecution(JsonObject jo, ResultCallback resultCallback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user