[ 
https://issues.apache.org/jira/browse/GEODE-8099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17124229#comment-17124229
 ] 

ASF GitHub Bot commented on GEODE-8099:
---------------------------------------

jchen21 commented on a change in pull request #5188:
URL: https://github.com/apache/geode/pull/5188#discussion_r434115982



##########
File path: 
geode-core/src/main/java/org/apache/geode/management/internal/api/LocatorClusterManagementService.java
##########
@@ -105,7 +107,12 @@
 import org.apache.geode.management.runtime.OperationResult;
 import org.apache.geode.management.runtime.RuntimeInfo;
 
+/**
+ * each locator will have one instance of this running if enabled
+ */
 public class LocatorClusterManagementService implements 
ClusterManagementService {
+  @VisibleForTesting
+  static final String CMS_NAME = "CMS_LOCK_SERVICE";

Review comment:
       It would be better to add some comments for this constant.

##########
File path: 
geode-core/src/test/java/org/apache/geode/management/internal/api/LocatorClusterManagementServiceTest.java
##########
@@ -125,22 +127,48 @@ public void before() throws Exception {
     doReturn(true).when(persistenceService).lockSharedConfiguration();
     doNothing().when(persistenceService).unlockSharedConfiguration();
     operationManager = mock(OperationManager.class);
+    dLockService = mock(DistributedLockService.class);
+
     service =
         spy(new LocatorClusterManagementService(cache, persistenceService, 
managers, validators,
             memberValidator, cacheElementValidator, operationManager));
+    doReturn(dLockService).when(service).getCmsDlockService();
 
     regionConfig = new Region();
     regionConfig.setName("region1");
 
     rebalanceOperation = new RebalanceOperation();
   }
 
+  @Test
+  public void lockAndUnlockCalledAtCreate() {
+    try {
+      service.create(regionConfig);
+    } catch (Exception ignore) {
+    }
+
+    verify(dLockService).lock(LocatorClusterManagementService.CMS_NAME, -1, 
-1);
+    verify(dLockService).unlock(LocatorClusterManagementService.CMS_NAME);
+  }
+
+  @Test
+  public void lockAndUnlockCalledAtDelete() {
+    try {
+      service.delete(regionConfig);
+    } catch (Exception ignore) {
+    }
+
+    verify(dLockService).lock(LocatorClusterManagementService.CMS_NAME, -1, 
-1);
+    verify(dLockService).unlock(LocatorClusterManagementService.CMS_NAME);
+  }
+
   @Test
   public void create_persistenceIsNull() {
     org.apache.geode.cache.Region<Object, Object> region =
         mock(org.apache.geode.cache.Region.class);
     when(cache.getRegion(any())).thenReturn(region);
-    service = new LocatorClusterManagementService(cache, null);

Review comment:
       This code change could loose code coverage for the constructor 
`LocatorClusterManagementService(InternalCache cache, 
InternalConfigurationPersistenceService persistenceService)`. I don't see this 
constructor is covered anywhere else.

##########
File path: 
geode-core/src/main/java/org/apache/geode/management/internal/api/LocatorClusterManagementService.java
##########
@@ -105,7 +107,12 @@
 import org.apache.geode.management.runtime.OperationResult;
 import org.apache.geode.management.runtime.RuntimeInfo;
 
+/**
+ * each locator will have one instance of this running if enabled
+ */
 public class LocatorClusterManagementService implements 
ClusterManagementService {
+  @VisibleForTesting
+  static final String CMS_NAME = "CMS_LOCK_SERVICE";

Review comment:
       It would be better to add some comment for this constant. 

##########
File path: 
geode-core/src/test/java/org/apache/geode/management/internal/api/LocatorClusterManagementServiceTest.java
##########
@@ -125,22 +127,48 @@ public void before() throws Exception {
     doReturn(true).when(persistenceService).lockSharedConfiguration();
     doNothing().when(persistenceService).unlockSharedConfiguration();
     operationManager = mock(OperationManager.class);
+    dLockService = mock(DistributedLockService.class);
+
     service =
         spy(new LocatorClusterManagementService(cache, persistenceService, 
managers, validators,
             memberValidator, cacheElementValidator, operationManager));
+    doReturn(dLockService).when(service).getCmsDlockService();
 
     regionConfig = new Region();
     regionConfig.setName("region1");
 
     rebalanceOperation = new RebalanceOperation();
   }
 
+  @Test
+  public void lockAndUnlockCalledAtCreate() {
+    try {
+      service.create(regionConfig);
+    } catch (Exception ignore) {
+    }
+
+    verify(dLockService).lock(LocatorClusterManagementService.CMS_NAME, -1, 
-1);
+    verify(dLockService).unlock(LocatorClusterManagementService.CMS_NAME);
+  }
+
+  @Test
+  public void lockAndUnlockCalledAtDelete() {
+    try {
+      service.delete(regionConfig);
+    } catch (Exception ignore) {
+    }
+
+    verify(dLockService).lock(LocatorClusterManagementService.CMS_NAME, -1, 
-1);
+    verify(dLockService).unlock(LocatorClusterManagementService.CMS_NAME);
+  }
+
   @Test
   public void create_persistenceIsNull() {
     org.apache.geode.cache.Region<Object, Object> region =
         mock(org.apache.geode.cache.Region.class);
     when(cache.getRegion(any())).thenReturn(region);
-    service = new LocatorClusterManagementService(cache, null);

Review comment:
       This change removes the code coverage for the constructor 
`LocatorClusterManagementService(InternalCache cache, 
InternalConfigurationPersistenceService persistenceService)`. I don't see it is 
covered anywhere else.




----------------------------------------------------------------
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.

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


> Make ClusterConfiguration Service thread safe
> ---------------------------------------------
>
>                 Key: GEODE-8099
>                 URL: https://issues.apache.org/jira/browse/GEODE-8099
>             Project: Geode
>          Issue Type: Bug
>          Components: configuration
>            Reporter: Anilkumar Gingade
>            Priority: Major
>              Labels: GeodeOperationAPI
>             Fix For: 1.14.0
>
>
> When multiple cluster configuration clients (multiple rest clients) connects 
> and issue configuration commands, the cluster configuration should handle 
> concurrent request and modify/save/execute the configuration definition in 
> thread safe manner.  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to