You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "mytang0 (via GitHub)" <gi...@apache.org> on 2023/02/20 12:02:33 UTC

[GitHub] [incubator-eventmesh] mytang0 commented on a diff in pull request #3207: [ISSUE #3201]Optimize remote service related code

mytang0 commented on code in PR #3207:
URL: https://github.com/apache/incubator-eventmesh/pull/3207#discussion_r1111828270


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/SystemUtils.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+
+public abstract class SystemUtils {
+
+    public static final String OS_NAME = System.getProperty("os.name");
+
+    private static boolean isLinuxPlatform = false;
+
+    private static boolean isWindowsPlatform = false;
+
+    static {
+        if (OS_NAME != null && OS_NAME.toLowerCase().contains("linux")) {
+            isLinuxPlatform = true;
+        }
+
+        if (OS_NAME != null && OS_NAME.toLowerCase().contains("windows")) {
+            isWindowsPlatform = true;
+        }
+    }
+
+    private SystemUtils() {
+
+    }
+
+    public static boolean isLinuxPlatform() {
+        return isLinuxPlatform;
+    }
+
+    public static boolean isWindowsPlatform() {
+        return isWindowsPlatform;
+    }
+
+    public static String getProcessId() {
+        try {
+            String name = ManagementFactory.getRuntimeMXBean().getName();
+            return name.split("@")[0];
+        } catch (final Exception ex) {
+            try {
+                // try a Linux-specific way
+                return new File("/proc/self").getCanonicalFile().getName();
+            } catch (final IOException ignoredUseDefault) {
+                // Ignore exception.
+            }
+        }
+        return "-1";
+    }
+}

Review Comment:
   Is it possible to consider a full reference to ProcessIdUtil.getProcessId



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java:
##########
@@ -703,14 +720,15 @@ protected void initChannel(final SocketChannel channel) {
             if (sslContext != null && useTLS) {
                 final SSLEngine sslEngine = sslContext.createSSLEngine();
                 sslEngine.setUseClientMode(false);
-                pipeline.addFirst("ssl", new SslHandler(sslEngine));
+                pipeline.addFirst(getWorkerGroup(), "ssl", new SslHandler(sslEngine));

Review Comment:
   Why only apply to workerGroup?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java:
##########
@@ -121,7 +124,7 @@ public abstract class AbstractHTTPServer extends AbstractRemotingServer {
     private final transient EventMeshHTTPConfiguration eventMeshHttpConfiguration;
 
     private final transient ThreadPoolExecutor asyncContextCompleteHandler =
-            ThreadPoolFactory.createThreadPoolExecutor(10, 10, "EventMesh-http-asyncContext");
+        ThreadPoolFactory.createThreadPoolExecutor(10, 10, "EventMesh-http-asyncContext");

Review Comment:
   Would you like to open an issue to modify the code style?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org