menghaoranss commented on a change in pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270#discussion_r832480728



##########
File path: 
shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
##########
@@ -80,17 +81,21 @@
     
     private volatile InstanceContext instanceContext;
     
+    private volatile LockContext lockContext;
+    
     /**
      * Initialize context manager.
      *
      * @param metaDataContexts meta data contexts
      * @param transactionContexts transaction contexts
      * @param instanceContext instance context
+     * @param lockContext lock context
      */
-    public void init(final MetaDataContexts metaDataContexts, final 
TransactionContexts transactionContexts, final InstanceContext instanceContext) 
{
+    public void init(final MetaDataContexts metaDataContexts, final 
TransactionContexts transactionContexts, final InstanceContext instanceContext, 
final LockContext lockContext) {
         this.metaDataContexts = metaDataContexts;
         this.transactionContexts = transactionContexts;
         this.instanceContext = instanceContext;
+        this.lockContext = lockContext;

Review comment:
       Could `LockContext` be created inside `ContextManager` without passing 
parameter?
   

##########
File path: 
shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/future/lock/ShardingSphereDistributeGlobalLock.java
##########
@@ -0,0 +1,186 @@
+/*
+ * 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.coordinator.future.lock;
+
+import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.lock.ShardingSphereGlobalLock;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.future.lock.service.GlobalLockRegistryService;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.future.lock.util.GlobalLockNode;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Global distribute lock of ShardingSphere.
+ */
+public final class ShardingSphereDistributeGlobalLock implements 
ShardingSphereGlobalLock {
+    
+    private static final ReadWriteLock LOCK = new ReentrantReadWriteLock();
+    
+    private static final int CHECK_ACK_INTERVAL_SECONDS = 1;
+    
+    private static final long DEFAULT_TRY_LOCK_TIMEOUT_MILLISECONDS = 3 * 60 * 
1000;
+    
+    private static final long DEFAULT_REGISTRY_TIMEOUT_MILLISECONDS = 3 * 1000;
+    
+    private final InstanceContext instanceContext;
+    
+    private final String ownerInstanceId;
+    
+    private final GlobalLockRegistryService lockService;
+    
+    private final Set<String> lockedInstances = new LinkedHashSet<>();
+    
+    public ShardingSphereDistributeGlobalLock(final InstanceContext 
instanceContext, final GlobalLockRegistryService lockService) {
+        this.lockService = lockService;
+        this.instanceContext = instanceContext;
+        this.ownerInstanceId = 
instanceContext.getInstance().getInstanceDefinition().getInstanceId().getId();

Review comment:
       `this.ownerInstanceId`: the `this` is unnecessary, just use 
`ownerInstanceId =`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to