From bc4eb8b828e487c8d38c9b627eff26eb26daa663 Mon Sep 17 00:00:00 2001 From: "Frank.R.Wu" Date: Thu, 23 Dec 2021 21:42:41 +0800 Subject: [PATCH] chore: update build.gradle upgrade io.grpc:grpc-all from 1.41.0 (uses io.netty:4.1.52.Final) to 1.43.1 (uses io.netty:4.1.63.Final); optimize logs in CMHttpHandler and NetworkManager; rename CMHttpServer.parseConf to CMHttpServer.configServer --- build.gradle | 2 +- src/main/java/org/bdware/server/CMHttpServer.java | 8 ++++---- src/main/java/org/bdware/server/http/CMHttpHandler.java | 7 ++++++- src/main/java/org/bdware/units/NetworkManager.java | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 82a93fb..9b842fc 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ dependencies { implementation project(":front-base") implementation 'io.prometheus:simpleclient_httpserver:0.12.0' implementation 'org.knowhowlab.osgi:sigar:1.6.5_01' - implementation 'io.grpc:grpc-all:1.41.0' + 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' testImplementation 'junit:junit:4.13.2' diff --git a/src/main/java/org/bdware/server/CMHttpServer.java b/src/main/java/org/bdware/server/CMHttpServer.java index be0a588..9251d88 100644 --- a/src/main/java/org/bdware/server/CMHttpServer.java +++ b/src/main/java/org/bdware/server/CMHttpServer.java @@ -59,7 +59,7 @@ public class CMHttpServer { this.port = port; } - private static void parseConf(CMDConf cmdConf) throws IOException { + private static void configServer(CMDConf cmdConf) throws IOException { if (cmdConf.disableDoRepo) { DoConfig.callContractUsingDOI = false; } @@ -103,7 +103,6 @@ public class CMHttpServer { String[] filePaths = cmdConf.enableSsl.split(":"); File chainedFile = new File(filePaths[0]), keyFile = new File(filePaths[1]); if (chainedFile.exists() && keyFile.exists()) { - LOGGER.info("openssl isAvailable:" + OpenSsl.isAvailable()); sslContext = SslContextBuilder.forServer(chainedFile, keyFile) .ciphers( @@ -113,6 +112,7 @@ public class CMHttpServer { .filter(x -> null != x && !x.contains("RC4")) .toArray(String[]::new)) .build(); + LOGGER.info("openssl isAvailable:" + OpenSsl.isAvailable()); } } catch (Exception e) { LOGGER.warn("Enabling SSL failed: " + e.getMessage()); @@ -189,7 +189,7 @@ public class CMHttpServer { if (!confFile.exists() && confTemplate.exists()) { FileUtils.copyFile(confTemplate, confFile); } - CMDConf cmdConf = CMDConf.parseConf(CONFIG_PATH); + CMDConf cmdConf = CMDConf.parseFile(CONFIG_PATH); // addDirToPath(new File("./dynamicLibrary").getAbsolutePath()); @@ -207,7 +207,7 @@ public class CMHttpServer { } cmdConf.parseArgs(args); - parseConf(cmdConf); + configServer(cmdConf); // check default key pair File keyFile = new File("manager.key"); diff --git a/src/main/java/org/bdware/server/http/CMHttpHandler.java b/src/main/java/org/bdware/server/http/CMHttpHandler.java index 1618878..1a76e23 100644 --- a/src/main/java/org/bdware/server/http/CMHttpHandler.java +++ b/src/main/java/org/bdware/server/http/CMHttpHandler.java @@ -352,7 +352,12 @@ public class CMHttpHandler extends SimpleChannelInboundHandler { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { - LOGGER.warn("catch exception in " + this + ": " + cause.getClass().getSimpleName() + " " + ExceptionUtil.exceptionToString(cause)); + LOGGER.warn("catch exception in " + parseCtx2String(ctx) + ": " + cause.getClass().getSimpleName()); + LOGGER.debug(ExceptionUtil.exceptionToString(cause)); // ctx.close(); } + + private String parseCtx2String(ChannelHandlerContext ctx) { + return ctx.name() + "@" + ctx.channel().id(); + } } diff --git a/src/main/java/org/bdware/units/NetworkManager.java b/src/main/java/org/bdware/units/NetworkManager.java index c0651b8..37abcc1 100644 --- a/src/main/java/org/bdware/units/NetworkManager.java +++ b/src/main/java/org/bdware/units/NetworkManager.java @@ -128,7 +128,7 @@ public class NetworkManager { } } catch (Exception e) { // e.printStackTrace(); - LOGGER.error("connecting to node center failed! " + e.getMessage()); + LOGGER.warn("connecting to node center failed! " + e.getMessage()); } }, 0,