Skip to content

Commit

Permalink
GEODE-7864: Replace uses of hardcoded "/" with Region.SEPARATOR (apac…
Browse files Browse the repository at this point in the history
…he#5049)

* GEODE-7864: Replace uses of hardcoded "/" with Region.SEPARATOR

Authored-by: Donal Evans <[email protected]>
  • Loading branch information
DonalEvans authored May 9, 2020
1 parent 15cb323 commit 8f0650e
Show file tree
Hide file tree
Showing 149 changed files with 851 additions and 619 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package org.apache.geode.modules.session.catalina;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.any;
Expand Down Expand Up @@ -272,7 +273,7 @@ public void touchSessionsInvokesRRFunctionForRRAndDoesNotThrowExceptionWhenFunct

Set<String> sessionIds = new HashSet<>();

when(sessionRegion.getFullPath()).thenReturn("/" + sessionRegionName);
when(sessionRegion.getFullPath()).thenReturn(SEPARATOR + sessionRegionName);
when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());

sessionCache.touchSessions(sessionIds);
Expand All @@ -289,7 +290,7 @@ public void touchSessionsInvokesRRFunctionForRRAndThrowsExceptionWhenFunctionThr
FunctionException exception = new FunctionException();
ResultCollector exceptionCollector = mock(ResultCollector.class);

when(sessionRegion.getFullPath()).thenReturn("/" + sessionRegionName);
when(sessionRegion.getFullPath()).thenReturn(SEPARATOR + sessionRegionName);
when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.REPLICATE.toString());
when(emptyExecution.execute(TouchReplicatedRegionEntriesFunction.ID))
.thenReturn(exceptionCollector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.apache.geode.modules.session.catalina;

import static org.apache.geode.cache.Region.SEPARATOR;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
Expand Down Expand Up @@ -682,10 +684,10 @@ private void doUnload() throws IOException {
}

String regionName;
if (getRegionName().startsWith("/")) {
if (getRegionName().startsWith(SEPARATOR)) {
regionName = getRegionName();
} else {
regionName = "/" + getRegionName();
regionName = SEPARATOR + getRegionName();
}

Query query = querySvc.newQuery("select s.id from " + regionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package org.apache.geode.management.internal.rest;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.lang.Identifiable.find;
import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static void beforeClass() throws Exception {
regionConfig.setGroup("group1");
regionConfig.setType(RegionType.PARTITION);
client.create(regionConfig);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_IN_SINGLE_GROUP, 1);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + REGION_IN_SINGLE_GROUP, 1);

// create a region that has different type on different group
regionConfig = new Region();
Expand All @@ -89,13 +90,14 @@ public static void beforeClass() throws Exception {
regionConfig.setGroup("group2");
regionConfig.setType(RegionType.PARTITION);
client.create(regionConfig);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_WITH_MULTIPLE_TYPES, 2);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + REGION_WITH_MULTIPLE_TYPES,
2);

regionConfig = new Region();
regionConfig.setName(REGION_IN_CLUSTER);
regionConfig.setType(RegionType.PARTITION);
client.create(regionConfig);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_IN_CLUSTER, 2);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + REGION_IN_CLUSTER, 2);

// create a region that belongs to multiple groups
regionConfig = new Region();
Expand All @@ -105,7 +107,8 @@ public static void beforeClass() throws Exception {
client.create(regionConfig);
regionConfig.setGroup("group2");
client.create(regionConfig);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_IN_MULTIPLE_GROUPS, 2);
locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + REGION_IN_MULTIPLE_GROUPS,
2);
}

@Before
Expand Down Expand Up @@ -171,16 +174,17 @@ public void listClusterLevel() {
public void testEntryCount() {
server1.invoke(() -> {
org.apache.geode.cache.Region<String, String> region =
ClusterStartupRule.getCache().getRegion("/" + REGION_IN_CLUSTER);
ClusterStartupRule.getCache().getRegion(SEPARATOR + REGION_IN_CLUSTER);
region.put("k1", "v1");
region.put("k2", "v2");
});

// wait till entry size are correctly gathered by the mbean
locator.invoke(() -> {
await().untilAsserted(
() -> assertThat(ClusterStartupRule.memberStarter.getRegionMBean("/" + REGION_IN_CLUSTER)
.getSystemRegionEntryCount()).isEqualTo(2));
() -> assertThat(
ClusterStartupRule.memberStarter.getRegionMBean(SEPARATOR + REGION_IN_CLUSTER)
.getSystemRegionEntryCount()).isEqualTo(2));
});

filter.setName(REGION_IN_CLUSTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.apache.geode.connectors.jdbc.internal.cli;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.connectors.jdbc.internal.cli.CreateMappingCommand.CREATE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.DescribeMappingCommand.DESCRIBE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.MappingConstants.DATA_SOURCE_NAME;
Expand Down Expand Up @@ -248,7 +249,7 @@ private static CacheConfig.AsyncEventQueue findQueue(List<CacheConfig.AsyncEvent
}

private static String convertRegionPathToName(String regionPath) {
if (regionPath.startsWith("/")) {
if (regionPath.startsWith(SEPARATOR)) {
return regionPath.substring(1);
}
return regionPath;
Expand Down Expand Up @@ -401,7 +402,7 @@ public void createMappingPartitionedUpdatesServiceAndClusterConfigForServerGroup

@Test
public void createMappingReplicatedUpdatesServiceAndClusterConfigForMultiServerGroup() {
String regionName = "/" + GROUP1_GROUP2_REGION;
String regionName = SEPARATOR + GROUP1_GROUP2_REGION;
setupGroupReplicate(regionName, TEST_GROUP1 + "," + TEST_GROUP2);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand Down Expand Up @@ -437,7 +438,7 @@ public void createMappingReplicatedUpdatesServiceAndClusterConfigForMultiServerG

@Test
public void createMappingPartitionedUpdatesServiceAndClusterConfigForMultiServerGroup() {
String regionName = "/" + GROUP1_GROUP2_REGION;
String regionName = SEPARATOR + GROUP1_GROUP2_REGION;
setupGroupPartition(regionName, TEST_GROUP1 + "," + TEST_GROUP2);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand Down Expand Up @@ -759,7 +760,7 @@ private static void assertValidEmployeeMapping(RegionMapping mapping, String tab

@Test
public void createMappingUpdatesServiceAndClusterConfig() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand All @@ -786,7 +787,7 @@ public void createMappingUpdatesServiceAndClusterConfig() {

@Test
public void createMappingWithDomainClassUpdatesServiceAndClusterConfig() {
String regionName = "/" + EMPLOYEE_REGION;
String regionName = SEPARATOR + EMPLOYEE_REGION;
setupReplicate(regionName);
server1.invoke(() -> {
ClusterStartupRule.getCache().registerPdxMetaData(new Employee());
Expand Down Expand Up @@ -952,7 +953,7 @@ public void createMappingUsingRegionNameUsesDomainClass() {

@Test
public void createSynchronousMappingUpdatesServiceAndClusterConfig() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand Down Expand Up @@ -980,7 +981,7 @@ public void createSynchronousMappingUpdatesServiceAndClusterConfig() {

@Test
public void createMappingWithPartitionUpdatesServiceAndClusterConfig() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupPartition(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand Down Expand Up @@ -1015,7 +1016,7 @@ public void createMappingWithPartitionUpdatesServiceAndClusterConfig() {

@Test
public void createMappingWithNoTable() {
String regionName = "/" + "myTable";
String regionName = SEPARATOR + "myTable";
setupReplicate(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand Down Expand Up @@ -1048,7 +1049,7 @@ public void createMappingWithNoTable() {

@Test
public void createExistingRegionMappingFails() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand Down Expand Up @@ -1086,7 +1087,7 @@ public void createExistingRegionMappingFails() {

@Test
public void createMappingWithoutPdxNameFails() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand All @@ -1100,7 +1101,7 @@ public void createMappingWithoutPdxNameFails() {

@Test
public void createMappingWithNonExistentRegionFails() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, "bogusRegion");
Expand All @@ -1113,7 +1114,7 @@ public void createMappingWithNonExistentRegionFails() {

@Test
public void createMappingWithRegionThatHasALoaderFails() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName, true);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
csb.addOption(REGION_NAME, regionName);
Expand All @@ -1127,7 +1128,7 @@ public void createMappingWithRegionThatHasALoaderFails() {

@Test
public void createMappingWithExistingQueueFails() {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
setupReplicate(regionName);
setupAsyncEventQueue(regionName);
CommandStringBuilder csb = new CommandStringBuilder(CREATE_MAPPING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.apache.geode.connectors.jdbc.internal.cli;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.connectors.jdbc.internal.cli.CreateMappingCommand.CREATE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.DescribeMappingCommand.DESCRIBE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.DestroyMappingCommand.DESTROY_MAPPING;
Expand Down Expand Up @@ -203,7 +204,7 @@ private static CacheConfig.AsyncEventQueue findQueue(
}

private static String convertRegionPathToName(String regionPath) {
if (regionPath.startsWith("/")) {
if (regionPath.startsWith(SEPARATOR)) {
return regionPath.substring(1);
}
return regionPath;
Expand Down Expand Up @@ -253,7 +254,7 @@ private static void validateRegionAlteredOnServer(String regionName, boolean syn
@Test
@Parameters(method = "parametersToTestPRDR")
public void createMappingTogetherForMultiServerGroupWithEmptyRegion(boolean isPR) {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
if (isPR) {
setupGroupPartition(regionName, TEST_GROUP1, false);
setupGroupPartition(regionName, TEST_GROUP2, true);
Expand Down Expand Up @@ -322,7 +323,7 @@ public void createMappingTogetherForMultiServerGroupWithEmptyRegion(boolean isPR
@Test
@Parameters(method = "parametersToTestPRDR")
public void createMappingSeparatelyForMultiServerGroupWithEmptyRegion(boolean isPR) {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
if (isPR) {
setupGroupPartition(regionName, TEST_GROUP1, false);
setupGroupPartition(regionName, TEST_GROUP2, true);
Expand Down Expand Up @@ -419,7 +420,7 @@ public void createMappingSeparatelyForMultiServerGroupWithEmptyRegion(boolean is
@Test
@Parameters(method = "parametersToTestPRDR")
public void createEmptyRegionAfterCreateMapping(boolean isPR) {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
if (isPR) {
setupGroupPartition(regionName, TEST_GROUP1, false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.apache.geode.connectors.jdbc.internal.cli;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.connectors.jdbc.internal.cli.CreateMappingCommand.CREATE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.DescribeMappingCommand.DESCRIBE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.MappingConstants.DATA_SOURCE_NAME;
Expand Down Expand Up @@ -68,7 +69,7 @@ public class DescribeMappingCommandDUnitTest implements Serializable {
private MemberVM server2;

private static String convertRegionPathToName(String regionPath) {
if (regionPath.startsWith("/")) {
if (regionPath.startsWith(SEPARATOR)) {
return regionPath.substring(1);
}
return regionPath;
Expand Down Expand Up @@ -185,7 +186,7 @@ public void fromData(PdxReader reader) {
@SuppressWarnings("deprecation")
@Test
public void describesExistingSynchronousMapping() throws Exception {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
locator = startupRule.startLocatorVM(0);
server = startupRule.startServerVM(1, locator.getPort());

Expand Down Expand Up @@ -266,7 +267,7 @@ public void describesExistingSynchronousMappingWithGroups() throws Exception {
@SuppressWarnings("deprecation")
@Test
public void describesExistingAsyncMapping() throws Exception {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
locator = startupRule.startLocatorVM(0);
server = startupRule.startServerVM(1, locator.getPort());

Expand Down Expand Up @@ -353,7 +354,7 @@ public void describesExistingAsyncMappingWithGroup() throws Exception {
@Test
public void describesExistingAsyncMappingsWithSameRegionOnDifferentGroups()
throws Exception {
String regionName = "/" + TEST_REGION;
String regionName = SEPARATOR + TEST_REGION;
String groupName1 = "group1";
String groupName2 = "group2";
locator = startupRule.startLocatorVM(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.apache.geode.connectors.jdbc.internal.cli;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.connectors.jdbc.internal.cli.CreateMappingCommand.CREATE_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.DestroyMappingCommand.DESTROY_MAPPING;
import static org.apache.geode.connectors.jdbc.internal.cli.MappingConstants.DATA_SOURCE_NAME;
Expand Down Expand Up @@ -257,7 +258,7 @@ public void destroysAsyncMapping() {
public void destroysAsyncMappingWithRegionPath() {
setupAsyncMapping();
CommandStringBuilder csb = new CommandStringBuilder(DESTROY_MAPPING);
csb.addOption(REGION_NAME, "/" + TEST_REGION);
csb.addOption(REGION_NAME, SEPARATOR + TEST_REGION);

gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();

Expand Down Expand Up @@ -376,7 +377,7 @@ public void destroysMappingForMultiServerGroup() throws Exception {
public void destroysSynchronousMappingWithRegionPath() throws Exception {
setupSynchronousMapping();
CommandStringBuilder csb = new CommandStringBuilder(DESTROY_MAPPING);
csb.addOption(REGION_NAME, "/" + TEST_REGION);
csb.addOption(REGION_NAME, SEPARATOR + TEST_REGION);

gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package org.apache.geode.connectors.jdbc.internal.cli;


import static org.apache.geode.cache.Region.SEPARATOR;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -131,7 +133,7 @@ public ResultModel createMapping(
optionContext = ConverterHint.MEMBERGROUP,
help = CREATE_MAPPING__GROUPS_NAME__HELP) String[] groups)
throws IOException {
if (regionName.startsWith("/")) {
if (regionName.startsWith(SEPARATOR)) {
regionName = regionName.substring(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.apache.geode.connectors.jdbc.internal.cli;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.connectors.jdbc.internal.cli.MappingConstants.CATALOG_NAME;
import static org.apache.geode.connectors.jdbc.internal.cli.MappingConstants.DATA_SOURCE_NAME;
import static org.apache.geode.connectors.jdbc.internal.cli.MappingConstants.ID_NAME;
Expand Down Expand Up @@ -71,7 +72,7 @@ public ResultModel describeMapping(@CliOption(key = DESCRIBE_MAPPING__REGION_NAM
@CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
optionContext = ConverterHint.MEMBERGROUP,
help = DESCRIBE_MAPPING__GROUPS_NAME__HELP) String[] groups) {
if (regionName.startsWith("/")) {
if (regionName.startsWith(SEPARATOR)) {
regionName = regionName.substring(1);
}

Expand Down
Loading

0 comments on commit 8f0650e

Please sign in to comment.