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 be7951f6c60d3..21ff72a97fc1e 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 @@ private ContextManager createContextManager(final ModeConfiguration modeConfig, Collection 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 853e5651ec20c..0000000000000 --- 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 f916eb3aa9699..365b95460ba59 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 2ac9e518e6428..28c3148ff94be 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 @@ void assertGetDefaultModeConfiguration() { 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 d7b31a021111b..31badda822ca5 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 @@ void assertCreateWithProxyInstanceMetaData() throws SQLException { 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 cc783b111e17f..cee881c2fa41e 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 Collection getProcessList() { } } + private Collection 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 getShowProcessListData(final String taskId) { YamlProcessList yamlProcessList = new YamlProcessList(); for (String each : repository.getChildrenKeys(ProcessNodePath.getRootPath(taskId)).stream() @@ -69,12 +75,6 @@ private Collection getShowProcessListData(final String taskId) { return new YamlProcessListSwapper().swapToObject(yamlProcessList); } - private Collection 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 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 ada4bea9f1128..25090c02dd64b 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 @@ void assertBuildForProxy() throws SQLException { 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 f03294c51ce69..e4510dd2b9cd7 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 @@ void assertBuildWithDefault() throws SQLException { 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 c0de399642288..63b802276b409 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 static void main(final String[] args) throws IOException, SQLException { int port = bootstrapArgs.getPort().orElseGet(() -> new ConfigurationProperties(yamlConfig.getServerConfiguration().getProps()).getValue(ConfigurationPropertyKey.PROXY_DEFAULT_PORT)); List 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 2942e9c3de0e1..d6cda5468c647 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 Optional getSocketPath() { 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 25fb984fbb04e..2fe864ac835c1 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 b98088aea3435..0ca6a3f5f576c 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 @@ void assertGetAddressesWithThreeArguments() { 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 262a55864a109..14000211dadc4 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 void start() { 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"));