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 fc4776890f4 Remove useless ContextManagerBuilderParameter.force 
(#34302)
fc4776890f4 is described below

commit fc4776890f4ac0bfe8056f56ae97db88a5ec851b
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 10 23:08:31 2025 +0800

    Remove useless ContextManagerBuilderParameter.force (#34302)
    
    * Refactor ClusterProcessPersistService
    
    * Remove ContextManagerAware
    
    * Remove useless ContextManagerBuilderParameter.force
---
 .../core/datasource/ShardingSphereDataSource.java  |  2 +-
 .../mode/manager/ContextManagerAware.java          | 31 ----------------------
 .../manager/ContextManagerBuilderParameter.java    |  2 --
 .../ContextManagerBuilderParameterTest.java        |  4 +--
 .../mode/metadata/MetaDataContextsFactoryTest.java |  2 +-
 .../service/ClusterProcessPersistService.java      | 12 ++++-----
 .../cluster/ClusterContextManagerBuilderTest.java  |  2 +-
 .../StandaloneContextManagerBuilderTest.java       |  2 +-
 .../org/apache/shardingsphere/proxy/Bootstrap.java |  2 +-
 .../proxy/arguments/BootstrapArguments.java        |  9 -------
 .../proxy/initializer/BootstrapInitializer.java    |  9 +++----
 .../proxy/arguments/BootstrapArgumentsTest.java    |  9 -------
 .../adapter/impl/ShardingSphereProxyContainer.java |  2 +-
 13 files changed, 18 insertions(+), 70 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 be7951f6c60..21ff72a97fc 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
@@ -70,7 +70,7 @@ public final class ShardingSphereDataSource extends 
AbstractDataSourceAdapter im
         Collection<RuleConfiguration> databaseRuleConfigs = new 
LinkedList<>(ruleConfigs);
         databaseRuleConfigs.removeAll(globalRuleConfigs);
         ContextManagerBuilderParameter param = new 
ContextManagerBuilderParameter(modeConfig, 
Collections.singletonMap(databaseName,
-                new DataSourceProvidedDatabaseConfiguration(dataSourceMap, 
databaseRuleConfigs)), Collections.emptyMap(), globalRuleConfigs, props, 
Collections.emptyList(), instanceMetaData, false);
+                new DataSourceProvidedDatabaseConfiguration(dataSourceMap, 
databaseRuleConfigs)), Collections.emptyMap(), globalRuleConfigs, props, 
Collections.emptyList(), instanceMetaData);
         return TypedSPILoader.getService(ContextManagerBuilder.class, null == 
modeConfig ? null : modeConfig.getType()).build(param, new EventBusContext());
     }
     
diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java
deleted file mode 100644
index 853e5651ec2..00000000000
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerAware.java
+++ /dev/null
@@ -1,31 +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.mode.manager;
-
-/**
- * Context manager aware.
- */
-public interface ContextManagerAware {
-    
-    /**
-     * Set context manager.
-     *
-     * @param contextManager context manager
-     */
-    void setContextManager(ContextManager contextManager);
-}
diff --git 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
index f916eb3aa96..365b95460ba 100644
--- 
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
+++ 
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
@@ -52,8 +52,6 @@ public final class ContextManagerBuilderParameter {
     
     private final InstanceMetaData instanceMetaData;
     
-    private final boolean force;
-    
     /**
      * Get mode configuration.
      *
diff --git 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
index 2ac9e518e64..28c3148ff94 100644
--- 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
+++ 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
@@ -34,7 +34,7 @@ class ContextManagerBuilderParameterTest {
     
     @Test
     void assertGetDefaultModeConfiguration() {
-        ContextManagerBuilderParameter param = new 
ContextManagerBuilderParameter(null, Collections.emptyMap(), 
Collections.emptyMap(), Collections.emptyList(), new Properties(), null, null, 
false);
+        ContextManagerBuilderParameter param = new 
ContextManagerBuilderParameter(null, Collections.emptyMap(), 
Collections.emptyMap(), Collections.emptyList(), new Properties(), null, null);
         assertThat(param.getModeConfiguration().getType(), is("Standalone"));
         assertNull(param.getModeConfiguration().getRepository());
     }
@@ -43,7 +43,7 @@ class ContextManagerBuilderParameterTest {
     void assertGetModeConfiguration() {
         ModeConfiguration modeConfig = new ModeConfiguration("Cluster", 
mock(PersistRepositoryConfiguration.class));
         ContextManagerBuilderParameter param =
-                new ContextManagerBuilderParameter(modeConfig, 
Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList(), new 
Properties(), null, null, false);
+                new ContextManagerBuilderParameter(modeConfig, 
Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList(), new 
Properties(), null, null);
         assertThat(param.getModeConfiguration().getType(), is("Cluster"));
         assertNotNull(param.getModeConfiguration().getRepository());
     }
diff --git 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java
 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java
index d7b31a02111..31badda822c 100644
--- 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java
+++ 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactoryTest.java
@@ -130,6 +130,6 @@ class MetaDataContextsFactoryTest {
     private ContextManagerBuilderParameter 
createContextManagerBuilderParameter() {
         DatabaseConfiguration databaseConfig = new 
DataSourceProvidedDatabaseConfiguration(Collections.singletonMap("foo", new 
MockedDataSource()), Collections.emptyList());
         return new ContextManagerBuilderParameter(null, 
Collections.singletonMap("foo_db", databaseConfig), Collections.emptyMap(),
-                Collections.emptyList(), new Properties(), 
Collections.emptyList(), null, false);
+                Collections.emptyList(), new Properties(), 
Collections.emptyList(), null);
     }
 }
diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
index cc783b111e1..cee881c2fa4 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/ClusterProcessPersistService.java
@@ -60,6 +60,12 @@ public final class ClusterProcessPersistService implements 
ProcessPersistService
         }
     }
     
+    private Collection<String> getShowProcessListTriggerPaths(final String 
taskId) {
+        return Stream.of(InstanceType.values())
+                .flatMap(each -> 
repository.getChildrenKeys(ComputeNodePath.getOnlinePath(each)).stream().map(instanceId
 -> ComputeNodePath.getShowProcessListTriggerPath(instanceId, taskId)))
+                .collect(Collectors.toList());
+    }
+    
     private Collection<Process> getShowProcessListData(final String taskId) {
         YamlProcessList yamlProcessList = new YamlProcessList();
         for (String each : 
repository.getChildrenKeys(ProcessNodePath.getRootPath(taskId)).stream()
@@ -69,12 +75,6 @@ public final class ClusterProcessPersistService implements 
ProcessPersistService
         return new YamlProcessListSwapper().swapToObject(yamlProcessList);
     }
     
-    private Collection<String> getShowProcessListTriggerPaths(final String 
taskId) {
-        return Stream.of(InstanceType.values())
-                .flatMap(each -> 
repository.getChildrenKeys(ComputeNodePath.getOnlinePath(each)).stream().map(instanceId
 -> ComputeNodePath.getShowProcessListTriggerPath(instanceId, taskId)))
-                .collect(Collectors.toList());
-    }
-    
     @Override
     public void killProcess(final String processId) {
         Collection<String> triggerPaths = 
getKillProcessTriggerPaths(processId);
diff --git 
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilderTest.java
 
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilderTest.java
index ada4bea9f11..25090c02dd6 100644
--- 
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilderTest.java
+++ 
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilderTest.java
@@ -73,7 +73,7 @@ class ClusterContextManagerBuilderTest {
     
     private void assertBuild(final InstanceMetaData instanceMetaData) throws 
SQLException {
         ContextManager actual = builder.build(new 
ContextManagerBuilderParameter(createModeConfiguration(),
-                Collections.emptyMap(), Collections.emptyMap(), 
Collections.emptyList(), new Properties(), Collections.emptyList(), 
instanceMetaData, false), mock(EventBusContext.class));
+                Collections.emptyMap(), Collections.emptyMap(), 
Collections.emptyList(), new Properties(), Collections.emptyList(), 
instanceMetaData), mock(EventBusContext.class));
         
assertThat(actual.getComputeNodeInstanceContext().getInstance().getMetaData(), 
is(instanceMetaData));
     }
     
diff --git 
a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTest.java
 
b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTest.java
index f03294c51ce..e4510dd2b9c 100644
--- 
a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTest.java
+++ 
b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTest.java
@@ -54,7 +54,7 @@ class StandaloneContextManagerBuilderTest {
     void assertBuild(final ContextManagerBuilder builder) throws SQLException {
         InstanceMetaData instanceMetaData = new JDBCInstanceMetaData("foo", 
"foo_db");
         ContextManager actual = builder.build(new 
ContextManagerBuilderParameter(createModeConfiguration(),
-                Collections.emptyMap(), Collections.emptyMap(), 
Collections.emptyList(), new Properties(), Collections.emptyList(), 
instanceMetaData, false), mock(EventBusContext.class));
+                Collections.emptyMap(), Collections.emptyMap(), 
Collections.emptyList(), new Properties(), Collections.emptyList(), 
instanceMetaData), mock(EventBusContext.class));
         
assertThat(actual.getComputeNodeInstanceContext().getInstance().getMetaData(), 
is(instanceMetaData));
     }
     
diff --git 
a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java 
b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
index c0de3996422..63b802276b4 100644
--- 
a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
+++ 
b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
@@ -61,7 +61,7 @@ public final class Bootstrap {
         int port = bootstrapArgs.getPort().orElseGet(() -> new 
ConfigurationProperties(yamlConfig.getServerConfiguration().getProps()).getValue(ConfigurationPropertyKey.PROXY_DEFAULT_PORT));
         List<String> addresses = bootstrapArgs.getAddresses();
         checkPort(addresses, port);
-        new BootstrapInitializer().init(yamlConfig, port, 
bootstrapArgs.isForce());
+        new BootstrapInitializer().init(yamlConfig, port);
         Optional.ofNullable((Integer) 
yamlConfig.getServerConfiguration().getProps().get(ConfigurationPropertyKey.CDC_SERVER_PORT.getKey()))
                 .ifPresent(optional -> new Thread(new CDCServer(addresses, 
optional)).start());
         ProxySSLContext.init();
diff --git 
a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/arguments/BootstrapArguments.java
 
b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/arguments/BootstrapArguments.java
index 2942e9c3de0..d6cda5468c6 100644
--- 
a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/arguments/BootstrapArguments.java
+++ 
b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/arguments/BootstrapArguments.java
@@ -96,15 +96,6 @@ public final class BootstrapArguments {
         return addresses.stream().filter(address -> 
!InetAddresses.isInetAddress(address)).filter(this::isValidPath).findFirst();
     }
     
-    /**
-     * Get force startup parameter.
-     *
-     * @return force parameter
-     */
-    public boolean isForce() {
-        return args.length >= 4 && parseForceParameter(args[3]);
-    }
-    
     private boolean parseForceParameter(final String forceParam) {
         return Boolean.TRUE.toString().equalsIgnoreCase(forceParam.trim());
     }
diff --git 
a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
 
b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index 25fb984fbb0..2fe864ac835 100644
--- 
a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ 
b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -44,21 +44,20 @@ public final class BootstrapInitializer {
      *
      * @param yamlConfig YAML proxy configuration
      * @param port proxy port
-     * @param force force start
      * @throws SQLException SQL exception
      */
-    public void init(final YamlProxyConfiguration yamlConfig, final int port, 
final boolean force) throws SQLException {
+    public void init(final YamlProxyConfiguration yamlConfig, final int port) 
throws SQLException {
         ModeConfiguration modeConfig = null == 
yamlConfig.getServerConfiguration().getMode() ? null : new 
YamlModeConfigurationSwapper().swapToObject(yamlConfig.getServerConfiguration().getMode());
         ProxyConfiguration proxyConfig = new 
YamlProxyConfigurationSwapper().swap(yamlConfig);
-        ContextManager contextManager = createContextManager(proxyConfig, 
modeConfig, port, force);
+        ContextManager contextManager = createContextManager(proxyConfig, 
modeConfig, port);
         ProxyContext.init(contextManager);
         ShardingSphereProxyVersion.setVersion(contextManager);
     }
     
-    private ContextManager createContextManager(final ProxyConfiguration 
proxyConfig, final ModeConfiguration modeConfig, final int port, final boolean 
force) throws SQLException {
+    private ContextManager createContextManager(final ProxyConfiguration 
proxyConfig, final ModeConfiguration modeConfig, final int port) throws 
SQLException {
         InstanceMetaData instanceMetaData = 
TypedSPILoader.getService(InstanceMetaDataBuilder.class, "Proxy").build(port, 
"");
         ContextManagerBuilderParameter param = new 
ContextManagerBuilderParameter(modeConfig, 
proxyConfig.getDatabaseConfigurations(), 
proxyConfig.getGlobalConfiguration().getDataSources(),
-                proxyConfig.getGlobalConfiguration().getRules(), 
proxyConfig.getGlobalConfiguration().getProperties(), 
proxyConfig.getGlobalConfiguration().getLabels(), instanceMetaData, force);
+                proxyConfig.getGlobalConfiguration().getRules(), 
proxyConfig.getGlobalConfiguration().getProperties(), 
proxyConfig.getGlobalConfiguration().getLabels(), instanceMetaData);
         return TypedSPILoader.getService(ContextManagerBuilder.class, null == 
modeConfig ? null : modeConfig.getType()).build(param, new EventBusContext());
     }
 }
diff --git 
a/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
 
b/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
index b98088aea34..0ca6a3f5f57 100644
--- 
a/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
+++ 
b/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
@@ -106,15 +106,6 @@ class BootstrapArgumentsTest {
         assertThat(new BootstrapArguments(new String[]{"3306", "test_conf", 
"1.1.1.1,127.0.0.1"}).getAddresses(), is(Arrays.asList("1.1.1.1", 
"127.0.0.1")));
     }
     
-    @Test
-    void assertGetForce() {
-        assertFalse(new BootstrapArguments(new String[]{"3306", "test_conf", 
"127.0.0.1"}).isForce());
-        assertFalse(new BootstrapArguments(new String[]{"3306", "test_conf", 
"127.0.0.1", "false"}).isForce());
-        assertTrue(new BootstrapArguments(new String[]{"3306", "test_conf", 
"127.0.0.1", "true "}).isForce());
-        assertTrue(new BootstrapArguments(new String[]{"3306", "test_conf", 
"127.0.0.1", "true"}).isForce());
-        assertTrue(new BootstrapArguments(new String[]{"3306", "test_conf", 
"127.0.0.1", "TrUe"}).isForce());
-    }
-    
     @Test
     void assertGetSocketPath() {
         assertThat(new BootstrapArguments(new String[]{"3306", "test_conf", 
"127.0.0.1,/tmp/shardingsphere.sock"}).getSocketPath(), 
is(Optional.of("/tmp/shardingsphere.sock")));
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 262a55864a1..14000211dad 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
@@ -131,7 +131,7 @@ public final class ShardingSphereProxyContainer implements 
AdapterContainer, Emb
     private void startInternalProxy() {
         YamlProxyConfiguration yamlConfig = 
ProxyConfigurationLoader.load(getTempConfigDirectory().toString());
         int port = 
Integer.parseInt(ConfigurationPropertyKey.PROXY_DEFAULT_PORT.getDefaultValue());
-        new BootstrapInitializer().init(yamlConfig, port, false);
+        new BootstrapInitializer().init(yamlConfig, port);
         ProxySSLContext.init();
         proxy = new ShardingSphereProxy();
         proxy.startInternal(port, Collections.singletonList("0.0.0.0"));

Reply via email to