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

zhangliang 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 389b95b6b7e Remove useless ShardingSphereMultiProxiesClusterContainer 
(#36634)
389b95b6b7e is described below

commit 389b95b6b7e64861c4424b52f4e92d65eedf5227
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Fri Sep 19 19:33:00 2025 +0800

    Remove useless ShardingSphereMultiProxiesClusterContainer (#36634)
---
 .../container/adapter/AdapterContainerFactory.java |   3 -
 .../env/container/adapter/enums/AdapterType.java   |   4 +-
 ...ShardingSphereMultiProxiesClusterContainer.java | 144 ---------------------
 .../compose/ContainerComposerRegistry.java         |   2 +-
 4 files changed, 2 insertions(+), 151 deletions(-)

diff --git 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/AdapterContainerFactory.java
 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/AdapterContainerFactory.java
index 2596e4f09c2..63dadd8a42a 100644
--- 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/AdapterContainerFactory.java
+++ 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/AdapterContainerFactory.java
@@ -24,7 +24,6 @@ import 
org.apache.shardingsphere.test.e2e.env.container.adapter.config.AdaptorCo
 import 
org.apache.shardingsphere.test.e2e.env.container.adapter.enums.AdapterMode;
 import 
org.apache.shardingsphere.test.e2e.env.container.adapter.enums.AdapterType;
 import 
org.apache.shardingsphere.test.e2e.env.container.adapter.impl.ShardingSphereJdbcEmbeddedContainer;
-import 
org.apache.shardingsphere.test.e2e.env.container.adapter.impl.ShardingSphereMultiProxiesClusterContainer;
 import 
org.apache.shardingsphere.test.e2e.env.container.adapter.impl.ShardingSphereProxyClusterContainer;
 import 
org.apache.shardingsphere.test.e2e.env.container.adapter.impl.ShardingSphereProxyEmbeddedContainer;
 import 
org.apache.shardingsphere.test.e2e.env.container.adapter.impl.ShardingSphereProxyStandaloneContainer;
@@ -56,8 +55,6 @@ public final class AdapterContainerFactory {
         switch (adapter) {
             case PROXY:
                 return newProxyInstance(mode, databaseType, containerConfig, 
envType);
-            case PROXY_RANDOM:
-                return new 
ShardingSphereMultiProxiesClusterContainer(databaseType, containerConfig);
             case JDBC:
                 return new 
ShardingSphereJdbcEmbeddedContainer(storageContainer, new 
ScenarioCommonPath(scenario).getRuleConfigurationFile(databaseType));
             default:
diff --git 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/enums/AdapterType.java
 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/enums/AdapterType.java
index 9bd3b15ae01..0bc67c0eec6 100644
--- 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/enums/AdapterType.java
+++ 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/enums/AdapterType.java
@@ -29,9 +29,7 @@ public enum AdapterType {
     
     JDBC("jdbc"),
     
-    PROXY("proxy"),
-    
-    PROXY_RANDOM("proxy_random");
+    PROXY("proxy");
     
     private final String value;
 }
diff --git 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereMultiProxiesClusterContainer.java
 
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereMultiProxiesClusterContainer.java
deleted file mode 100644
index d120be90710..00000000000
--- 
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereMultiProxiesClusterContainer.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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.shardingsphere.test.e2e.env.container.adapter.impl;
-
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
-import org.apache.shardingsphere.test.e2e.env.container.ComboITContainer;
-import org.apache.shardingsphere.test.e2e.env.container.ITContainer;
-import 
org.apache.shardingsphere.test.e2e.env.container.adapter.AdapterContainer;
-import 
org.apache.shardingsphere.test.e2e.env.container.adapter.config.AdaptorContainerConfiguration;
-import 
org.apache.shardingsphere.test.e2e.env.container.constants.ProxyContainerConstants;
-import org.testcontainers.lifecycle.Startable;
-
-import javax.sql.DataSource;
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-/**
- * ShardingSphere multi-proxies cluster container.
- */
-public final class ShardingSphereMultiProxiesClusterContainer implements 
AdapterContainer, ComboITContainer {
-    
-    private final AtomicReference<DataSource> targetDataSourceProvider = new 
AtomicReference<>();
-    
-    private final Collection<ShardingSphereProxyClusterContainer> 
proxyClusterContainers;
-    
-    public ShardingSphereMultiProxiesClusterContainer(final DatabaseType 
databaseType, final AdaptorContainerConfiguration config) {
-        proxyClusterContainers = 
Arrays.asList(createProxyClusterContainer(databaseType, config, "proxy1"), 
createProxyClusterContainer(databaseType, config, "proxy2"));
-    }
-    
-    private ShardingSphereProxyClusterContainer 
createProxyClusterContainer(final DatabaseType databaseType, final 
AdaptorContainerConfiguration config, final String name) {
-        ShardingSphereProxyClusterContainer result = new 
ShardingSphereProxyClusterContainer(databaseType, config);
-        result.setAbbreviation(name);
-        result.setName(name);
-        return result;
-    }
-    
-    @Override
-    public DataSource getTargetDataSource(final String serverLists) {
-        DataSource dataSource = targetDataSourceProvider.get();
-        if (null == dataSource) {
-            targetDataSourceProvider.set(new 
RandomDataSourceAdapter(proxyClusterContainers.stream().map(each -> 
each.getTargetDataSource(serverLists)).collect(Collectors.toSet())));
-        }
-        return targetDataSourceProvider.get();
-    }
-    
-    @Override
-    public String getAbbreviation() {
-        return ProxyContainerConstants.PROXY_CONTAINER_ABBREVIATION;
-    }
-    
-    @Override
-    public void start() {
-        proxyClusterContainers.forEach(Startable::start);
-    }
-    
-    @Override
-    public Collection<ITContainer> getContainers() {
-        return 
proxyClusterContainers.stream().map(ITContainer.class::cast).collect(Collectors.toList());
-    }
-    
-    private static class RandomDataSourceAdapter implements DataSource {
-        
-        private final DataSource[] dataSources;
-        
-        RandomDataSourceAdapter(final Set<DataSource> dataSources) {
-            this.dataSources = dataSources.toArray(new DataSource[0]);
-        }
-        
-        private DataSource getDataSource() {
-            return 
dataSources[ThreadLocalRandom.current().nextInt(dataSources.length)];
-        }
-        
-        @Override
-        public Connection getConnection() throws SQLException {
-            return getDataSource().getConnection();
-        }
-        
-        @Override
-        public Connection getConnection(final String username, final String 
password) throws SQLException {
-            return getDataSource().getConnection(username, password);
-        }
-        
-        @Override
-        public PrintWriter getLogWriter() throws SQLException {
-            return getDataSource().getLogWriter();
-        }
-        
-        @Override
-        public void setLogWriter(final PrintWriter out) throws SQLException {
-            getDataSource().setLogWriter(out);
-        }
-        
-        @Override
-        public void setLoginTimeout(final int seconds) throws SQLException {
-            for (DataSource each : dataSources) {
-                each.setLoginTimeout(seconds);
-            }
-        }
-        
-        @Override
-        public int getLoginTimeout() throws SQLException {
-            return getDataSource().getLoginTimeout();
-        }
-        
-        @Override
-        public Logger getParentLogger() throws SQLFeatureNotSupportedException 
{
-            return getDataSource().getParentLogger();
-        }
-        
-        @Override
-        public <T> T unwrap(final Class<T> iface) throws SQLException {
-            return getDataSource().unwrap(iface);
-        }
-        
-        @Override
-        public boolean isWrapperFor(final Class<?> iface) throws SQLException {
-            return getDataSource().isWrapperFor(iface);
-        }
-    }
-}
diff --git 
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
 
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
index eb6da386db1..e1c391bb2b7 100644
--- 
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
+++ 
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
@@ -63,7 +63,7 @@ public final class ContainerComposerRegistry implements 
AutoCloseable {
     }
     
     private boolean isClusterMode(final AdapterMode adapterMode, final 
AdapterType adapterType) {
-        return AdapterMode.CLUSTER == adapterMode && AdapterType.PROXY == 
adapterType || AdapterType.PROXY_RANDOM == adapterType;
+        return AdapterMode.CLUSTER == adapterMode && AdapterType.PROXY == 
adapterType;
     }
     
     private ContainerComposer createContainerComposer(final boolean 
clusterMode, final String scenario, final DatabaseType databaseType, final 
AdapterMode adapterMode, final AdapterType adapterType) {

Reply via email to