You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jc...@apache.org on 2019/02/19 20:05:09 UTC
[geode] branch develop updated: GEODE-6365: Group support for JDBC
mapping logic in DestroyRegionCommand (#3202)
This is an automated email from the ASF dual-hosted git repository.
jchen21 pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 49696f8 GEODE-6365: Group support for JDBC mapping logic in DestroyRegionCommand (#3202)
49696f8 is described below
commit 49696f83c70606673758a19cf904b544d1df4346
Author: BenjaminPerryRoss <39...@users.noreply.github.com>
AuthorDate: Tue Feb 19 12:04:17 2019 -0800
GEODE-6365: Group support for JDBC mapping logic in DestroyRegionCommand (#3202)
Added server group support for the logic in destroy region which
checks for an existing jdbc-mapping
---
.../cli/commands/DestroyRegionCommand.java | 33 +++++++++++++---------
.../cli/commands/DestroyRegionCommandTest.java | 16 +++++++++--
2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java
index c9ffcb9..6df293e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommand.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.management.internal.cli.commands;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -95,19 +96,25 @@ public class DestroyRegionCommand extends InternalGfshCommand {
if (ccService == null) {
return;
}
- CacheConfig cacheConfig = ccService.getCacheConfig(null);
- if (cacheConfig == null) {
- return;
- }
- RegionConfig regionConfig = CacheElement.findElement(cacheConfig.getRegions(), regionName);
- if (regionConfig == null) {
- return;
- }
- CacheElement element =
- CacheElement.findElement(regionConfig.getCustomRegionElements(), "jdbc-mapping");
- if (element != null) {
- throw new IllegalStateException("Cannot destroy region \"" + regionName
- + "\" because JDBC mapping exists. Use \"destroy jdbc-mapping\" first.");
+
+ Set<String> groupNames = new HashSet<String>();
+ groupNames.addAll(ccService.getGroups());
+ groupNames.add("cluster");
+ for (String groupName : groupNames) {
+ CacheConfig cacheConfig = ccService.getCacheConfig(groupName);
+ if (cacheConfig == null) {
+ return;
+ }
+ RegionConfig regionConfig = CacheElement.findElement(cacheConfig.getRegions(), regionName);
+ if (regionConfig == null) {
+ return;
+ }
+ CacheElement element =
+ CacheElement.findElement(regionConfig.getCustomRegionElements(), "jdbc-mapping");
+ if (element != null) {
+ throw new IllegalStateException("Cannot destroy region \"" + regionName
+ + "\" because JDBC mapping exists. Use \"destroy jdbc-mapping\" first.");
+ }
}
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandTest.java
index 374eba1..46d069d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -165,7 +166,7 @@ public class DestroyRegionCommandTest {
}
private void setupJDBCMappingOnRegion(String regionName) {
- doReturn(cacheConfig).when(ccService).getCacheConfig(null);
+ doReturn(cacheConfig).when(ccService).getCacheConfig("cluster");
doReturn(regionConfigList).when(cacheConfig).getRegions();
doReturn(regionName).when(regionConfig).getName();
doReturn(regionName).when(regionConfig).getId();
@@ -187,6 +188,17 @@ public class DestroyRegionCommandTest {
command.checkForJDBCMapping("regionName");
}
+ @Test(expected = IllegalStateException.class)
+ public void checkForJDBCMappingWithRegionNameThrowsIllegalStateExceptionForGroup() {
+ Set<String> groups = new HashSet<String>();
+ groups.add("Group1");
+ doReturn(groups).when(ccService).getGroups();
+ setupJDBCMappingOnRegion("regionName");
+ doReturn(cacheConfig).when(ccService).getCacheConfig("Group1");
+
+ command.checkForJDBCMapping("regionName");
+ }
+
@Test
public void checkForJDBCMappingWithNoClusterConfigDoesNotThrowException() {
setupJDBCMappingOnRegion("regionName");
@@ -198,7 +210,7 @@ public class DestroyRegionCommandTest {
@Test
public void checkForJDBCMappingWithNoCacheConfigDoesNotThrowException() {
setupJDBCMappingOnRegion("regionName");
- doReturn(null).when(ccService).getCacheConfig(null);
+ doReturn(null).when(ccService).getCacheConfig("cluster");
command.checkForJDBCMapping("regionName");
}