add nodecenterws config

This commit is contained in:
CaiHQ 2022-03-30 11:17:08 +08:00
parent aacd939408
commit 0a24986907
3 changed files with 29 additions and 1 deletions

View File

@ -162,7 +162,7 @@ public class CMHttpServer {
String[] paths = cmdConf.startContract.split(",");
for (String path : paths) {
File f = new File(path);
if (!f.getName().endsWith(".ypk"))
if (!f.getName().endsWith(".ypk") || !f.exists())
continue;
Contract c = new Contract();
c.setScript(f.getAbsolutePath());

View File

@ -45,6 +45,7 @@ public class GlobalConf {
public String ipPort;
public boolean isLAN = true;
private String nodeCenterUrl; // 从ConfigDB读
private String nodeCenterWSUrl;
private static GlobalConf init() {
java.util.logging.Logger.getLogger(org.bdware.bdledger.api.grpc.Client.class.getName())
@ -157,6 +158,8 @@ public class GlobalConf {
conf.isLAN = "true".equals(KeyValueDBUtil.instance.getValue(dbName, "isLAN"));
conf.masterAddress = KeyValueDBUtil.instance.getValue(dbName, "masterAddress");
conf.nodeCenterUrl = KeyValueDBUtil.instance.getValue(dbName, "nodeCenter");
conf.nodeCenterWSUrl = KeyValueDBUtil.instance.getValue(dbName, "nodeCenterWS");
conf.peerID = KeyValueDBUtil.instance.getValue(dbName, "peerID");
conf.keyPairStr = KeyValueDBUtil.instance.getValue(dbName, "keyPairStr");
// logger.debug("keyPairStr" + conf.keyPairStr);
@ -355,6 +358,19 @@ public class GlobalConf {
}
}
public static boolean resetNodeCenterWS(String val) {
try {
instance.nodeCenterWSUrl = val;
KeyValueDBUtil.instance.setValue(CMTables.ConfigDB.toString(), "nodeCenterWS", val);
return true;
} catch (Exception e) {
LOGGER.error(e.getMessage());
LOGGER.debug(ExceptionUtil.exceptionToString(e));
return false;
}
}
public static boolean resetDeviceName(String val) {
try {
KeyValueDBUtil.instance.setValue(CMTables.ConfigDB.toString(), "nodeName", val);
@ -460,6 +476,10 @@ public class GlobalConf {
return instance.keyPair.getPublicKeyStr();
}
public static String getNodeCenterWSUrl() {
return instance.nodeCenterWSUrl;
}
public boolean resetLicenceInternal(String licence2) {
licence2 = licence2.replaceAll(" ", "+");
LOGGER.info("resetLicence:" + licence2);

View File

@ -154,6 +154,7 @@ public class ManagerActions {
data.put("clusterConnected", String.valueOf(NetworkManager.instance.isConnectedToNodeCenter()));
data.put("nodePubKey", GlobalConf.instance.keyPair.getPublicKeyStr());
data.put("masterAddress", GlobalConf.instance.masterAddress);
data.put("nodeCenterWS",GlobalConf.getNodeCenterWSUrl());
ReplyUtil.replyWithStatus(resultCallback, "onLoadNodeConfig", true, data);
}
@ -163,6 +164,13 @@ public class ManagerActions {
LOGGER.debug(JsonUtil.toJson(args));
ReplyUtil.replyWithStatus(resultCallback, "onChangeNodeCenter", true, GlobalConf.resetNodeCenter(val));
}
@Action(userPermission = 1 << 10)
public void changeNodeCenterWS(JsonObject args, ResultCallback resultCallback) {
String val = args.get("data").getAsString();
LOGGER.debug(JsonUtil.toJson(args));
ReplyUtil.replyWithStatus(resultCallback, "onChangeNodeCenter", true, GlobalConf.resetNodeCenterWS(val));
}
@Action(userPermission = 1 << 10)
public void changeBDledger(JsonObject args, ResultCallback resultCallback) {