Skip to content

Commit f8620b9

Browse files
GEODE-7699: use ConfigurationInfo to wrap the get result (apache#4596)
* GEODE-7699: use ConfigurationInfo to wrap the get result Co-authored-by: Dale Emery <[email protected]>
1 parent 049f039 commit f8620b9

File tree

28 files changed

+712
-117
lines changed

28 files changed

+712
-117
lines changed

geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/DeployToMultiGroupDUnitTest.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.apache.geode.management.internal.rest;
1717

1818
import static org.apache.geode.test.junit.assertions.ClusterManagementListResultAssert.assertManagementListResult;
19-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
19+
import static org.assertj.core.api.Assertions.assertThat;
2020

2121
import java.io.File;
2222

@@ -26,7 +26,7 @@
2626
import org.junit.Test;
2727
import org.junit.rules.TemporaryFolder;
2828

29-
import org.apache.geode.management.api.ClusterManagementException;
29+
import org.apache.geode.management.api.ClusterManagementGetResult;
3030
import org.apache.geode.management.api.ClusterManagementListResult;
3131
import org.apache.geode.management.api.ClusterManagementService;
3232
import org.apache.geode.management.client.ClusterManagementServiceBuilder;
@@ -118,7 +118,9 @@ public void listById() throws Exception {
118118
public void getById() throws Exception {
119119
Deployment filter = new Deployment();
120120
filter.setJarFileName("lib.jar");
121-
assertThatThrownBy(() -> client.get(filter)).isInstanceOf(ClusterManagementException.class)
122-
.hasMessageContaining("ERROR: Expect only one matching Deployment.");
121+
ClusterManagementGetResult<Deployment, DeploymentInfo> getResult =
122+
client.get(filter);
123+
assertThat(getResult.getResult().getConfigurations()).extracting(Deployment::getGroup)
124+
.containsExactlyInAnyOrder("group1", "group2");
123125
}
124126
}

geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ListIndexManagementDUnitTest.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void listRegion_succeeds_with_empty_filter() {
114114
@Test
115115
public void getRegion_succeeds_with_region_name_filter() {
116116
regionConfig.setName("region1");
117-
Region region = cms.get(regionConfig).getConfigResult();
117+
Region region = cms.get(regionConfig).getResult().getConfigurations().get(0);
118118
assertThat(region).isNotNull();
119119
}
120120

@@ -144,8 +144,8 @@ public void getIndex_succeeds_with_index_name_and_region_name_filter() {
144144
indexConfig.setRegionPath("/region1");
145145
indexConfig.setName("index1");
146146
ClusterManagementGetResult<Index, IndexInfo> clusterManagementGetResult = cms.get(indexConfig);
147-
Index indexConfig = clusterManagementGetResult.getConfigResult();
148-
List<IndexInfo> runtimeResult = clusterManagementGetResult.getRuntimeResult();
147+
Index indexConfig = clusterManagementGetResult.getResult().getConfigurations().get(0);
148+
List<IndexInfo> runtimeResult = clusterManagementGetResult.getResult().getRuntimeInfos();
149149

150150
assertSoftly(softly -> {
151151
softly.assertThat(indexConfig.getRegionName()).as("get index: region name")
@@ -155,7 +155,7 @@ public void getIndex_succeeds_with_index_name_and_region_name_filter() {
155155
.isEqualTo("/region1");
156156
softly.assertThat(indexConfig.getExpression()).as("get index: expression").isEqualTo("id");
157157
ConfigurationResult<Index, IndexInfo> configurationResult =
158-
cms.get(this.indexConfig).getResult();
158+
cms.get(this.indexConfig).getResult().getConfigurationByGroup().get(0);
159159
Index indexConfigTwo = configurationResult.getConfiguration();
160160
softly.assertThat(indexConfigTwo.getLinks().getLinks()).as("get index: links key")
161161
.containsKey("region");
@@ -256,8 +256,8 @@ public void createAndDeleteIndex_success_for_specific_group() {
256256
cms.create(index);
257257

258258
ClusterManagementGetResult<Index, IndexInfo> indexResult = cms.get(index);
259-
Index fetchedIndexConfig = indexResult.getConfigResult();
260-
List<IndexInfo> runtimeResult = indexResult.getRuntimeResult();
259+
Index fetchedIndexConfig = indexResult.getResult().getConfigurations().get(0);
260+
List<IndexInfo> runtimeResult = indexResult.getResult().getRuntimeInfos();
261261
assertSoftly(softly -> {
262262
softly.assertThat(fetchedIndexConfig.getRegionName()).as("index create: region name")
263263
.isEqualTo("region2");
@@ -301,8 +301,8 @@ public void createAndDeleteIndex_success_for_cluster() {
301301
cms.create(index);
302302

303303
ClusterManagementGetResult<Index, IndexInfo> indexResult = cms.get(index);
304-
Index fetchedIndexConfig = indexResult.getConfigResult();
305-
List<IndexInfo> runtimeResult = indexResult.getRuntimeResult();
304+
Index fetchedIndexConfig = indexResult.getResult().getConfigurations().get(0);
305+
List<IndexInfo> runtimeResult = indexResult.getResult().getRuntimeInfos();
306306
assertSoftly(softly -> {
307307
softly.assertThat(fetchedIndexConfig.getRegionName()).as("index create: region name")
308308
.isEqualTo("region2");

geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ListRegionManagementDunitTest.java

+60-31
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
import org.junit.ClassRule;
2828
import org.junit.Test;
2929

30+
import org.apache.geode.management.api.ClusterManagementGetResult;
3031
import org.apache.geode.management.api.ClusterManagementListResult;
32+
import org.apache.geode.management.api.ClusterManagementResult;
3133
import org.apache.geode.management.api.ClusterManagementService;
34+
import org.apache.geode.management.api.ConfigurationInfo;
3235
import org.apache.geode.management.client.ClusterManagementServiceBuilder;
3336
import org.apache.geode.management.configuration.AbstractConfiguration;
3437
import org.apache.geode.management.configuration.Region;
@@ -40,6 +43,10 @@
4043

4144
public class ListRegionManagementDunitTest {
4245

46+
public static final String REGION_WITH_MULTIPLE_TYPES = "region-with-multiple-types";
47+
public static final String REGION_IN_MULTIPLE_GROUPS = "region-in-multiple-groups";
48+
public static final String REGION_IN_CLUSTER = "region-in-cluster";
49+
public static final String REGION_IN_SINGLE_GROUP = "region-in-single-group";
4350
@ClassRule
4451
public static ClusterStartupRule cluster = new ClusterStartupRule();
4552

@@ -66,41 +73,41 @@ public static void beforeClass() throws Exception {
6673

6774
// create regions
6875
Region regionConfig = new Region();
69-
regionConfig.setName("customers1");
76+
regionConfig.setName(REGION_IN_SINGLE_GROUP);
7077
regionConfig.setGroup("group1");
7178
regionConfig.setType(RegionType.PARTITION);
7279
client.create(regionConfig);
73-
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/customers1", 1);
80+
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_IN_SINGLE_GROUP, 1);
7481

7582
// create a region that has different type on different group
7683
regionConfig = new Region();
77-
regionConfig.setName("customers2");
84+
regionConfig.setName(REGION_WITH_MULTIPLE_TYPES);
7885
regionConfig.setGroup("group1");
7986
regionConfig.setType(RegionType.PARTITION_PROXY);
8087
client.create(regionConfig);
8188

8289
regionConfig = new Region();
83-
regionConfig.setName("customers2");
90+
regionConfig.setName(REGION_WITH_MULTIPLE_TYPES);
8491
regionConfig.setGroup("group2");
8592
regionConfig.setType(RegionType.PARTITION);
8693
client.create(regionConfig);
87-
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/customers2", 2);
94+
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_WITH_MULTIPLE_TYPES, 2);
8895

8996
regionConfig = new Region();
90-
regionConfig.setName("customers");
97+
regionConfig.setName(REGION_IN_CLUSTER);
9198
regionConfig.setType(RegionType.PARTITION);
9299
client.create(regionConfig);
93-
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/customers", 2);
100+
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_IN_CLUSTER, 2);
94101

95102
// create a region that belongs to multiple groups
96103
regionConfig = new Region();
97-
regionConfig.setName("customers3");
104+
regionConfig.setName(REGION_IN_MULTIPLE_GROUPS);
98105
regionConfig.setGroup("group1");
99106
regionConfig.setType(RegionType.PARTITION);
100107
client.create(regionConfig);
101108
regionConfig.setGroup("group2");
102109
client.create(regionConfig);
103-
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/customers3", 2);
110+
locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REGION_IN_MULTIPLE_GROUPS, 2);
104111
}
105112

106113
@Before
@@ -113,55 +120,77 @@ public void listAll() {
113120
// list all
114121
List<Region> regions = client.list(filter).getConfigResult();
115122
assertThat(regions).hasSize(6);
116-
Region element = find(regions, "customers");
123+
Region element = find(regions, REGION_IN_CLUSTER);
117124
assertThat(element.getGroup()).isNull();
118125

119-
element = find(regions, "customers1");
126+
element = find(regions, REGION_IN_SINGLE_GROUP);
120127
assertThat(element.getGroup()).isEqualTo("group1");
121128

122-
assertThat(regions.stream().filter(x -> x.getId().equals("customers2")).map(Region::getGroup)
129+
assertThat(regions.stream().filter(x -> x.getId().equals(REGION_WITH_MULTIPLE_TYPES))
130+
.map(Region::getGroup)
123131
.collect(Collectors.toList())).containsExactlyInAnyOrder("group1", "group2");
124132

125-
assertThat(regions.stream().filter(x -> x.getId().equals("customers2")).map(Region::getType)
133+
assertThat(regions.stream().filter(x -> x.getId().equals(REGION_WITH_MULTIPLE_TYPES))
134+
.map(Region::getType)
126135
.collect(Collectors.toList())).containsExactlyInAnyOrder(RegionType.PARTITION,
127136
RegionType.PARTITION_PROXY);
128137

129-
assertThat(regions.stream().filter(x -> x.getId().equals("customers3")).map(Region::getGroup)
138+
assertThat(regions.stream().filter(x -> x.getId().equals(REGION_IN_MULTIPLE_GROUPS))
139+
.map(Region::getGroup)
130140
.collect(Collectors.toList())).containsExactlyInAnyOrder("group1", "group2");
131141
}
132142

143+
@Test
144+
public void getRegionInMultipleGroups() throws Exception {
145+
Region region = new Region();
146+
// customers2 belongs to multiple groups
147+
region.setName(REGION_WITH_MULTIPLE_TYPES);
148+
ClusterManagementGetResult<Region, RuntimeRegionInfo> result =
149+
client.get(region);
150+
assertThat(result.getStatusCode()).isEqualTo(ClusterManagementResult.StatusCode.OK);
151+
ConfigurationInfo<Region, RuntimeRegionInfo> configInfo = result.getResult();
152+
assertThat(configInfo.getId()).isEqualTo(REGION_WITH_MULTIPLE_TYPES);
153+
assertThat(configInfo.getConfigurations()).extracting(Region::getName)
154+
.containsExactlyInAnyOrder(
155+
REGION_WITH_MULTIPLE_TYPES, REGION_WITH_MULTIPLE_TYPES);
156+
assertThat(configInfo.getConfigurations()).extracting(Region::getType)
157+
.containsExactlyInAnyOrder(RegionType.PARTITION, RegionType.PARTITION_PROXY);
158+
assertThat(configInfo.getConfigurations()).extracting(Region::getGroup)
159+
.containsExactlyInAnyOrder("group1", "group2");
160+
}
161+
133162
@Test
134163
public void listClusterLevel() {
135164
// list cluster level only
136165
filter.setGroup("cluster");
137166
List<Region> regions = client.list(filter).getConfigResult();
138167
assertThat(regions).hasSize(1);
139-
assertThat(regions.get(0).getId()).isEqualTo("customers");
168+
assertThat(regions.get(0).getId()).isEqualTo(REGION_IN_CLUSTER);
140169
assertThat(regions.get(0).getGroup()).isNull();
141170
}
142171

143172
@Test
144173
public void testEntryCount() {
145174
server1.invoke(() -> {
146175
org.apache.geode.cache.Region<String, String> region =
147-
ClusterStartupRule.getCache().getRegion("/customers");
176+
ClusterStartupRule.getCache().getRegion("/" + REGION_IN_CLUSTER);
148177
region.put("k1", "v1");
149178
region.put("k2", "v2");
150179
});
151180

152181
// wait till entry size are correctly gathered by the mbean
153182
locator.invoke(() -> {
154183
await().untilAsserted(
155-
() -> assertThat(ClusterStartupRule.memberStarter.getRegionMBean("/customers")
184+
() -> assertThat(ClusterStartupRule.memberStarter.getRegionMBean("/" + REGION_IN_CLUSTER)
156185
.getSystemRegionEntryCount()).isEqualTo(2));
157186
});
158187

159-
filter.setName("customers");
188+
filter.setName(REGION_IN_CLUSTER);
160189
ClusterManagementListResult<Region, RuntimeRegionInfo> result = client.list(filter);
161190
List<Region> regions = result.getConfigResult();
162191
assertThat(regions).hasSize(1);
163192
Region regionConfig = regions.get(0);
164-
assertThat(regionConfig.getName()).isEqualTo("customers");
193+
assertThat(regionConfig.getName()).isEqualTo(REGION_IN_CLUSTER);
165194

166195
List<RuntimeRegionInfo> runtimeRegionInfos = result.getRuntimeResult();
167196
assertThat(runtimeRegionInfos).hasSize(1);
@@ -175,13 +204,13 @@ public void listGroup1() {
175204
List<Region> regions = client.list(filter).getConfigResult();
176205
assertThat(regions).hasSize(3);
177206
// when filtering by group, the returned list should not have group info
178-
Region region = find(regions, "customers1");
207+
Region region = find(regions, REGION_IN_SINGLE_GROUP);
179208
assertThat(region.getGroup()).isEqualTo("group1");
180209

181-
region = find(regions, "customers2");
210+
region = find(regions, REGION_WITH_MULTIPLE_TYPES);
182211
assertThat(region.getGroup()).isEqualTo("group1");
183212

184-
region = find(regions, "customers3");
213+
region = find(regions, REGION_IN_MULTIPLE_GROUPS);
185214
assertThat(region.getGroup()).isEqualTo("group1");
186215
}
187216

@@ -192,10 +221,10 @@ public void listGroup2() {
192221
List<Region> regions = client.list(filter).getConfigResult();
193222
assertThat(regions).hasSize(2);
194223

195-
Region region = find(regions, "customers2");
224+
Region region = find(regions, REGION_WITH_MULTIPLE_TYPES);
196225
assertThat(region.getGroup()).isEqualTo("group2");
197226

198-
region = find(regions, "customers3");
227+
region = find(regions, REGION_IN_MULTIPLE_GROUPS);
199228
assertThat(region.getGroup()).isEqualTo("group2");
200229
}
201230

@@ -209,25 +238,25 @@ public void listNonExistentGroup() {
209238

210239
@Test
211240
public void listRegionByName() {
212-
filter.setName("customers");
241+
filter.setName(REGION_IN_CLUSTER);
213242
List<Region> regions = client.list(filter).getConfigResult();
214243
assertThat(regions).hasSize(1);
215-
assertThat(regions.get(0).getId()).isEqualTo("customers");
244+
assertThat(regions.get(0).getId()).isEqualTo(REGION_IN_CLUSTER);
216245
assertThat(regions.get(0).getGroup()).isNull();
217246
}
218247

219248
@Test
220249
public void listRegionByName1() {
221-
filter.setName("customers1");
250+
filter.setName(REGION_IN_SINGLE_GROUP);
222251
List<Region> regions = client.list(filter).getConfigResult();
223252
assertThat(regions).hasSize(1);
224-
assertThat(regions.get(0).getId()).isEqualTo("customers1");
253+
assertThat(regions.get(0).getId()).isEqualTo(REGION_IN_SINGLE_GROUP);
225254
assertThat(regions.get(0).getGroup()).isEqualTo("group1");
226255
}
227256

228257
@Test
229258
public void listRegionByName2() {
230-
filter.setName("customers2");
259+
filter.setName(REGION_WITH_MULTIPLE_TYPES);
231260
List<Region> regions = client.list(filter).getConfigResult();
232261
assertThat(regions).hasSize(2);
233262
assertThat(
@@ -241,7 +270,7 @@ public void listRegionByName2() {
241270

242271
@Test
243272
public void listRegionByName3() {
244-
filter.setName("customers3");
273+
filter.setName(REGION_IN_MULTIPLE_GROUPS);
245274
List<Region> regions = client.list(filter).getConfigResult();
246275
assertThat(regions).hasSize(2);
247276
assertThat(regions).extracting(Region::getGroup).containsExactlyInAnyOrder("group1", "group2");
@@ -250,7 +279,7 @@ public void listRegionByName3() {
250279
@Test
251280
public void listNonExistentRegion() {
252281
// list non-existent region
253-
filter.setName("customer4");
282+
filter.setName("non-existent-region");
254283
List<Region> regions = client.list(filter).getConfigResult();
255284
assertThat(regions).hasSize(0);
256285
}

geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/MemberManagementServiceDunitTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public void getOneMember() {
9090
ClusterManagementGetResult<Member, MemberInformation> result = cmsClient.get(config);
9191
assertThat(result.isSuccessful()).isTrue();
9292
assertThat(result.getStatusCode()).isEqualTo(ClusterManagementResult.StatusCode.OK);
93-
assertThat(result.getRuntimeResult().size()).isEqualTo(1);
93+
assertThat(result.getResult().getRuntimeInfos().size()).isEqualTo(1);
9494

95-
MemberInformation memberConfig = result.getRuntimeResult().get(0);
95+
MemberInformation memberConfig = result.getResult().getRuntimeInfos().get(0);
9696
assertThat(memberConfig.isCoordinator()).isTrue();
9797
assertThat(memberConfig.isServer()).isFalse();
9898
assertThat(memberConfig.getLocatorPort()).isEqualTo(locator.getPort());

geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/RegionManagementDunitTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void createRegionWithKeyValueConstraint() throws Exception {
103103
config.setValueConstraint("java.lang.Integer");
104104
cms.create(config);
105105

106-
Region config1 = cms.get(config).getConfigResult();
106+
Region config1 = cms.get(config).getResult().getConfigurations().get(0);
107107

108108
assertThat(config1.getType()).isEqualTo(RegionType.PARTITION);
109109
assertThat(config1.getValueConstraint()).isEqualTo("java.lang.Integer");
@@ -271,7 +271,7 @@ public void createRegionWithExpiration() throws Exception {
271271
assertThat(attributes.getCustomEntryTimeToLive()).isNull();
272272
});
273273

274-
Region regionResult = cms.get(region).getConfigResult();
274+
Region regionResult = cms.get(region).getResult().getConfigurations().get(0);
275275
List<Region.Expiration> expirations = regionResult.getExpirations();
276276
assertThat(expirations).hasSize(2);
277277
assertThat(expirations.get(0).getTimeInSeconds()).isEqualTo(10000);
@@ -322,7 +322,7 @@ public void createRegionWithEviction() {
322322

323323
});
324324

325-
Region regionResult = cms.get(region).getConfigResult();
325+
Region regionResult = cms.get(region).getResult().getConfigurations().get(0);
326326
Region.Eviction eviction2 = regionResult.getEviction();
327327
assertThat(eviction2).isNotNull();
328328
assertThat(eviction2.getType()).isEqualTo(Region.EvictionType.ENTRY_COUNT);

geode-assembly/src/integrationTest/resources/assembly_content.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ javadoc/org/apache/geode/management/api/ClusterManagementRealizationResult.html
702702
javadoc/org/apache/geode/management/api/ClusterManagementResult.StatusCode.html
703703
javadoc/org/apache/geode/management/api/ClusterManagementResult.html
704704
javadoc/org/apache/geode/management/api/ClusterManagementService.html
705+
javadoc/org/apache/geode/management/api/ConfigurationInfo.html
705706
javadoc/org/apache/geode/management/api/ConfigurationResult.html
706707
javadoc/org/apache/geode/management/api/JsonSerializable.html
707708
javadoc/org/apache/geode/management/api/RealizationResult.html
@@ -967,7 +968,6 @@ lib/commons-digester-2.1.jar
967968
lib/commons-io-2.6.jar
968969
lib/commons-lang3-3.9.jar
969970
lib/commons-logging-1.2.jar
970-
lib/geode-membership-0.0.0.jar
971971
lib/commons-math3-3.2.jar
972972
lib/commons-modeler-2.0.1.jar
973973
lib/commons-validator-1.6.jar
@@ -986,6 +986,7 @@ lib/geode-log4j-0.0.0.jar
986986
lib/geode-logging-0.0.0.jar
987987
lib/geode-lucene-0.0.0.jar
988988
lib/geode-management-0.0.0.jar
989+
lib/geode-membership-0.0.0.jar
989990
lib/geode-memcached-0.0.0.jar
990991
lib/geode-old-client-support-0.0.0.jar
991992
lib/geode-protobuf-0.0.0.jar

0 commit comments

Comments
 (0)