This is an automated email from the ASF dual-hosted git repository.

menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 7ea707c9537 Optimize startup log, print instance id, IP and port. 
(#35204)
7ea707c9537 is described below

commit 7ea707c95371246caae9ec4fa40c0647fa1af049
Author: Raigor <raigor.ji...@gmail.com>
AuthorDate: Wed Apr 16 18:00:37 2025 +0800

    Optimize startup log, print instance id, IP and port. (#35204)
---
 .../driver/jdbc/core/datasource/ShardingSphereDataSource.java         | 4 +++-
 .../org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java | 3 +++
 .../container/atomic/adapter/impl/ShardingSphereProxyContainer.java   | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 8e74ca02473..35da1021ee4 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -78,7 +78,9 @@ public final class ShardingSphereDataSource extends 
AbstractDataSourceAdapter im
     }
     
     private void printDriverInstanceId(final ContextManager contextManager) {
-        log.info("ShardingSphere-Driver `{}` started successfully.", 
contextManager.getComputeNodeInstanceContext().getInstance().getMetaData().getId());
+        log.info("ShardingSphere-JDBC {} mode started successfully.", 
contextManager.getComputeNodeInstanceContext().getModeConfiguration().getType());
+        InstanceMetaData instanceMetaData = 
contextManager.getComputeNodeInstanceContext().getInstance().getMetaData();
+        log.info("Instance id: {}, IP: {}", instanceMetaData.getId(), 
instanceMetaData.getIp());
     }
     
     @HighFrequencyInvocation(canBeCached = true)
diff --git 
a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
 
b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
index f39ac83e0be..0a10fc23060 100644
--- 
a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
+++ 
b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
@@ -36,6 +36,7 @@ import io.netty.handler.logging.LoggingHandler;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
+import 
org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData;
 import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.frontend.netty.ServerHandlerInitializer;
@@ -129,6 +130,8 @@ public final class ShardingSphereProxy {
     
     private void accept(final List<ChannelFuture> futures) throws 
InterruptedException {
         log.info("ShardingSphere-Proxy {} mode started successfully", 
ProxyContext.getInstance().getContextManager().getComputeNodeInstanceContext().getModeConfiguration().getType());
+        ProxyInstanceMetaData instanceMetaData = (ProxyInstanceMetaData) 
ProxyContext.getInstance().getContextManager().getComputeNodeInstanceContext().getInstance().getMetaData();
+        log.info("Instance id: {}, IP: {}, port: {}", 
instanceMetaData.getId(), instanceMetaData.getIp(), instanceMetaData.getPort());
         for (ChannelFuture each : futures) {
             each.channel().closeFuture().sync();
         }
diff --git 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereProxyContainer.java
 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereProxyContainer.java
index 14000211dad..173f5564b75 100644
--- 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereProxyContainer.java
+++ 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereProxyContainer.java
@@ -135,7 +135,7 @@ public final class ShardingSphereProxyContainer implements 
AdapterContainer, Emb
         ProxySSLContext.init();
         proxy = new ShardingSphereProxy();
         proxy.startInternal(port, Collections.singletonList("0.0.0.0"));
-        log.info("DBPlusEngine-Proxy {} mode started successfully", 
ProxyContext.getInstance().getContextManager().getComputeNodeInstanceContext().getModeConfiguration().getType());
+        log.info("ShardingSphere-Proxy {} mode started successfully", 
ProxyContext.getInstance().getContextManager().getComputeNodeInstanceContext().getModeConfiguration().getType());
     }
     
     private Path getTempConfigDirectory() throws IOException {

Reply via email to