diff --git a/build.gradle b/build.gradle index 4ab8b6f..0aad91f 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/dynamicLibrary/libnetty_tcnative_linux_aarch_64.so b/dynamicLibrary/libnetty_tcnative_linux_aarch_64.so new file mode 100644 index 0000000..00babe5 Binary files /dev/null and b/dynamicLibrary/libnetty_tcnative_linux_aarch_64.so differ diff --git a/dynamicLibrary/libnetty_tcnative_linux_x86_64.so b/dynamicLibrary/libnetty_tcnative_linux_x86_64.so new file mode 100644 index 0000000..fa8a8eb Binary files /dev/null and b/dynamicLibrary/libnetty_tcnative_linux_x86_64.so differ diff --git a/dynamicLibrary/libsigar-aarch64-linux.so b/dynamicLibrary/libsigar-aarch64-linux.so new file mode 100644 index 0000000..1f8979f Binary files /dev/null and b/dynamicLibrary/libsigar-aarch64-linux.so differ diff --git a/dynamicLibrary/netty-tcnative-boringssl-static-2.0.59.Final-20230213.120010-1-linux-aarch_64.jar b/dynamicLibrary/netty-tcnative-boringssl-static-2.0.59.Final-20230213.120010-1-linux-aarch_64.jar new file mode 100644 index 0000000..fdcdd70 Binary files /dev/null and b/dynamicLibrary/netty-tcnative-boringssl-static-2.0.59.Final-20230213.120010-1-linux-aarch_64.jar differ diff --git a/dynamicLibrary/netty-tcnative-boringssl-static-2.0.59.Final-20230213.120010-1-linux-x86_64.jar b/dynamicLibrary/netty-tcnative-boringssl-static-2.0.59.Final-20230213.120010-1-linux-x86_64.jar new file mode 100644 index 0000000..416e721 Binary files /dev/null and b/dynamicLibrary/netty-tcnative-boringssl-static-2.0.59.Final-20230213.120010-1-linux-x86_64.jar differ diff --git a/src/main/java/org/bdware/server/CMHttpServer.java b/src/main/java/org/bdware/server/CMHttpServer.java index 1e0d5a1..da7124c 100644 --- a/src/main/java/org/bdware/server/CMHttpServer.java +++ b/src/main/java/org/bdware/server/CMHttpServer.java @@ -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!! } diff --git a/src/main/java/org/bdware/server/GlobalConf.java b/src/main/java/org/bdware/server/GlobalConf.java index 9c9c139..6451776 100644 --- a/src/main/java/org/bdware/server/GlobalConf.java +++ b/src/main/java/org/bdware/server/GlobalConf.java @@ -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); diff --git a/src/main/java/org/bdware/server/doip/BCOManager.java b/src/main/java/org/bdware/server/doip/BCOManager.java index fc72be7..924cf90 100644 --- a/src/main/java/org/bdware/server/doip/BCOManager.java +++ b/src/main/java/org/bdware/server/doip/BCOManager.java @@ -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()); } diff --git a/src/main/java/org/bdware/server/doip/ContractRepositoryHandler.java b/src/main/java/org/bdware/server/doip/ContractRepositoryHandler.java index 37b4b4f..7e402f5 100644 --- a/src/main/java/org/bdware/server/doip/ContractRepositoryHandler.java +++ b/src/main/java/org/bdware/server/doip/ContractRepositoryHandler.java @@ -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()); diff --git a/src/main/java/org/bdware/server/doip/ContractRepositoryMain.java b/src/main/java/org/bdware/server/doip/ContractRepositoryMain.java index a6555b4..3d9c9aa 100644 --- a/src/main/java/org/bdware/server/doip/ContractRepositoryMain.java +++ b/src/main/java/org/bdware/server/doip/ContractRepositoryMain.java @@ -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) { diff --git a/src/test/java/org/bdware/server/doip/BCOManagerTest.java b/src/test/java/org/bdware/server/doip/BCOManagerTest.java index 1f024b2..44c284b 100644 --- a/src/test/java/org/bdware/server/doip/BCOManagerTest.java +++ b/src/test/java/org/bdware/server/doip/BCOManagerTest.java @@ -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