support ledgerparams

add startContract at cmconfig.json
add docker scripts
This commit is contained in:
CaiHQ 2022-03-22 23:52:01 +08:00
parent b1bf67c802
commit aacd939408
6 changed files with 85 additions and 18 deletions

View File

@ -81,6 +81,7 @@ task copyScript(type: Copy) {
include 'cmstop.sh'
include 'cmconfig.json.template'
include 'killContracts.sh'
include 'generatekey.sh'
}
into "./build/output"
println("copyScript done !")
@ -110,8 +111,12 @@ task copyDynamicLibrary(type: Copy) {
from './dynamicLibrary/'
into './build/output/dynamicLibrary'
}
task copyCustomPlugin(type: Copy) {
from '../custom-plugin/build/libs/custom-plugin.jar'
into "./build/output/libs/"
}
task copyLibs(type: Copy, dependsOn: ["copyScript", 'copySsl']) {
task copyLibs(type: Copy, dependsOn: ["copyScript", 'copySsl', 'copyCustomPlugin']) {
from configurations.runtimeClasspath
into "./build/output/libs/"
}
@ -154,11 +159,6 @@ task copyDockerfile(type: Copy) {
into "./build/"
}
//task copyCP(type: Copy, dependsOn: ":cp:buildBundle") {
// from "../cp/build/output"
// into "./build/output"
//}
task copyKeys(type: Copy) {
from "./keys"
into "./build/output/keys"

View File

@ -1,11 +1,38 @@
# 配置项
## wsPluginActions: WS端,包括contractManagerFrameHandler和CMHttpHandler
## clientToAgentPlugins: client -> cluster 包括MasterClientFrameHandler
## clientToClusterPlugins:[], client -> NodeCenterClientHandler
## tcpPlugins:tcp 包括TcpserverFrameHandler
# 配置说明
## 使用字符串分割如需添加多项在agent-backend/script/config.json.template里修改如:
## 示例格式
```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,
"consistencyPlugins": "./libs/custom-plugin.jar"
}
```
## 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

3
script/generatekey.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
echo "generate manger.key, manager.keypair!"
java -cp cp/libs:cp/yjs.jar org.bdware.sc.SM2Helper generateKeyToFile

View File

@ -22,12 +22,15 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.bdware.sc.*;
import org.bdware.sc.bean.Contract;
import org.bdware.sc.bean.ContractExecType;
import org.bdware.sc.db.CMTables;
import org.bdware.sc.db.KeyValueDBUtil;
import org.bdware.sc.db.MultiIndexTimeRocksDBUtil;
import org.bdware.sc.util.ExceptionUtil;
import org.bdware.sdk.consistency.ConsistencyPluginManager;
import org.bdware.server.action.FileActions;
import org.bdware.server.action.UserManagerAction;
import org.bdware.server.doip.ContractRepositoryMain;
import org.bdware.server.http.CMHttpHandler;
import org.bdware.server.nodecenter.client.NodeCenterClientHandler;
@ -153,6 +156,23 @@ public class CMHttpServer {
if (cmdConf.overwrite) {
cmdConf.write(CONFIG_PATH);
}
if (cmdConf.startContract != null && cmdConf.startContract.length() > 0) {
ContractManager.scheduledThreadPool.schedule(
() -> {
String[] paths = cmdConf.startContract.split(",");
for (String path : paths) {
File f = new File(path);
if (!f.getName().endsWith(".ypk"))
continue;
Contract c = new Contract();
c.setScript(f.getAbsolutePath());
c.setType(ContractExecType.Sole);
c.setOwner(UserManagerAction.getNodeManager());
ContractManager.instance.startContract(c);
}
},
10, TimeUnit.SECONDS);
}
}
private static String[] parseStrAsList(String str) {

View File

@ -1,6 +1,7 @@
package org.bdware.server;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
@ -247,6 +248,27 @@ public class GRPCPool implements ChainOpener {
}
}
@Override
public JsonObject getLedgerParams() {
JsonObject jo = new JsonObject();
JsonArray jsonArray = new JsonArray();
String conf = GlobalConf.instance.datachainConf;
conf = conf.replaceAll(",", "\n");
Scanner sc = new Scanner(new ByteArrayInputStream(conf.getBytes()));
while (sc.hasNextLine()) {
String str = sc.nextLine();
String[] ipAndPort = str.split(":");
String ip = ipAndPort[0];
int port = Integer.parseInt(ipAndPort[1]);
JsonObject client = new JsonObject();
client.addProperty("ip", ip);
client.addProperty("port", port);
jsonArray.add(client);
}
jo.add("nodes", jsonArray);
return jo;
}
@Override
public void reRegister(String doid) {
//TODO just success

View File

@ -84,11 +84,6 @@ public class CMActions implements OnHashCallback {
}
}
LOGGER.info(
"reconnectDone! "
+ (System.currentTimeMillis() - start)
+ " --> "
+ contractManager.getContractDespList().size());
NetworkManager.instance.waitForNodeCenterConnected();
ExecutionManager.instance.updateLocalContractToNodeCenter();
});