fix sigar dynamiclib missing

fix netty dynamiclib missing
fix BCOManager
This commit is contained in:
CaiHQ 2023-03-30 23:51:52 +08:00
parent 8fa064ee8a
commit e76865fb09
12 changed files with 39 additions and 38 deletions

View File

@ -36,16 +36,21 @@ dependencies {
implementation project(":front-base")
implementation project(":consistency-sdk")
implementation 'io.prometheus:simpleclient_httpserver:0.12.0'
implementation 'org.knowhowlab.osgi:sigar:1.6.5_01'
implementation 'org.hyperic.sigar:sigar:1.6.4'
implementation 'io.grpc:grpc-all:1.43.1'
implementation 'org.apache.velocity:velocity-engine-core:2.3'
implementation 'com.nimbusds:nimbus-jose-jwt:9.10'
implementation 'org.bdware.doip:doip-sdk:1.3.8'
implementation 'org.bdware.doip:doip-audit-tool:1.1.9'
implementation 'org.bdware.doip:bdosclient:0.0.1'
implementation 'org.bdware.doip:doip-audit-tool:1.2.0'
implementation 'org.bdware.doip:bdosclient:0.0.2'
implementation fileTree(dir: 'lib', include: '*.jar')
testImplementation 'junit:junit:4.13.2'
implementation group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: '2.0.50.Final'
implementation 'io.netty:netty-tcnative-boringssl-static:2.0.59.Final'
implementation 'io.netty:netty-tcnative-boringssl-static:2.0.59.Final-linux-aarch_64-fedora'
// implementation 'io.netty:netty-tcnative-boringssl-static:2.0.59.Final'
// implementation 'io.netty:netty-tcnative-boringssl-static:2.0.59.Final'
// implementation 'io.netty:netty-tcnative-boringssl-static:2.0.59.Final'
// implementation 'io.netty:netty-tcnative-boringssl-static:2.0.59.Final'
}
compileJava {

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -256,7 +256,6 @@ public class CMHttpServer {
cmdConf.parseArgs(args);
configServer(cmdConf);
// check default key pair
File keyFile = new File("manager.key");
if (keyFile.exists()) {
@ -282,7 +281,6 @@ public class CMHttpServer {
} catch (IOException ignored) {
}
}
GlobalConf.initIpPort(cmdConf.ip + ":" + cmdConf.servicePort);
GlobalConf.initMasterAddress(cmdConf.ip + ":" + (cmdConf.servicePort + 1));
start(cmdConf.servicePort);
@ -291,8 +289,6 @@ public class CMHttpServer {
public static void start(int port) throws IOException {
LOGGER.info("start server at:" + port);
LOGGER.debug("dir:" + new File("./").getAbsolutePath());
new CMHttpServer(port).start();
//never reach here!!
}

View File

@ -81,16 +81,8 @@ public class GlobalConf {
try {
String dbName = CMTables.ConfigDB.toString();
Class<?> clz = com.sleepycat.je.utilint.Tracer.class;
URL uri = clz.getClassLoader().getResource("com/sleepycat/je/utilint/Tracer.class");
LOGGER.debug(null == uri ? "uri is null!" : uri.getPath());
clz = com.sleepycat.je.log.FileHeader.class;
uri = clz.getClassLoader().getResource("com/sleepycat/je/log/FileHeader.class");
LOGGER.debug(null == uri ? "uri is null!" : uri.getPath());
if (!KeyValueDBUtil.instance.getKeys(dbName).contains("hasInited")) {
KeyValueDBUtil.instance.setValue(dbName, "hasInited", "true");
KeyValueDBUtil.instance.setValue(
dbName, "projectDir", new File("./BDWareProjectDir/").getAbsolutePath());
KeyValueDBUtil.instance.setValue(
@ -140,7 +132,7 @@ public class GlobalConf {
KeyValueDBUtil.instance.setValue(dbName, "nodeName", deviceName.substring(0, 10));
KeyValueDBUtil.instance.setValue(dbName, "masterAddress", "null");
KeyValueDBUtil.instance.setValue(dbName, "ipPort", "null");
KeyValueDBUtil.instance.setValue(dbName, "nodeCenter", "ws://127.0.0.1:18002");
KeyValueDBUtil.instance.setValue(dbName, "nodeCenter", "ws://127.0.0.1:18005");
KeyValueDBUtil.instance.setValue(
dbName,
"datachainConf",
@ -178,6 +170,7 @@ public class GlobalConf {
loadDOAConfig(conf.doaConf, KeyValueDBUtil.instance.getValue(dbName, "doipConfig"));
} catch (Exception e) {
LOGGER.error(e.getMessage());
e.printStackTrace();
LOGGER.debug(ExceptionUtil.exceptionToString(e));
}
// verifyLicence(conf);

View File

@ -11,33 +11,40 @@ import org.bdware.doip.audit.client.AuditIrpClient;
import org.bdware.doip.audit.writer.AuditType;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.client.DoipMessageCallback;
import org.bdware.irp.client.IrpClient;
import org.bdware.sc.db.CMTables;
import org.bdware.sc.db.KeyValueDBUtil;
import org.bdware.server.GlobalConf;
import org.zz.gmhelper.SM2KeyPair;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
public class BCOManager {
private final String codeRepoDoid;
private final String routerURI;
private final SM2KeyPair keyPair;
CodeRepoClient client;
File bcodir;
IrpClient irpClient;
static Logger LOGGER = LogManager.getLogger(BCOManager.class);
public BCOManager(String doid, File bcoDir, IrpClient irpClient, SM2KeyPair keyPair) {
String codeRepoDoid = CodeRepoClient.getDefaultCodeRepo(doid);
this.irpClient = irpClient;
public BCOManager(String doid, File bcoDir, String routerURI, SM2KeyPair keyPair) {
this.bcodir = bcoDir;
client = new CodeRepoClient(codeRepoDoid, irpClient, keyPair);
this.codeRepoDoid = CodeRepoClient.getDefaultCodeRepo(doid);
this.routerURI = routerURI;
this.keyPair = keyPair;
}
public String download(String bCoId) {
if (client == null) {
EndpointConfig config = new EndpointConfig();
config.routerURI = GlobalConf.instance.doaConf.lhsAddress;
config.auditType = AuditType.None;
AuditIrpClient irpClient = new AuditIrpClient(codeRepoDoid, config);
client = new CodeRepoClient(codeRepoDoid, irpClient, keyPair);
}
YPKInfo ypkInfo = new YPKInfo();
client.retrieveBCO(bCoId, new DoipMessageCallback() {
@Override
public void onResult(DoipMessage doipMessage) {
String body = doipMessage.body.getDataAsJsonString();
LOGGER.info("Retrieve " + bCoId + " Result:" + body);
YPKInfo parsed = new Gson().fromJson(body, YPKInfo.class);
if (parsed != null && parsed.md5 != null && parsed.status == UploadingStatus.Finished) {
ypkInfo.copyFrom(parsed);
@ -54,13 +61,18 @@ public class BCOManager {
} catch (Exception e) {
}
}
LOGGER.info("Download:" + new Gson().toJson(ypkInfo));
if (ypkInfo.status == UploadingStatus.Finished) {
File target = getYpkFile(ypkInfo);
if (target.exists() && (client.calFileMd5(target.getAbsolutePath()) + ".ypk").equals(target.getName()))
return target.getAbsolutePath();
DownloadProgressChecker checker = new DownloadProgressChecker();
client.downloadYPK(bCoId, checker, target);
LOGGER.info("start Download:" + new Gson().toJson(ypkInfo));
checker.waitForResult(30000);
LOGGER.info("checker:" + checker.isSuccess);
if (checker.isSuccess)
return target.getAbsolutePath();
}
@ -97,6 +109,7 @@ public class BCOManager {
synchronized (this) {
this.notify();
}
LOGGER.info("[Download error]" + s + " doipMessage:" + doipMessage.body.getDataAsJsonString());
}

View File

@ -8,7 +8,6 @@ import io.netty.channel.ChannelHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.EndpointConfig;
import org.bdware.doip.audit.client.AuditIrpClient;
import org.bdware.doip.audit.server.DefaultRepoHandlerInjector;
import org.bdware.doip.codec.digitalObject.DigitalObject;
import org.bdware.doip.codec.digitalObject.DoType;
@ -51,15 +50,9 @@ public class ContractRepositoryHandler extends RepositoryHandlerBase implements
super(info);
GlobalConf.DOAConf doaConf = GlobalConf.instance.doaConf;
String bcoDir = GlobalConf.instance.bcoDir;
EndpointConfig config = new EndpointConfig();
config.routerURI = doaConf.lhsAddress;
AuditIrpClient client = new AuditIrpClient(config);
bcoManager = new BCOManager(doaConf.repoDoid, new File(bcoDir), client, GlobalConf.instance.keyPair);
bcoManager = new BCOManager(doaConf.repoDoid, new File(bcoDir), doaConf.lhsAddress, GlobalConf.instance.keyPair);
}
CMActions cmActions = new CMActions();
@Override
public DoipMessage handleHello(DoipMessage doipMessage) {
return replyDoipServiceInfo(doipMessage);
@ -97,9 +90,9 @@ public class ContractRepositoryHandler extends RepositoryHandlerBase implements
e.printStackTrace(new PrintStream(bo));
return replyStringWithStatus(doipMessage, "exception:" + new String(bo.toByteArray()), DoipResponseCode.Invalid);
}
DoipMessage[] content = new DoipMessage[1];
digitalObject.attributes.addProperty("verifiedPubKey", doipMessage.credential.getSigner());
String path = null;
LOGGER.info("create BDO, bCoId:" + digitalObject.attributes.get("bCoId").getAsString());
if (digitalObject.attributes.has("bCoId"))
path = bcoManager.download(digitalObject.attributes.get("bCoId").getAsString());

View File

@ -1,5 +1,6 @@
package org.bdware.server.doip;
import com.google.gson.Gson;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.EndpointConfig;
@ -19,8 +20,8 @@ public class ContractRepositoryMain {
public static void start() {
try {
LOGGER.info("DOIPServer, start" + new Gson().toJson(GlobalConf.instance.doaConf));
String url = GlobalConf.instance.doaConf.doipAddress;
LOGGER.info("DOIPServer start:" + url);
if (url == null || GlobalConf.instance.doaConf.repoDoid.isEmpty()) {
LOGGER.warn("missing args, failed to start! url:" + url + " doid:" + GlobalConf.instance.doaConf.repoDoid);
return;
@ -37,7 +38,7 @@ public class ContractRepositoryMain {
config.auditType = AuditType.None;
config.routerURI = GlobalConf.instance.doaConf.lhsAddress;
config.repoName = GlobalConf.instance.doaConf.repoName;
currentServer = new AuditDoipServer(config);
currentServer = new AuditDoipServer(config, info);
currentServer.setRepositoryHandler(new ContractRepositoryHandler(info));
currentServer.start();
} catch (Exception e) {

View File

@ -25,7 +25,7 @@ public class BCOManagerTest {
// config.privateKey = key.getPrivateKeyStr();
// config.publicKey = key.getPublicKeyStr();
this.bcoManager = new BCOManager("bdtest/CodeRepository", new File("./BDWareProjectDir/bco"), client, key);
this.bcoManager = new BCOManager("bdtest/CodeRepository", new File("./BDWareProjectDir/bco"), config.routerURI, key);
}
@Test