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 a1b19ee Merge mode based ContextManager (#12156)
a1b19ee is described below
commit a1b19ee5c2788b7d45b41a2a762b4c2adcc11ed9
Author: Haoran Meng <[email protected]>
AuthorDate: Wed Sep 1 21:05:45 2021 +0800
Merge mode based ContextManager (#12156)
* Merge mode based ContextManager
---
.../mode/manager/ContextManager.java | 50 +++++-------
.../mode/metadata/MetaDataContexts.java | 12 ++-
.../mode/persist/PersistService.java | 3 +
.../mode/manager/ContextManagerTest.java | 71 ++++++++++++++++
.../manager/cluster/ClusterContextManager.java | 81 ------------------
.../cluster/ClusterContextManagerBuilder.java | 3 +-
.../manager/cluster/ClusterContextManagerTest.java | 95 ----------------------
.../mode/manager/memory/MemoryContextManager.java | 63 --------------
.../memory/MemoryContextManagerBuilder.java | 2 +-
.../standalone/StandaloneContextManager.java | 63 --------------
.../StandaloneContextManagerBuilder.java | 2 +-
.../proxy/backend/context/ProxyContext.java | 7 +-
12 files changed, 113 insertions(+), 339 deletions(-)
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index c76a190..9d0cdf6 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -17,57 +17,51 @@
package org.apache.shardingsphere.mode.manager;
+import lombok.Getter;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.lock.ShardingSphereLock;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
-import java.util.Optional;
-
/**
* Context manager.
*/
-public interface ContextManager extends AutoCloseable {
+@Getter
+public final class ContextManager implements AutoCloseable {
+
+ private volatile MetaDataContexts metaDataContexts = new
MetaDataContexts(null);
+
+ private volatile TransactionContexts transactionContexts = new
TransactionContexts();
/**
* Initialize context manager.
- *
+ *
* @param metaDataContexts meta data contexts
* @param transactionContexts transaction contexts
*/
- void init(MetaDataContexts metaDataContexts, TransactionContexts
transactionContexts);
-
- /**
- * Get meta data contexts.
- *
- * @return meta data contexts
- */
- MetaDataContexts getMetaDataContexts();
+ public void init(final MetaDataContexts metaDataContexts, final
TransactionContexts transactionContexts) {
+ this.metaDataContexts = metaDataContexts;
+ this.transactionContexts = transactionContexts;
+ }
/**
* Renew meta data contexts.
*
* @param metaDataContexts meta data contexts
*/
- void renewMetaDataContexts(MetaDataContexts metaDataContexts);
-
- /**
- * Get transaction contexts.
- *
- * @return transaction contexts
- */
- TransactionContexts getTransactionContexts();
+ public synchronized void renewMetaDataContexts(final MetaDataContexts
metaDataContexts) {
+ this.metaDataContexts = metaDataContexts;
+ }
/**
* Renew transaction contexts.
*
* @param transactionContexts transaction contexts
*/
- void renewTransactionContexts(TransactionContexts transactionContexts);
+ public synchronized void renewTransactionContexts(final
TransactionContexts transactionContexts) {
+ this.transactionContexts = transactionContexts;
+ }
- /**
- * Get lock.
- *
- * @return lock
- */
- Optional<ShardingSphereLock> getLock();
+ @Override
+ public void close() throws Exception {
+ metaDataContexts.close();
+ }
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java
index ddaa488..5decc5f 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java
@@ -24,8 +24,8 @@ import
org.apache.shardingsphere.infra.lock.ShardingSphereLock;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.optimize.context.OptimizeContextFactory;
-import org.apache.shardingsphere.mode.persist.PersistService;
import org.apache.shardingsphere.infra.state.StateContext;
+import org.apache.shardingsphere.mode.persist.PersistService;
import java.util.Collection;
import java.util.Collections;
@@ -39,7 +39,7 @@ import java.util.Properties;
* Meta data contexts.
*/
@Getter
-public final class MetaDataContexts {
+public final class MetaDataContexts implements AutoCloseable {
private final PersistService persistService;
@@ -107,4 +107,12 @@ public final class MetaDataContexts {
public Optional<ShardingSphereLock> getLock() {
return Optional.empty();
}
+
+ @Override
+ public void close() throws Exception {
+ executorEngine.close();
+ if (null != persistService) {
+ persistService.getRepository().close();
+ }
+ }
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistService.java
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistService.java
index 26450c9..76f0954 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistService.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/persist/PersistService.java
@@ -37,6 +37,8 @@ import java.util.Properties;
@Getter
public final class PersistService {
+ private final PersistRepository repository;
+
private final DataSourcePersistService dataSourceService;
private final SchemaMetaDataPersistService schemaMetaDataService;
@@ -48,6 +50,7 @@ public final class PersistService {
private final PropertiesPersistService propsService;
public PersistService(final PersistRepository repository) {
+ this.repository = repository;
dataSourceService = new DataSourcePersistService(repository);
schemaMetaDataService = new SchemaMetaDataPersistService(repository);
schemaRuleService = new SchemaRulePersistService(repository);
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
new file mode 100644
index 0000000..843bea0
--- /dev/null
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.transaction.context.TransactionContexts;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class ContextManagerTest {
+
+ @Mock
+ private MetaDataContexts metaDataContexts;
+
+ @Mock
+ private TransactionContexts transactionContexts;
+
+ private ContextManager contextManager;
+
+ @Before
+ public void setUp() {
+ contextManager = new ContextManager();
+ contextManager.init(metaDataContexts, transactionContexts);
+ }
+
+ @SneakyThrows
+ @Test
+ public void assertClose() {
+ contextManager.close();
+ verify(metaDataContexts).close();
+ }
+
+ @Test
+ public void assertRenewMetaDataContexts() {
+ MetaDataContexts metaDataContexts = mock(MetaDataContexts.class);
+ contextManager.renewMetaDataContexts(metaDataContexts);
+ assertThat(contextManager.getMetaDataContexts(), is(metaDataContexts));
+ }
+
+ @Test
+ public void assertRenewTransactionContexts() {
+ TransactionContexts transactionContexts =
mock(TransactionContexts.class);
+ contextManager.renewTransactionContexts(transactionContexts);
+ assertThat(contextManager.getTransactionContexts(),
is(transactionContexts));
+ }
+}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java
deleted file mode 100644
index 3066cee..0000000
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java
+++ /dev/null
@@ -1,81 +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.cluster;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.lock.ShardingSphereLock;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import
org.apache.shardingsphere.mode.manager.cluster.governance.lock.ShardingSphereDistributeLock;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
-import org.apache.shardingsphere.transaction.context.TransactionContexts;
-
-import java.util.Optional;
-
-/**
- * Cluster context manager.
- */
-@RequiredArgsConstructor
-public final class ClusterContextManager implements ContextManager {
-
- private final RegistryCenter registryCenter;
-
- @Getter
- private volatile MetaDataContexts metaDataContexts;
-
- @Getter
- private volatile TransactionContexts transactionContexts;
-
- private volatile ShardingSphereLock lock;
-
- @Override
- public void init(final MetaDataContexts metaDataContexts, final
TransactionContexts transactionContexts) {
- this.metaDataContexts = metaDataContexts;
- this.transactionContexts = transactionContexts;
- lock = createShardingSphereLock(registryCenter.getRepository());
- registryCenter.onlineInstance(metaDataContexts.getAllSchemaNames());
- }
-
- private ShardingSphereLock createShardingSphereLock(final
ClusterPersistRepository repository) {
- return
metaDataContexts.getProps().<Boolean>getValue(ConfigurationPropertyKey.LOCK_ENABLED)
- ? new ShardingSphereDistributeLock(repository,
metaDataContexts.getProps().<Long>getValue(ConfigurationPropertyKey.LOCK_WAIT_TIMEOUT_MILLISECONDS))
: null;
- }
-
- @Override
- public synchronized void renewMetaDataContexts(final MetaDataContexts
metaDataContexts) {
- this.metaDataContexts = metaDataContexts;
- }
-
- @Override
- public synchronized void renewTransactionContexts(final
TransactionContexts transactionContexts) {
- this.transactionContexts = transactionContexts;
- }
-
- @Override
- public Optional<ShardingSphereLock> getLock() {
- return Optional.ofNullable(lock);
- }
-
- @Override
- public void close() {
- metaDataContexts.getExecutorEngine().close();
- registryCenter.getRepository().close();
- }
-}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index bc81ee2..9c3b39a 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -105,7 +105,7 @@ public final class ClusterContextManagerBuilder implements
ContextManagerBuilder
final Map<String,
Collection<RuleConfiguration>> schemaRuleConfigs, final
Collection<RuleConfiguration> globalRuleConfigs,
final Properties props, final boolean
isOverwrite) throws SQLException {
beforeBuildContextManager(modeConfig, dataSourcesMap,
schemaRuleConfigs, globalRuleConfigs, props, isOverwrite);
- contextManager = new ClusterContextManager(registryCenter);
+ contextManager = new ContextManager();
contextManager.init(metaDataContexts, transactionContexts);
afterBuildContextManager();
return contextManager;
@@ -128,6 +128,7 @@ public final class ClusterContextManagerBuilder implements
ContextManagerBuilder
private void afterBuildContextManager() {
disableDataSources();
persistMetaData();
+ registryCenter.onlineInstance(metaDataContexts.getAllSchemaNames());
}
private ClusterPersistRepository createClusterPersistRepository(final
ClusterPersistRepositoryConfiguration config) {
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerTest.java
deleted file mode 100644
index fb61b46..0000000
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerTest.java
+++ /dev/null
@@ -1,95 +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.cluster;
-
-import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
-import org.apache.shardingsphere.infra.database.DefaultSchema;
-import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import
org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.optimize.context.OptimizeContextFactory;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.mode.persist.PersistService;
-import org.apache.shardingsphere.transaction.context.TransactionContexts;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ClusterContextManagerTest {
-
- private final ConfigurationProperties props = new
ConfigurationProperties(new Properties());
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private RegistryCenter registryCenter;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private ShardingSphereMetaData metaData;
-
- private ClusterContextManager clusterContextManager;
-
- @Mock
- private ShardingSphereRuleMetaData globalRuleMetaData;
-
- @Before
- public void setUp() {
- clusterContextManager = new ClusterContextManager(registryCenter);
- clusterContextManager.init(
- new MetaDataContexts(mock(PersistService.class),
createMetaDataMap(), globalRuleMetaData, mock(ExecutorEngine.class), props,
mockOptimizeContextFactory()),
- mock(TransactionContexts.class, RETURNS_DEEP_STUBS));
- }
-
- private Map<String, ShardingSphereMetaData> createMetaDataMap() {
-
when(metaData.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
- return Collections.singletonMap("schema", metaData);
- }
-
- private OptimizeContextFactory mockOptimizeContextFactory() {
- OptimizeContextFactory result = mock(OptimizeContextFactory.class);
- return result;
- }
-
- @Test
- public void assertGetMetaData() {
-
assertThat(clusterContextManager.getMetaDataContexts().getMetaData("schema"),
is(metaData));
- }
-
- @Test
- public void assertGetDefaultMetaData() {
-
assertNull(clusterContextManager.getMetaDataContexts().getMetaData(DefaultSchema.LOGIC_NAME));
- }
-
- @Test
- public void assertGetProps() {
- assertThat(clusterContextManager.getMetaDataContexts().getProps(),
is(props));
- }
-}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManager.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManager.java
deleted file mode 100644
index eb2a64c..0000000
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManager.java
+++ /dev/null
@@ -1,63 +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.memory;
-
-import lombok.Getter;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.lock.ShardingSphereLock;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.transaction.context.TransactionContexts;
-
-import java.util.Optional;
-
-/**
- * Memory context manager.
- */
-@Getter
-public final class MemoryContextManager implements ContextManager {
-
- private volatile MetaDataContexts metaDataContexts = new
MetaDataContexts(null);
-
- private volatile TransactionContexts transactionContexts = new
TransactionContexts();
-
- @Override
- public void init(final MetaDataContexts metaDataContexts, final
TransactionContexts transactionContexts) {
- this.metaDataContexts = metaDataContexts;
- this.transactionContexts = transactionContexts;
- }
-
- @Override
- public synchronized void renewMetaDataContexts(final MetaDataContexts
metaDataContexts) {
- this.metaDataContexts = metaDataContexts;
- }
-
- @Override
- public synchronized void renewTransactionContexts(final
TransactionContexts transactionContexts) {
- this.transactionContexts = transactionContexts;
- }
-
- @Override
- public Optional<ShardingSphereLock> getLock() {
- return Optional.empty();
- }
-
- @Override
- public void close() {
- metaDataContexts.getExecutorEngine().close();
- }
-}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
index 7492a05..2f7d35e 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
@@ -49,7 +49,7 @@ public final class MemoryContextManagerBuilder implements
ContextManagerBuilder
final Properties props, final boolean
isOverwrite) throws SQLException {
MetaDataContexts metaDataContexts = new
MetaDataContextsBuilder(dataSourcesMap, schemaRuleConfigs, globalRuleConfigs,
props).build(null);
TransactionContexts transactionContexts =
createTransactionContexts(metaDataContexts);
- ContextManager result = new MemoryContextManager();
+ ContextManager result = new ContextManager();
result.init(metaDataContexts, transactionContexts);
return result;
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManager.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManager.java
deleted file mode 100644
index 4fa5912..0000000
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManager.java
+++ /dev/null
@@ -1,63 +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.standalone;
-
-import lombok.Getter;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.lock.ShardingSphereLock;
-import org.apache.shardingsphere.transaction.context.TransactionContexts;
-
-import java.util.Optional;
-
-/**
- * Standalone context manager.
- */
-@Getter
-public final class StandaloneContextManager implements ContextManager {
-
- private volatile MetaDataContexts metaDataContexts;
-
- private volatile TransactionContexts transactionContexts;
-
- @Override
- public void init(final MetaDataContexts metaDataContexts, final
TransactionContexts transactionContexts) {
- this.metaDataContexts = metaDataContexts;
- this.transactionContexts = transactionContexts;
- }
-
- @Override
- public synchronized void renewMetaDataContexts(final MetaDataContexts
metaDataContexts) {
- this.metaDataContexts = metaDataContexts;
- }
-
- @Override
- public synchronized void renewTransactionContexts(final
TransactionContexts transactionContexts) {
- this.transactionContexts = transactionContexts;
- }
-
- @Override
- public Optional<ShardingSphereLock> getLock() {
- return Optional.empty();
- }
-
- @Override
- public void close() {
- metaDataContexts.getExecutorEngine().close();
- }
-}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index 7a8e78a..a276ac3 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -70,7 +70,7 @@ public final class StandaloneContextManagerBuilder implements
ContextManagerBuil
MetaDataContexts metaDataContexts = new
MetaDataContextsBuilder(loadDataSourcesMap(persistService, dataSourcesMap,
schemaNames),
loadSchemaRules(persistService, schemaNames),
persistService.getGlobalRuleService().load(),
persistService.getPropsService().load()).build(persistService);
TransactionContexts transactionContexts =
createTransactionContexts(metaDataContexts);
- ContextManager result = new StandaloneContextManager();
+ ContextManager result = new ContextManager();
result.init(metaDataContexts, transactionContexts);
return result;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
index 75e08b2..5485245 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
@@ -21,12 +21,11 @@ import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.mode.manager.memory.MemoryContextManager;
import org.apache.shardingsphere.infra.lock.ShardingSphereLock;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.state.StateContext;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.JDBCBackendDataSource;
import
org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
@@ -47,7 +46,7 @@ public final class ProxyContext {
private final JDBCBackendDataSource backendDataSource = new
JDBCBackendDataSource();
- private volatile ContextManager contextManager = new
MemoryContextManager();
+ private volatile ContextManager contextManager = new ContextManager();
/**
* Get instance of proxy schema schemas.
@@ -105,7 +104,7 @@ public final class ProxyContext {
* @return lock
*/
public Optional<ShardingSphereLock> getLock() {
- return contextManager.getLock();
+ return Optional.empty();
}
/**