You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/03/22 10:51:41 UTC

[GitHub] [shardingsphere] soulasuna opened a new pull request #16270: Add basic framework for global lock by cluster mode

soulasuna opened a new pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270


   ## Add basic framework for global lock by cluster mode
   
   Related to #16269.
   
   Changes proposed in this pull request:
   - Add interface `ShardingSphereGlobalLock` extended `ShardingSphereLock`
   - Add interface `LockContext`
   - Add `DistributeLockContext` implemented  `LockContext` in cluster mode
   - Add `ShardingSphereDistributeGlobalLock` implemented `ShardingSphereGlobalLock` in cluster mode 
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270#discussion_r832482963



##########
File path: shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
##########
@@ -150,10 +152,12 @@ private ContextManager createContextManager(final ClusterPersistRepository repos
                                                 final Properties transactionProps, final ModeConfiguration modeConfiguration) {
         InstanceContext instanceContext = new InstanceContext(metaDataPersistService.getComputeNodePersistService().loadComputeNodeInstance(instanceDefinition),
                 new ClusterWorkerIdGenerator(repository, metaDataPersistService, instanceDefinition), modeConfiguration);
+        DistributeLockContext distributeLockContext = new DistributeLockContext(instanceContext, new GlobalLockRegistryService(repository));
+        distributeLockContext.synchronizeGlobalLock();

Review comment:
       what `synchronizeGlobalLock` will do here?

##########
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/util/GlobalLockNode.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.util;
+
+import com.google.common.base.Joiner;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Global lock node.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class GlobalLockNode {

Review comment:
       Is the existing `LockNode` still useful ?
   




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] soulasuna commented on a change in pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
soulasuna commented on a change in pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270#discussion_r832772160



##########
File path: shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
##########
@@ -150,10 +152,12 @@ private ContextManager createContextManager(final ClusterPersistRepository repos
                                                 final Properties transactionProps, final ModeConfiguration modeConfiguration) {
         InstanceContext instanceContext = new InstanceContext(metaDataPersistService.getComputeNodePersistService().loadComputeNodeInstance(instanceDefinition),
                 new ClusterWorkerIdGenerator(repository, metaDataPersistService, instanceDefinition), modeConfiguration);
+        DistributeLockContext distributeLockContext = new DistributeLockContext(instanceContext, new GlobalLockRegistryService(repository));
+        distributeLockContext.synchronizeGlobalLock();

Review comment:
       Three things to do here
   1. Synchronize the global lock state,
   2. Lock resources,
   3. ACK response




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter commented on pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270#issuecomment-1075380894


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16270?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#16270](https://codecov.io/gh/apache/shardingsphere/pull/16270?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (96bf9c2) into [master](https://codecov.io/gh/apache/shardingsphere/commit/afc39910bdeeea31df8cb3965ae5de2547b7ca97?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (afc3991) will **decrease** coverage by `0.27%`.
   > The diff coverage is `13.98%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #16270      +/-   ##
   ============================================
   - Coverage     60.98%   60.70%   -0.28%     
   - Complexity     2068     2072       +4     
   ============================================
     Files          3291     3301      +10     
     Lines         49520    49745     +225     
     Branches       8520     8550      +30     
   ============================================
   + Hits          30198    30199       +1     
   - Misses        16779    17002     +223     
   - Partials       2543     2544       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/16270?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...uture/lock/ShardingSphereDistributeGlobalLock.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9mdXR1cmUvbG9jay9TaGFyZGluZ1NwaGVyZURpc3RyaWJ1dGVHbG9iYWxMb2NrLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...de/manager/memory/MemoryContextManagerBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtbWVtb3J5LW1vZGUvc2hhcmRpbmdzcGhlcmUtbWVtb3J5LW1vZGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvbW9kZS9tYW5hZ2VyL21lbW9yeS9NZW1vcnlDb250ZXh0TWFuYWdlckJ1aWxkZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...re/mode/manager/memory/lock/MemoryLockContext.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtbWVtb3J5LW1vZGUvc2hhcmRpbmdzcGhlcmUtbWVtb3J5LW1vZGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvbW9kZS9tYW5hZ2VyL21lbW9yeS9sb2NrL01lbW9yeUxvY2tDb250ZXh0LmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...coordinator/future/lock/DistributeLockContext.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9mdXR1cmUvbG9jay9EaXN0cmlidXRlTG9ja0NvbnRleHQuamF2YQ==) | `12.90% <12.90%> (ø)` | |
   | [...r/future/lock/watcher/GlobalAckChangedWatcher.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9mdXR1cmUvbG9jay93YXRjaGVyL0dsb2JhbEFja0NoYW5nZWRXYXRjaGVyLmphdmE=) | `14.28% <14.28%> (ø)` | |
   | [...future/lock/watcher/GlobalLocksChangedWatcher.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9mdXR1cmUvbG9jay93YXRjaGVyL0dsb2JhbExvY2tzQ2hhbmdlZFdhdGNoZXIuamF2YQ==) | `15.38% <15.38%> (ø)` | |
   | [...manager/standalone/lock/StandaloneLockContext.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtc3RhbmRhbG9uZS1tb2RlL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvc3RhbmRhbG9uZS9sb2NrL1N0YW5kYWxvbmVMb2NrQ29udGV4dC5qYXZh) | `25.00% <25.00%> (ø)` | |
   | [...future/lock/service/GlobalLockRegistryService.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9mdXR1cmUvbG9jay9zZXJ2aWNlL0dsb2JhbExvY2tSZWdpc3RyeVNlcnZpY2UuamF2YQ==) | `30.00% <30.00%> (ø)` | |
   | [...r/coordinator/future/lock/util/GlobalLockNode.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9mdXR1cmUvbG9jay91dGlsL0dsb2JhbExvY2tOb2RlLmphdmE=) | `54.54% <54.54%> (ø)` | |
   | [...he/shardingsphere/mode/manager/ContextManager.java](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWFuYWdlci9Db250ZXh0TWFuYWdlci5qYXZh) | `68.19% <100.00%> (+0.12%)` | :arrow_up: |
   | ... and [50 more](https://codecov.io/gh/apache/shardingsphere/pull/16270/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16270?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16270?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [afc3991...96bf9c2](https://codecov.io/gh/apache/shardingsphere/pull/16270?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss merged pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
menghaoranss merged pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] soulasuna commented on a change in pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
soulasuna commented on a change in pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270#discussion_r832771011



##########
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:
       Because `LockContext`  will synchronize the global lock state of the registry when `Proxy` starts.
   Execute before register Online Instance in ContextManager can not be created inside now.
   Will refactor later if possible




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] soulasuna commented on a change in pull request #16270: Add basic framework for global lock by cluster mode

Posted by GitBox <gi...@apache.org>.
soulasuna commented on a change in pull request #16270:
URL: https://github.com/apache/shardingsphere/pull/16270#discussion_r832776137



##########
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/util/GlobalLockNode.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.util;
+
+import com.google.common.base.Joiner;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Global lock node.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class GlobalLockNode {

Review comment:
       Yes `scaling` is in use, will be merged when completed.




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org