You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/01/30 15:32:29 UTC

[shardingsphere] branch master updated: Refactor global lock (#9225)

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 bbb76ef  Refactor global lock (#9225)
bbb76ef is described below

commit bbb76ef9f9bb7abce228eded19d29bd3c606b172
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Sat Jan 30 23:32:02 2021 +0800

    Refactor global lock (#9225)
---
 .../metadata/GovernanceMetaDataContexts.java       | 19 +++--
 .../core/event/model/lock/UnlockEvent.java         | 26 +++++++
 .../core/lock/GovernanceLockContext.java           | 89 ++++++++++++++++++++++
 .../infra/lock/AbstractLockContext.java            | 57 ++++++++++++++
 .../shardingsphere/infra/lock/LockContext.java     | 72 ++++-------------
 .../infra/lock/StandardLockContext.java            | 55 +++++++++++++
 .../shardingsphere/infra/state/StateContext.java   |  9 ---
 .../shardingsphere/infra/lock/LockContextTest.java | 54 -------------
 .../infra/context/metadata/MetaDataContexts.java   |  8 ++
 .../metadata/impl/StandardMetaDataContexts.java    | 10 +++
 .../driver/executor/DriverJDBCExecutor.java        |  5 +-
 .../core/datasource/ShardingSphereDataSource.java  |  3 -
 .../GovernanceShardingSphereDataSource.java        | 10 ---
 .../internal/state/impl/LockDriverState.java       | 11 +--
 .../communication/DatabaseCommunicationEngine.java |  5 +-
 .../proxy/backend/context/ProxyContext.java        | 10 +++
 .../impl/AbstractBootstrapInitializer.java         |  3 -
 .../impl/GovernanceBootstrapInitializer.java       |  9 ---
 .../impl/StandardBootstrapInitializer.java         |  7 --
 .../proxy/frontend/state/impl/LockProxyState.java  |  4 +-
 .../scaling/core/job/FinishedCheckJob.java         | 19 ++---
 21 files changed, 299 insertions(+), 186 deletions(-)

diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
index 97e0bde..4f167c1 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
@@ -22,12 +22,14 @@ import com.google.common.eventbus.Subscribe;
 import org.apache.shardingsphere.governance.core.event.model.auth.AuthenticationChangedEvent;
 import org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangeCompletedEvent;
 import org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangedEvent;
+import org.apache.shardingsphere.governance.core.event.model.lock.UnlockEvent;
 import org.apache.shardingsphere.governance.core.event.model.metadata.MetaDataAddedEvent;
 import org.apache.shardingsphere.governance.core.event.model.metadata.MetaDataDeletedEvent;
 import org.apache.shardingsphere.governance.core.event.model.props.PropertiesChangedEvent;
 import org.apache.shardingsphere.governance.core.event.model.rule.RuleConfigurationsChangedEvent;
 import org.apache.shardingsphere.governance.core.event.model.schema.SchemaChangedEvent;
 import org.apache.shardingsphere.governance.core.facade.GovernanceFacade;
+import org.apache.shardingsphere.governance.core.lock.GovernanceLockContext;
 import org.apache.shardingsphere.governance.core.registry.event.DisabledStateChangedEvent;
 import org.apache.shardingsphere.governance.core.registry.event.PrimaryStateChangedEvent;
 import org.apache.shardingsphere.governance.core.registry.schema.GovernanceSchema;
@@ -41,6 +43,7 @@ import org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
 import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.optimize.context.CalciteContextFactory;
@@ -48,9 +51,6 @@ import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.event.impl.DataSourceNameDisabledEvent;
 import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
 import org.apache.shardingsphere.infra.rule.type.StatusContainedRule;
-import org.apache.shardingsphere.infra.state.StateContext;
-import org.apache.shardingsphere.infra.state.StateEvent;
-import org.apache.shardingsphere.infra.state.StateType;
 
 import javax.sql.DataSource;
 import java.sql.SQLException;
@@ -72,12 +72,15 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
     
     private volatile StandardMetaDataContexts metaDataContexts;
     
+    private final LockContext lockContext;
+    
     public GovernanceMetaDataContexts(final StandardMetaDataContexts metaDataContexts, final GovernanceFacade governanceFacade) {
         this.governanceFacade = governanceFacade;
         this.metaDataContexts = metaDataContexts;
         ShardingSphereEventBus.getInstance().register(this);
         disableDataSources();
         persistMetaData();
+        lockContext = new GovernanceLockContext(governanceFacade.getRegistryCenter());
     }
     
     private void disableDataSources() {
@@ -134,6 +137,11 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
     }
     
     @Override
+    public LockContext getLockContext() {
+        return this.lockContext;
+    }
+    
+    @Override
     public void close() {
         metaDataContexts.close();
         governanceFacade.close();
@@ -206,10 +214,7 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
             }
             metaDataContexts = new StandardMetaDataContexts(newMetaDataMap, metaDataContexts.getExecutorEngine(), metaDataContexts.getAuthentication(), metaDataContexts.getProps());
         } finally {
-            if (StateContext.getCurrentState() == StateType.LOCK) {
-                StateContext.switchState(new StateEvent(StateType.LOCK, false));
-                governanceFacade.getRegistryCenter().persistInstanceData("");
-            }
+            ShardingSphereEventBus.getInstance().post(new UnlockEvent());
         }
     }
     
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/lock/UnlockEvent.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/lock/UnlockEvent.java
new file mode 100644
index 0000000..3253bf9
--- /dev/null
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/lock/UnlockEvent.java
@@ -0,0 +1,26 @@
+/*
+ * 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.governance.core.event.model.lock;
+
+import org.apache.shardingsphere.governance.core.event.model.GovernanceEvent;
+
+/**
+ * Unlock event.
+ */
+public final class UnlockEvent implements GovernanceEvent {
+}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/GovernanceLockContext.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/GovernanceLockContext.java
new file mode 100644
index 0000000..ef2e276
--- /dev/null
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/lock/GovernanceLockContext.java
@@ -0,0 +1,89 @@
+/*
+ * 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.governance.core.lock;
+
+import com.google.common.eventbus.Subscribe;
+import org.apache.shardingsphere.governance.core.event.model.lock.GlobalLockAddedEvent;
+import org.apache.shardingsphere.governance.core.event.model.lock.UnlockEvent;
+import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
+import org.apache.shardingsphere.governance.core.registry.RegistryCenterNodeStatus;
+import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
+import org.apache.shardingsphere.infra.lock.AbstractLockContext;
+import org.apache.shardingsphere.infra.state.StateContext;
+import org.apache.shardingsphere.infra.state.StateEvent;
+import org.apache.shardingsphere.infra.state.StateType;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Governance lock context.
+ */
+public final class GovernanceLockContext extends AbstractLockContext {
+    
+    private final RegistryCenter registryCenter;
+    
+    public GovernanceLockContext(final RegistryCenter registryCenter) {
+        this.registryCenter = registryCenter;
+        ShardingSphereEventBus.getInstance().register(this);
+    }
+    
+    @Override
+    public boolean tryGlobalLock(final long timeout, final TimeUnit timeUnit) {
+        return registryCenter.tryGlobalLock(timeout, timeUnit);
+    }
+    
+    @Override
+    public void releaseGlobalLock() {
+        registryCenter.releaseGlobalLock();
+    }
+    
+    /**
+     * Switch state.
+     *
+     * @param event state event
+     */
+    @Subscribe
+    public void switchState(final StateEvent event) {
+        StateContext.switchState(event);
+    }
+    
+    /**
+     * Lock instance after global lock added.
+     *
+     * @param event global lock added event
+     */
+    @Subscribe
+    public void doLock(final GlobalLockAddedEvent event) {
+        StateContext.switchState(new StateEvent(StateType.LOCK, true));
+        registryCenter.persistInstanceData(RegistryCenterNodeStatus.LOCKED.toString());
+    }
+    
+    /**
+     * unlock instance.
+     * 
+     * @param event unlock event
+     */
+    @Subscribe
+    public void unlock(final UnlockEvent event) {
+        if (StateContext.getCurrentState() == StateType.LOCK) {
+            StateContext.switchState(new StateEvent(StateType.LOCK, false));
+            registryCenter.persistInstanceData("");
+            signalAll();
+        }
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/AbstractLockContext.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/AbstractLockContext.java
new file mode 100644
index 0000000..86324fd
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/AbstractLockContext.java
@@ -0,0 +1,57 @@
+/*
+ * 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.infra.lock;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Abstract lock context.
+ */
+public abstract class AbstractLockContext implements LockContext {
+    
+    private final Lock innerLock = new ReentrantLock();
+    
+    private final Condition innerCondition = innerLock.newCondition();
+    
+    @Override
+    public boolean await(final Long timeout, final TimeUnit timeUnit) {
+        innerLock.lock();
+        try {
+            return innerCondition.await(timeout, TimeUnit.MILLISECONDS);
+            // CHECKSTYLE:OFF
+        } catch (InterruptedException e) {
+            // CHECKSTYLE:ON
+        } finally {
+            innerLock.unlock();
+        }
+        return false;
+    }
+    
+    @Override
+    public void signalAll() {
+        innerLock.lock();
+        try {
+            innerCondition.signalAll();
+        } finally {
+            innerLock.unlock();
+        }
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java
index 16a0f9b..8197a28 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/LockContext.java
@@ -17,80 +17,38 @@
 
 package org.apache.shardingsphere.infra.lock;
 
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
-
-import java.util.Properties;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * Lock context.
  */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class LockContext {
-    
-    private static final AtomicReference<LockStrategy> LOCK_STRATEGY = new AtomicReference<>();
-    
-    private static final Lock LOCK = new ReentrantLock();
-    
-    private static final Condition CONDITION = LOCK.newCondition();
-    
-    static {
-        ShardingSphereServiceLoader.register(LockStrategy.class);
-    }
+public interface LockContext {
     
     /**
-     * Init lock strategy.
+     * Try to get lock.
      *
-     * @param lockStrategyType lock strategy type
+     * @param timeout the maximum time in milliseconds to acquire lock
+     * @param timeUnit time unit
+     * @return true if get the lock, false if not
      */
-    public static void init(final LockStrategyType lockStrategyType) {
-        LOCK_STRATEGY.set(TypedSPIRegistry.getRegisteredService(LockStrategy.class, lockStrategyType.name(), new Properties()));
-    }
+    boolean tryGlobalLock(long timeout, TimeUnit timeUnit);
     
     /**
-     * Get lock strategy.
-     * 
-     * @return lock strategy
+     * Release lock.
      */
-    public static LockStrategy getLockStrategy() {
-        return LOCK_STRATEGY.get();
-    }
+    void releaseGlobalLock();
     
     /**
-     * Waiting for unlock.
+     * await.
      * 
-     * @param timeout the maximum time in milliseconds to wait
-     * @return false if wait timeout exceeded, else true
+     * @param timeout time out
+     * @param timeUnit  time unit
+     * @return true if no exception
      */
-    public static boolean await(final Long timeout) {
-        LOCK.lock();
-        try {
-            return CONDITION.await(timeout, TimeUnit.MILLISECONDS);
-            // CHECKSTYLE:OFF
-        } catch (InterruptedException e) {
-            // CHECKSTYLE:ON
-        } finally {
-            LOCK.unlock();
-        }
-        return false;
-    }
+    boolean await(Long timeout, TimeUnit timeUnit);
     
     /**
-     * Notify all blocked tasks.
+     * signal all.
      */
-    public static void signalAll() {
-        LOCK.lock();
-        try {
-            CONDITION.signalAll();
-        } finally {
-            LOCK.unlock();
-        }
-    }
+    void signalAll();
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/StandardLockContext.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/StandardLockContext.java
new file mode 100644
index 0000000..571faf8
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/lock/StandardLockContext.java
@@ -0,0 +1,55 @@
+/*
+ * 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.infra.lock;
+
+import org.apache.shardingsphere.infra.state.StateContext;
+import org.apache.shardingsphere.infra.state.StateEvent;
+import org.apache.shardingsphere.infra.state.StateType;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Standard lock context.
+ */
+public final class StandardLockContext extends AbstractLockContext {
+    
+    private final ReentrantLock lock = new ReentrantLock();
+    
+    @Override
+    public boolean tryGlobalLock(final long timeout, final TimeUnit timeUnit) {
+        boolean result = false;
+        try {
+            result = lock.tryLock(timeout, timeUnit);
+            // CHECKSTYLE:OFF
+        } catch (final InterruptedException e) {
+            // CHECKSTYLE:ON
+        }
+        if (result) {
+            StateContext.switchState(new StateEvent(StateType.LOCK, true));
+        }
+        return result;
+    }
+    
+    @Override
+    public void releaseGlobalLock() {
+        lock.unlock();
+        StateContext.switchState(new StateEvent(StateType.LOCK, false));
+        signalAll();
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/state/StateContext.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/state/StateContext.java
index 9e3fce1..2f0d0d7 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/state/StateContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/state/StateContext.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.infra.state;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.lock.LockContext;
 
 import java.util.Collections;
 import java.util.Deque;
@@ -47,14 +46,6 @@ public final class StateContext {
                 recoverState();
             }
         }
-        signalAll();
-    }
-    
-    private static void signalAll() {
-        if (getCurrentState() == StateType.LOCK) {
-            return;
-        }
-        LockContext.signalAll();
     }
     
     /**
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/lock/LockContextTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/lock/LockContextTest.java
deleted file mode 100644
index 8b9f871..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/lock/LockContextTest.java
+++ /dev/null
@@ -1,54 +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.infra.lock;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public final class LockContextTest {
-    
-    @Before
-    public void init() {
-        LockContext.init(LockStrategyType.STANDARD);
-    }
-    
-    @Test
-    public void assertGetLockStrategy() {
-        assertNotNull(LockContext.getLockStrategy());
-    }
-    
-    @Test
-    public void assetAwait() {
-        new Thread(() -> {
-            try {
-                TimeUnit.MILLISECONDS.sleep(200L);
-                // CHECKSTYLE:OFF
-            } catch (final InterruptedException e) {
-                // CHECKSTYLE:ON
-            }
-            LockContext.signalAll();
-        }).start();
-        boolean result = LockContext.await(400L);
-        assertTrue(result);
-    }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContexts.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContexts.java
index 04422ff..1983025 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContexts.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContexts.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.infra.context.metadata;
 import org.apache.shardingsphere.infra.auth.Authentication;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.optimize.context.CalciteContextFactory;
 
@@ -80,4 +81,11 @@ public interface MetaDataContexts extends Closeable {
      * @return configuration properties
      */
     ConfigurationProperties getProps();
+    
+    /**
+     * Get lock context.
+     * 
+     * @return lock context
+     */
+    LockContext getLockContext();
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java
index 070122a..30b7d85 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java
@@ -25,6 +25,8 @@ import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
 import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.lock.LockContext;
+import org.apache.shardingsphere.infra.lock.StandardLockContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.optimize.context.CalciteContextFactory;
 
@@ -49,6 +51,8 @@ public final class StandardMetaDataContexts implements MetaDataContexts {
     
     private final ConfigurationProperties props;
     
+    private final LockContext lockContext;
+    
     public StandardMetaDataContexts() {
         this(new ConcurrentHashMap<>(), null, new DefaultAuthentication(), new ConfigurationProperties(new Properties()));
     }
@@ -60,6 +64,7 @@ public final class StandardMetaDataContexts implements MetaDataContexts {
         calciteContextFactory = new CalciteContextFactory(metaDataMap);
         this.authentication = AuthenticationEngine.findSPIAuthentication().orElse(authentication);
         this.props = props;
+        this.lockContext = new StandardLockContext();
     }
     
     @Override
@@ -78,6 +83,11 @@ public final class StandardMetaDataContexts implements MetaDataContexts {
     }
     
     @Override
+    public LockContext getLockContext() {
+        return this.lockContext;
+    }
+    
+    @Override
     public void close() {
         executorEngine.close();
     }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java
index ec19c5d..007d9ce 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverJDBCExecutor.java
@@ -30,7 +30,6 @@ import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.J
 import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
 import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback;
 import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
-import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilderMaterials;
@@ -141,7 +140,7 @@ public final class DriverJDBCExecutor {
     
     private boolean tryGlobalLock(final SQLStatement sqlStatement, final long lockTimeoutMilliseconds) {
         if (needLock(sqlStatement)) {
-            if (!LockContext.getLockStrategy().tryGlobalLock(lockTimeoutMilliseconds, TimeUnit.MILLISECONDS)) {
+            if (!metaDataContexts.getLockContext().tryGlobalLock(lockTimeoutMilliseconds, TimeUnit.MILLISECONDS)) {
                 throw new ShardingSphereException("Service lock wait timeout of %s ms exceeded", lockTimeoutMilliseconds);
             }
             return true;
@@ -170,6 +169,6 @@ public final class DriverJDBCExecutor {
     }
     
     private void releaseGlobalLock() {
-        LockContext.getLockStrategy().releaseGlobalLock();
+        metaDataContexts.getLockContext().releaseGlobalLock();
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 7ec02cf..9a74c77 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -27,8 +27,6 @@ import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
 import org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.lock.LockContext;
-import org.apache.shardingsphere.infra.lock.LockStrategyType;
 import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
 import org.apache.shardingsphere.transaction.context.TransactionContexts;
 import org.apache.shardingsphere.transaction.context.impl.StandardTransactionContexts;
@@ -57,7 +55,6 @@ public final class ShardingSphereDataSource extends AbstractUnsupportedOperation
                 Collections.singletonMap(DefaultSchema.LOGIC_NAME, dataSourceMap), Collections.singletonMap(DefaultSchema.LOGIC_NAME, configurations), props).build();
         String xaTransactionMangerType = metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
         transactionContexts = createTransactionContexts(metaDataContexts.getDefaultMetaData().getResource().getDatabaseType(), dataSourceMap, xaTransactionMangerType);
-        LockContext.init(LockStrategyType.STANDARD);
     }
     
     private TransactionContexts createTransactionContexts(final DatabaseType databaseType, final Map<String, DataSource> dataSourceMap, final String xaTransactionMangerType) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
index 29a43e7..16e4ff3 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.driver.jdbc.unsupported.AbstractUnsupportedOper
 import org.apache.shardingsphere.governance.context.metadata.GovernanceMetaDataContexts;
 import org.apache.shardingsphere.governance.core.config.ConfigCenter;
 import org.apache.shardingsphere.governance.core.facade.GovernanceFacade;
-import org.apache.shardingsphere.governance.core.lock.strategy.GovernanceLockStrategy;
 import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
 import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
@@ -35,8 +34,6 @@ import org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
 import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.lock.LockContext;
-import org.apache.shardingsphere.infra.lock.LockStrategyType;
 import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
 import org.apache.shardingsphere.transaction.context.TransactionContexts;
 import org.apache.shardingsphere.transaction.context.impl.StandardTransactionContexts;
@@ -67,7 +64,6 @@ public final class GovernanceShardingSphereDataSource extends AbstractUnsupporte
         String xaTransactionMangerType = metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
         transactionContexts = createTransactionContexts(metaDataContexts.getDefaultMetaData().getResource().getDatabaseType(),
                 metaDataContexts.getDefaultMetaData().getResource().getDataSources(), xaTransactionMangerType);
-        initLockContext(governanceFacade);
     }
     
     public GovernanceShardingSphereDataSource(final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> ruleConfigs, 
@@ -78,7 +74,6 @@ public final class GovernanceShardingSphereDataSource extends AbstractUnsupporte
         transactionContexts = createTransactionContexts(metaDataContexts.getDefaultMetaData().getResource().getDatabaseType(),
                 metaDataContexts.getDefaultMetaData().getResource().getDataSources(), xaTransactionMangerType);
         uploadLocalConfiguration(governanceFacade);
-        initLockContext(governanceFacade);
     }
     
     private GovernanceFacade createGovernanceFacade(final GovernanceConfiguration config) {
@@ -118,11 +113,6 @@ public final class GovernanceShardingSphereDataSource extends AbstractUnsupporte
                 Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigurations), null, metaDataContexts.getProps().getProps());
     }
     
-    private void initLockContext(final GovernanceFacade governanceFacade) {
-        LockContext.init(LockStrategyType.GOVERNANCE);
-        ((GovernanceLockStrategy) LockContext.getLockStrategy()).init(governanceFacade.getRegistryCenter());
-    }
-    
     @Override
     public Connection getConnection() {
         return DriverStateContext.getConnection(getDataSourceMap(), metaDataContexts, transactionContexts, TransactionTypeHolder.get());
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/state/impl/LockDriverState.java b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/state/impl/LockDriverState.java
index 4320794..c7e608d 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/state/impl/LockDriverState.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/state/impl/LockDriverState.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConne
 import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
 import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.state.StateContext;
 import org.apache.shardingsphere.infra.state.StateType;
 import org.apache.shardingsphere.transaction.context.TransactionContexts;
@@ -33,6 +32,7 @@ import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
 import javax.sql.DataSource;
 import java.sql.Connection;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Lock driver state.
@@ -42,7 +42,7 @@ public final class LockDriverState implements DriverState {
     @Override
     public Connection getConnection(final Map<String, DataSource> dataSourceMap, 
                                     final MetaDataContexts metaDataContexts, final TransactionContexts transactionContexts, final TransactionType transactionType) {
-        block(metaDataContexts.getProps().<Long>getValue(ConfigurationPropertyKey.LOCK_WAIT_TIMEOUT_MILLISECONDS));
+        block(metaDataContexts);
         if (StateContext.getCurrentState() == StateType.OK) {
             return new ShardingSphereConnection(dataSourceMap, metaDataContexts, transactionContexts, TransactionTypeHolder.get());
         } else if (StateContext.getCurrentState() == StateType.CIRCUIT_BREAK) {
@@ -51,9 +51,10 @@ public final class LockDriverState implements DriverState {
         throw new UnsupportedOperationException(String.format("Unknown driver state type: %s", StateContext.getCurrentState().name()));
     }
     
-    private void block(final long lockTimeoutMilliseconds) {
-        if (!LockContext.await(lockTimeoutMilliseconds)) {
-            throw new ShardingSphereException("Service lock wait timeout of %s ms exceeded", lockTimeoutMilliseconds);
+    private void block(final MetaDataContexts metaDataContexts) {
+        long lockTimeoutMilliseconds = metaDataContexts.getProps().<Long>getValue(ConfigurationPropertyKey.LOCK_WAIT_TIMEOUT_MILLISECONDS);
+        if (!metaDataContexts.getLockContext().await(lockTimeoutMilliseconds, TimeUnit.MILLISECONDS)) {
+            throw new ShardingSphereException("Service lock wait timeout of %s ms exceeded", lockTimeoutMilliseconds); 
         }
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
index a9a6ef3..23e453a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
@@ -28,7 +28,6 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult
 import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
 import org.apache.shardingsphere.infra.executor.sql.execute.result.update.UpdateResult;
 import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
-import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.merge.MergeEngine;
 import org.apache.shardingsphere.infra.merge.result.MergedResult;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
@@ -129,7 +128,7 @@ public final class DatabaseCommunicationEngine {
     
     private boolean tryGlobalLock(final ExecutionContext executionContext, final Long lockTimeoutMilliseconds) {
         if (needLock(executionContext)) {
-            if (!LockContext.getLockStrategy().tryGlobalLock(lockTimeoutMilliseconds, TimeUnit.MILLISECONDS)) {
+            if (!ProxyContext.getInstance().getLockContext().tryGlobalLock(lockTimeoutMilliseconds, TimeUnit.MILLISECONDS)) {
                 throw new LockWaitTimeoutException(lockTimeoutMilliseconds);
             }
             return true;
@@ -142,7 +141,7 @@ public final class DatabaseCommunicationEngine {
     }
     
     private void releaseGlobalLock() {
-        LockContext.getLockStrategy().releaseGlobalLock();
+        ProxyContext.getInstance().getLockContext().releaseGlobalLock();
     }
     
     private QueryResponseHeader processExecuteQuery(final ExecutionContext executionContext, final List<QueryResult> queryResults, final QueryResult queryResultSample) throws SQLException {
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 7fbf56e..e15d5bc 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,6 +21,7 @@ import com.google.common.base.Strings;
 import lombok.Getter;
 import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
 import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
+import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.JDBCBackendDataSource;
 import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
@@ -101,4 +102,13 @@ public final class ProxyContext {
     public List<String> getAllSchemaNames() {
         return new ArrayList<>(metaDataContexts.getAllSchemaNames());
     }
+    
+    /**
+     * Get lock context.
+     * 
+     * @return lock context
+     */
+    public LockContext getLockContext() {
+        return metaDataContexts.getLockContext();
+    }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
index cfef7f0..8415b43 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/AbstractBootstrapInitializer.java
@@ -61,7 +61,6 @@ public abstract class AbstractBootstrapInitializer implements BootstrapInitializ
         TransactionContexts transactionContexts = decorateTransactionContexts(createTransactionContexts(metaDataContexts), xaTransactionMangerType);
         ProxyContext.getInstance().init(metaDataContexts, transactionContexts);
         setDatabaseServerInfo();
-        initLockContext();
         initScalingWorker(yamlConfig);
         shardingSphereProxy.start(port);
     }
@@ -134,7 +133,5 @@ public abstract class AbstractBootstrapInitializer implements BootstrapInitializ
     
     protected abstract TransactionContexts decorateTransactionContexts(TransactionContexts transactionContexts, String xaTransactionMangerType);
     
-    protected abstract void initLockContext();
-    
     protected abstract void initScalingWorker(YamlProxyConfiguration yamlConfig);
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
index 66f5a9f..feb93c4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.proxy.initializer.impl;
 import org.apache.shardingsphere.governance.context.metadata.GovernanceMetaDataContexts;
 import org.apache.shardingsphere.governance.context.transaction.GovernanceTransactionContexts;
 import org.apache.shardingsphere.governance.core.facade.GovernanceFacade;
-import org.apache.shardingsphere.governance.core.lock.strategy.GovernanceLockStrategy;
 import org.apache.shardingsphere.governance.core.yaml.swapper.GovernanceConfigurationYamlSwapper;
 import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
 import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
@@ -30,8 +29,6 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration
 import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
 import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
 import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
-import org.apache.shardingsphere.infra.lock.LockContext;
-import org.apache.shardingsphere.infra.lock.LockStrategyType;
 import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
 import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
 import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
@@ -130,12 +127,6 @@ public final class GovernanceBootstrapInitializer extends AbstractBootstrapIniti
     }
     
     @Override
-    protected void initLockContext() {
-        LockContext.init(LockStrategyType.GOVERNANCE);
-        ((GovernanceLockStrategy) LockContext.getLockStrategy()).init(governanceFacade.getRegistryCenter());
-    }
-    
-    @Override
     protected void initScalingWorker(final YamlProxyConfiguration yamlConfig) {
         Optional<ServerConfiguration> scalingConfigurationOptional = getScalingConfiguration(yamlConfig);
         if (scalingConfigurationOptional.isPresent()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializer.java
index ace742c..c643dc6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializer.java
@@ -18,8 +18,6 @@
 package org.apache.shardingsphere.proxy.initializer.impl;
 
 import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.lock.LockContext;
-import org.apache.shardingsphere.infra.lock.LockStrategyType;
 import org.apache.shardingsphere.proxy.config.ProxyConfiguration;
 import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration;
 import org.apache.shardingsphere.proxy.config.yaml.swapper.YamlProxyConfigurationSwapper;
@@ -50,11 +48,6 @@ public final class StandardBootstrapInitializer extends AbstractBootstrapInitial
     }
     
     @Override
-    protected void initLockContext() {
-        LockContext.init(LockStrategyType.STANDARD);
-    }
-    
-    @Override
     protected void initScalingWorker(final YamlProxyConfiguration yamlConfig) {
         Optional<ServerConfiguration> scalingConfigurationOptional = getScalingConfiguration(yamlConfig);
         if (scalingConfigurationOptional.isPresent()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
index 1751b51..9e977d5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
@@ -21,7 +21,6 @@ import io.netty.channel.ChannelHandlerContext;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.state.StateContext;
 import org.apache.shardingsphere.infra.state.StateType;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -36,6 +35,7 @@ import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
 
 import java.util.Optional;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Lock proxy state.
@@ -55,7 +55,7 @@ public final class LockProxyState implements ProxyState {
     
     private void block(final ChannelHandlerContext context, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine) {
         Long lockTimeoutMilliseconds = ProxyContext.getInstance().getMetaDataContexts().getProps().<Long>getValue(ConfigurationPropertyKey.LOCK_WAIT_TIMEOUT_MILLISECONDS);
-        if (!LockContext.await(lockTimeoutMilliseconds)) {
+        if (!ProxyContext.getInstance().getLockContext().await(lockTimeoutMilliseconds, TimeUnit.MILLISECONDS)) {
             doError(context, databaseProtocolFrontendEngine, new LockWaitTimeoutException(lockTimeoutMilliseconds));
         }
     }
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/FinishedCheckJob.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/FinishedCheckJob.java
index 5184f96..4e3afa0 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/FinishedCheckJob.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/job/FinishedCheckJob.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
 import org.apache.shardingsphere.governance.core.event.model.rule.SwitchRuleConfigurationEvent;
 import org.apache.shardingsphere.governance.repository.api.RegistryRepository;
 import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
-import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.scaling.core.config.WorkflowConfiguration;
 import org.apache.shardingsphere.scaling.core.constant.ScalingConstant;
 import org.apache.shardingsphere.scaling.core.service.RegistryRepositoryHolder;
@@ -33,7 +32,6 @@ import org.apache.shardingsphere.scaling.core.utils.ThreadUtil;
 import org.apache.shardingsphere.scaling.core.workflow.ScalingServiceHolder;
 
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 
 @Slf4j
 public final class FinishedCheckJob implements SimpleJob {
@@ -66,18 +64,11 @@ public final class FinishedCheckJob implements SimpleJob {
     }
     
     private void trySwitch(final long jobId, final WorkflowConfiguration workflowConfig) {
-        if (LockContext.getLockStrategy().tryGlobalLock(30L, TimeUnit.SECONDS)) {
-            try {
-                ThreadUtil.sleep(10 * 1000L);
-                if (ScalingServiceHolder.getInstance().checkScalingResult(jobId)) {
-                    ScalingServiceHolder.getInstance().stopScalingJob(jobId);
-                    ShardingSphereEventBus.getInstance().post(new SwitchRuleConfigurationEvent(workflowConfig.getSchemaName(), workflowConfig.getRuleCacheId()));
-                }
-            } finally {
-                LockContext.getLockStrategy().releaseGlobalLock();
-            }
-        } else {
-            log.warn("can not get lock.");
+        // TODO lock proxy
+        ThreadUtil.sleep(10 * 1000L);
+        if (ScalingServiceHolder.getInstance().checkScalingResult(jobId)) {
+            ScalingServiceHolder.getInstance().stopScalingJob(jobId);
+            ShardingSphereEventBus.getInstance().post(new SwitchRuleConfigurationEvent(workflowConfig.getSchemaName(), workflowConfig.getRuleCacheId()));
         }
     }
 }