From bda6bdf50c0a6a3e7cc39fb3ff654a0c26c86d94 Mon Sep 17 00:00:00 2001 From: Jinmei Liao Date: Fri, 7 Feb 2020 08:26:15 -0800 Subject: [PATCH] GEODE-7717: ClusterManagementListResult should show a list of EntityInfo (#4673) * only show links in the EntityInfo level * rework list member responses --- .../rest/ListIndexManagementDUnitTest.java | 2 +- .../api/LocatorClusterManagementService.java | 28 ++++-- .../api/ClusterManagementResultTest.java | 4 +- .../LocatorClusterManagementServiceTest.java | 19 ++-- .../ClusterManagementGetResultAssert.java | 6 +- .../ClusterManagementListResultAssert.java | 2 +- .../api/ClusterManagementListResult.java | 68 +++++++++----- .../geode/management/api/EntityGroupInfo.java | 7 +- .../geode/management/api/EntityInfo.java | 33 ++++--- .../api/ClusterManagementListResultTest.java | 90 +++++++++++++++++++ .../management/api/EntityGroupInfoTest.java | 2 +- .../geode/management/api/EntityInfoTest.java | 8 +- .../MemberManagementServiceDUnitTest.java | 3 +- .../GatewayManagementIntegrationTest.java | 4 +- .../internal/rest/HateoasIntegrationTest.java | 4 +- ...rManagementServiceRestIntegrationTest.java | 64 +++++++------ .../MemberManagementController.java | 4 +- .../RegionManagementController.java | 10 +-- 18 files changed, 253 insertions(+), 105 deletions(-) create mode 100644 geode-management/src/test/java/org/apache/geode/management/api/ClusterManagementListResultTest.java diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ListIndexManagementDUnitTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ListIndexManagementDUnitTest.java index c99b29a5650d..96d5aceb8aac 100644 --- a/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ListIndexManagementDUnitTest.java +++ b/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ListIndexManagementDUnitTest.java @@ -154,7 +154,7 @@ public void getIndex_succeeds_with_index_name_and_region_name_filter() { .isEqualTo("/region1"); softly.assertThat(indexConfig.getExpression()).as("get index: expression").isEqualTo("id"); EntityGroupInfo entityGroupInfo = - cms.get(this.indexConfig).getResult().getConfigurationByGroup().get(0); + cms.get(this.indexConfig).getResult().getGroups().get(0); Index indexConfigTwo = entityGroupInfo.getConfiguration(); softly.assertThat(indexConfigTwo.getLinks().getLinks()).as("get index: links key") .containsKey("region"); diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/api/LocatorClusterManagementService.java b/geode-core/src/main/java/org/apache/geode/management/internal/api/LocatorClusterManagementService.java index 525feb803ec6..2ccb39e9af0c 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/api/LocatorClusterManagementService.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/api/LocatorClusterManagementService.java @@ -367,7 +367,21 @@ public , R extends RuntimeInfo> ClusterManage response.setRuntimeInfo(runtimeInfos); } - result.setResult(responses); + if (filter instanceof Member) { + // for members, we have exactly one response that holds the filter + // and all the members in the runtimeInfo section + List members = responses.get(0).getRuntimeInfo(); + for (R memberInfo : members) { + Member member = new Member(); + member.setId(memberInfo.getMemberName()); + EntityInfo entityInfo = new EntityInfo<>(memberInfo.getMemberName(), + Collections.singletonList( + new EntityGroupInfo<>((T) member, Collections.singletonList(memberInfo)))); + result.addEntityInfo(entityInfo); + } + } else { + result.setEntityGroupInfo(responses); + } return assertSuccessful(result); } @@ -375,18 +389,14 @@ public , R extends RuntimeInfo> ClusterManage public , R extends RuntimeInfo> ClusterManagementGetResult get( T config) { ClusterManagementListResult list = list(config); - List> result = list.getResult(); - int size = result.size(); - if (config instanceof Member) { - size = result.get(0).getRuntimeInfo().size(); - } - if (size == 0) { + List> result = list.getResult(); + if (result.size() == 0) { raise(StatusCode.ENTITY_NOT_FOUND, config.getClass().getSimpleName() + " '" + config.getId() + "' does not exist."); } - EntityInfo entityInfo = new EntityInfo<>(config.getId(), result); - return new ClusterManagementGetResult<>(entityInfo); + + return new ClusterManagementGetResult<>(result.get(0)); } @Override diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java index 988141ed63e5..eeb87929f4fc 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java @@ -134,7 +134,7 @@ public void deserialize() throws Exception { String json = "{\"statusCode\":\"OK\"}"; ClusterManagementListResult result = GeodeJsonMapper.getMapper().readValue(json, ClusterManagementListResult.class); - assertThat(result.getResult()).isNotNull().isEmpty(); + assertThat(result.getEntityGroupInfo()).isNotNull().isEmpty(); } @Test @@ -152,7 +152,7 @@ public void serializeResult() throws Exception { RuntimeRegionInfo info = new RuntimeRegionInfo(); info.setEntryCount(3); response.setRuntimeInfo(Collections.singletonList(info)); - result.setResult(Collections.singletonList(response)); + result.setEntityGroupInfo(Collections.singletonList(response)); String json = mapper.writeValueAsString(result); System.out.println(json); diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/api/LocatorClusterManagementServiceTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/api/LocatorClusterManagementServiceTest.java index f6e783d37536..31613b655e05 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/api/LocatorClusterManagementServiceTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/api/LocatorClusterManagementServiceTest.java @@ -15,6 +15,7 @@ package org.apache.geode.management.internal.api; +import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; @@ -63,6 +64,7 @@ import org.apache.geode.management.api.ClusterManagementRealizationResult; import org.apache.geode.management.api.ClusterManagementResult; import org.apache.geode.management.api.EntityGroupInfo; +import org.apache.geode.management.api.EntityInfo; import org.apache.geode.management.api.RealizationResult; import org.apache.geode.management.configuration.Index; import org.apache.geode.management.configuration.Member; @@ -409,7 +411,7 @@ public void get_whenResponseHasNoConfigurationResults() throws Exception { Region filter = new Region(); ClusterManagementListResult result = mock(ClusterManagementListResult.class); - when(result.getResult()).thenReturn(emptyList()); + when(result.getEntityGroupInfo()).thenReturn(emptyList()); doReturn(result).when(service).list(same(filter)); @@ -424,17 +426,18 @@ public void get_whenResponseHasConfigurationResults() throws Exception { ClusterManagementListResult listResult = mock(ClusterManagementListResult.class); - List> entityGroupInfos = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - entityGroupInfos.add(mock(EntityGroupInfo.class)); - } - when(listResult.getResult()).thenReturn(entityGroupInfos); + List> entityGroupInfos = + asList(mock(EntityGroupInfo.class)); + List> entityInfos = + asList(new EntityInfo<>("id", entityGroupInfos)); + + when(listResult.getResult()).thenReturn(entityInfos); doReturn(listResult).when(service).list(same(filter)); ClusterManagementGetResult getResult = service.get(filter); - assertThat(getResult.getResult().getConfigurationByGroup()).isSameAs(entityGroupInfos); + assertThat(getResult.getResult().getGroups()).isSameAs(entityGroupInfos); } @Test @@ -447,7 +450,7 @@ public void getMember_whenNoMembers() { mock(EntityGroupInfo.class); when(entityGroupInfo.getRuntimeInfo()).thenReturn(emptyList()); entityGroupInfos.add(entityGroupInfo); - when(listResult.getResult()).thenReturn(entityGroupInfos); + when(listResult.getEntityGroupInfo()).thenReturn(entityGroupInfos); assertThatThrownBy(() -> service.get(member)) .isInstanceOf(ClusterManagementException.class) diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementGetResultAssert.java b/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementGetResultAssert.java index 3526ff9f6670..4d9c94d5145b 100644 --- a/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementGetResultAssert.java +++ b/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementGetResultAssert.java @@ -57,15 +57,15 @@ public ClusterManagementGetResultAssert containsStatusMessage(String statu } public EntityGroupInfo getResult() { - return actual.getResult().getConfigurationByGroup().get(0); + return actual.getResult().getGroups().get(0); }; public ObjectAssert hasConfiguration() { - return assertThat(getActual().getResult().getConfigurationByGroup().get(0).getConfiguration()); + return assertThat(getActual().getResult().getGroups().get(0).getConfiguration()); } public ListAssert hasRuntimeInfos() { - return assertThat(getActual().getResult().getConfigurationByGroup().get(0).getRuntimeInfo()); + return assertThat(getActual().getResult().getGroups().get(0).getRuntimeInfo()); } public static , R extends RuntimeInfo> ClusterManagementGetResultAssert assertManagementGetResult( diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementListResultAssert.java b/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementListResultAssert.java index d23e2334aaef..3152e531496c 100644 --- a/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementListResultAssert.java +++ b/geode-junit/src/main/java/org/apache/geode/test/junit/assertions/ClusterManagementListResultAssert.java @@ -58,7 +58,7 @@ public ClusterManagementListResultAssert containsStatusMessage(String stat } public List> getResult() { - return actual.getResult(); + return actual.getEntityGroupInfo(); }; public ListAssert hasConfigurations() { diff --git a/geode-management/src/main/java/org/apache/geode/management/api/ClusterManagementListResult.java b/geode-management/src/main/java/org/apache/geode/management/api/ClusterManagementListResult.java index 4f998d3a2819..1a21e2bad250 100644 --- a/geode-management/src/main/java/org/apache/geode/management/api/ClusterManagementListResult.java +++ b/geode-management/src/main/java/org/apache/geode/management/api/ClusterManagementListResult.java @@ -14,13 +14,13 @@ */ package org.apache.geode.management.api; -import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.geode.annotations.Experimental; import org.apache.geode.management.configuration.AbstractConfiguration; @@ -34,28 +34,55 @@ @Experimental public class ClusterManagementListResult, R extends RuntimeInfo> extends ClusterManagementResult { - /** - * for internal use only - */ + public ClusterManagementListResult() {} - /** - * for internal use only - */ public ClusterManagementListResult(StatusCode statusCode, String message) { super(statusCode, message); } - // Override the mapper setting so that we always show result - @JsonInclude - @JsonProperty - private List> result = new ArrayList<>(); + private final Map> entities = new HashMap<>(); /** * Returns the combined payload of the list call */ - public List> getResult() { - return result; + @JsonIgnore + public List> getEntityGroupInfo() { + return entities.values().stream() + .flatMap(x -> x.getGroups().stream()) + .collect(Collectors.toList()); + } + + // this annotation makes sure we always show the result even though it's an empty list + @JsonInclude + public List> getResult() { + return entities.values().stream().collect(Collectors.toList()); + } + + public void setResult(List> entities) { + this.entities.clear(); + for (EntityInfo entity : entities) { + this.entities.put(entity.getId(), entity); + } + } + + public void addEntityInfo(EntityInfo entityInfo) { + this.entities.put(entityInfo.getId(), entityInfo); + } + + @JsonIgnore + public void setEntityGroupInfo(List> entityGroupInfos) { + this.entities.clear(); + for (EntityGroupInfo entityGroupInfo : entityGroupInfos) { + String id = entityGroupInfo.getConfiguration().getId(); + EntityInfo entity = this.entities.get(id); + if (entity == null) { + entity = new EntityInfo<>(); + entity.setId(id); + this.entities.put(id, entity); + } + entity.getGroups().add(entityGroupInfo); + } } /** @@ -63,7 +90,8 @@ public List> getResult() { */ @JsonIgnore public List getConfigResult() { - return result.stream().map(EntityGroupInfo::getConfiguration).collect(Collectors.toList()); + return getEntityGroupInfo().stream().map(EntityGroupInfo::getConfiguration) + .collect(Collectors.toList()); } /** @@ -71,13 +99,7 @@ public List getConfigResult() { */ @JsonIgnore public List getRuntimeResult() { - return result.stream().flatMap(r -> r.getRuntimeInfo().stream()).collect(Collectors.toList()); - } - - /** - * for internal use only - */ - public void setResult(List> result) { - this.result = result; + return getEntityGroupInfo().stream().flatMap(r -> r.getRuntimeInfo().stream()) + .collect(Collectors.toList()); } } diff --git a/geode-management/src/main/java/org/apache/geode/management/api/EntityGroupInfo.java b/geode-management/src/main/java/org/apache/geode/management/api/EntityGroupInfo.java index 2875dd58374d..36e0c0cac9cc 100644 --- a/geode-management/src/main/java/org/apache/geode/management/api/EntityGroupInfo.java +++ b/geode-management/src/main/java/org/apache/geode/management/api/EntityGroupInfo.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.geode.annotations.Experimental; import org.apache.geode.management.configuration.AbstractConfiguration; @@ -87,8 +87,11 @@ public void setRuntimeInfo(List runtimeInfo) { this.runtimeInfo = runtimeInfo; } - @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @JsonIgnore public Links getLinks() { + if (configuration == null) { + return null; + } return configuration.getLinks(); } diff --git a/geode-management/src/main/java/org/apache/geode/management/api/EntityInfo.java b/geode-management/src/main/java/org/apache/geode/management/api/EntityInfo.java index 40963abdfae3..4ebc3573ca48 100644 --- a/geode-management/src/main/java/org/apache/geode/management/api/EntityInfo.java +++ b/geode-management/src/main/java/org/apache/geode/management/api/EntityInfo.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.geode.management.configuration.AbstractConfiguration; +import org.apache.geode.management.configuration.Links; import org.apache.geode.management.runtime.RuntimeInfo; /** @@ -39,13 +40,13 @@ public class EntityInfo, R extends RuntimeInf private String id; @JsonInclude @JsonProperty - private List> configurationByGroup = new ArrayList<>(); + private List> groups = new ArrayList<>(); public EntityInfo() {} - public EntityInfo(String id, List> configurationByGroup) { + public EntityInfo(String id, List> groups) { this.id = id; - this.configurationByGroup = configurationByGroup; + this.groups = groups; } public String getId() { @@ -56,28 +57,36 @@ public void setId(String id) { this.id = id; } - public List> getConfigurationByGroup() { - return configurationByGroup; + public List> getGroups() { + return groups; } - public void setConfigurationByGroup(List> configurationByGroup) { - this.configurationByGroup = configurationByGroup; + public void setGroups(List> groups) { + this.groups = groups; } @JsonIgnore public List getConfigurations() { - return configurationByGroup.stream() + return groups.stream() .map(EntityGroupInfo::getConfiguration) .collect(toList()); } @JsonIgnore public List getRuntimeInfos() { - return configurationByGroup.stream() + return groups.stream() .flatMap(r -> r.getRuntimeInfo().stream()) .collect(toList()); } + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + public Links getLinks() { + if (groups.isEmpty()) { + return null; + } + return groups.get(0).getLinks(); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -88,19 +97,19 @@ public boolean equals(Object o) { } EntityInfo that = (EntityInfo) o; return Objects.equals(id, that.id) && - Objects.equals(configurationByGroup, that.configurationByGroup); + Objects.equals(groups, that.groups); } @Override public int hashCode() { - return Objects.hash(id, configurationByGroup); + return Objects.hash(id, groups); } @Override public String toString() { return "ConfigurationInfo{" + "id='" + id + '\'' + - ", configurationByGroup=" + configurationByGroup + + ", configurationByGroup=" + groups + '}'; } } diff --git a/geode-management/src/test/java/org/apache/geode/management/api/ClusterManagementListResultTest.java b/geode-management/src/test/java/org/apache/geode/management/api/ClusterManagementListResultTest.java new file mode 100644 index 000000000000..4961ac62be18 --- /dev/null +++ b/geode-management/src/test/java/org/apache/geode/management/api/ClusterManagementListResultTest.java @@ -0,0 +1,90 @@ +/* + * 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.geode.management.api; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Before; +import org.junit.Test; + +import org.apache.geode.management.configuration.Region; +import org.apache.geode.management.configuration.RegionType; +import org.apache.geode.management.runtime.RuntimeRegionInfo; +import org.apache.geode.util.internal.GeodeJsonMapper; + +public class ClusterManagementListResultTest { + + private ClusterManagementListResult list; + private ObjectMapper mapper = GeodeJsonMapper.getMapper(); + + @Before + public void before() throws Exception { + list = new ClusterManagementListResult<>(); + } + + @Test + public void serialization() throws Exception { + List> groupInfos = new ArrayList<>(); + EntityGroupInfo group1 = new EntityGroupInfo<>(); + Region group1Region = new Region(); + group1Region.setName("regionA"); + group1Region.setGroup("group1"); + group1Region.setType(RegionType.REPLICATE); + group1.setConfiguration(group1Region); + + EntityGroupInfo group2 = new EntityGroupInfo<>(); + Region group2Region = new Region(); + group2Region.setName("regionA"); + group2Region.setGroup("group2"); + group2Region.setType(RegionType.REPLICATE); + group2.setConfiguration(group2Region); + + EntityGroupInfo group3 = new EntityGroupInfo<>(); + Region group3Region = new Region(); + group3Region.setName("regionB"); + group3Region.setGroup("group3"); + group3Region.setType(RegionType.REPLICATE); + group3.setConfiguration(group3Region); + + groupInfos.add(group1); + groupInfos.add(group2); + groupInfos.add(group3); + + list.setEntityGroupInfo(groupInfos); + + // make sure it has 3 region definition by groups + assertThat(list.getEntityGroupInfo()).hasSize(3); + // make sure it only has 2 regions defined (one region exists in 2 groups) + assertThat(list.getResult()).hasSize(2); + + String json = mapper.writeValueAsString(list); + System.out.println(json); + + // make sure each region's link only appears once in the json + assertThat(json).containsOnlyOnce("\"self\":\"#HREF/management/v1/regions/regionA\"") + .containsOnlyOnce("\"self\":\"#HREF/management/v1/regions/regionB\""); + + ClusterManagementListResult result = + mapper.readValue(json, ClusterManagementListResult.class); + + assertThat(result.getEntityGroupInfo()).hasSize(3); + assertThat(result.getResult()).hasSize(2); + } +} diff --git a/geode-management/src/test/java/org/apache/geode/management/api/EntityGroupInfoTest.java b/geode-management/src/test/java/org/apache/geode/management/api/EntityGroupInfoTest.java index cf1d142320de..aa8ac190bb0d 100644 --- a/geode-management/src/test/java/org/apache/geode/management/api/EntityGroupInfoTest.java +++ b/geode-management/src/test/java/org/apache/geode/management/api/EntityGroupInfoTest.java @@ -38,7 +38,7 @@ public void jsonTest() throws Exception { String json = mapper.writeValueAsString(result); assertThat(regionJson).doesNotContain("links"); System.out.println(json); - assertThat(json).contains("links"); + assertThat(json).doesNotContain("links"); mapper.readValue(json, EntityGroupInfo.class); } } diff --git a/geode-management/src/test/java/org/apache/geode/management/api/EntityInfoTest.java b/geode-management/src/test/java/org/apache/geode/management/api/EntityInfoTest.java index 9a8ac5fe9034..190302e2bb4a 100644 --- a/geode-management/src/test/java/org/apache/geode/management/api/EntityInfoTest.java +++ b/geode-management/src/test/java/org/apache/geode/management/api/EntityInfoTest.java @@ -91,15 +91,19 @@ public void serialization() throws JsonProcessingException { EntityGroupInfo entityGroupInfo = new EntityGroupInfo<>(region, singletonList(runtimeRegionInfo)); + EntityGroupInfo entityGroupInfo2 = + new EntityGroupInfo<>(region, singletonList(runtimeRegionInfo)); + EntityInfo original = - new EntityInfo<>("my.element", singletonList(entityGroupInfo)); + new EntityInfo<>("my.element", asList(entityGroupInfo, entityGroupInfo2)); ObjectMapper mapper = GeodeJsonMapper.getMapper(); String json = mapper.writeValueAsString(original); assertThat(json) .containsOnlyOnce("id") - .containsOnlyOnce("configurationByGroup"); + .containsOnlyOnce("groups") + .containsOnlyOnce("links"); System.out.println(json); diff --git a/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java b/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java index faa36188266a..bf4b4edb7fc6 100644 --- a/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java +++ b/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java @@ -150,8 +150,7 @@ public void noMatchWithJavaAPI() { assertThat(result.isSuccessful()).isTrue(); assertThat(result.getStatusCode()) .isEqualTo(ClusterManagementResult.StatusCode.OK); - assertThat(result.getResult().size()).isEqualTo(1); - assertThat(result.getRuntimeResult().size()).isEqualTo(0); + assertThat(result.getResult().size()).isEqualTo(0); } @Test diff --git a/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/GatewayManagementIntegrationTest.java b/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/GatewayManagementIntegrationTest.java index 5797333e8596..5d5300e3ca50 100644 --- a/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/GatewayManagementIntegrationTest.java +++ b/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/GatewayManagementIntegrationTest.java @@ -78,7 +78,7 @@ public void listEmptyGatewayReceivers() { ClusterManagementListResult result = client.list(receiver); assertThat(result.isSuccessful()).isTrue(); - assertThat(result.getResult().size()).isEqualTo(0); + assertThat(result.getEntityGroupInfo().size()).isEqualTo(0); } @Test @@ -102,7 +102,7 @@ public void listExisting() { client.list(receiver); assertThat(results.isSuccessful()).isTrue(); List> receivers = - results.getResult(); + results.getEntityGroupInfo(); assertThat(receivers.size()).isEqualTo(1); GatewayReceiver result = receivers.get(0).getConfiguration(); assertThat(result.isManualStart()).isFalse(); diff --git a/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/HateoasIntegrationTest.java b/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/HateoasIntegrationTest.java index 9d2134d574ab..1d29e341edc4 100644 --- a/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/HateoasIntegrationTest.java +++ b/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/HateoasIntegrationTest.java @@ -89,10 +89,10 @@ public void getRegionHateoas() throws Exception { context.perform(get("/v1/regions/customers")) .andExpect(status().isOk()) .andExpect( - jsonPath("$.result.configurationByGroup[0].links.self", + jsonPath("$.result.links.self", Matchers.endsWith("/regions/customers"))) .andExpect( - jsonPath("$.result.configurationByGroup[0].links.indexes", + jsonPath("$.result.links.indexes", Matchers.endsWith("/regions/customers/indexes"))); } diff --git a/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/MemberManagementServiceRestIntegrationTest.java b/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/MemberManagementServiceRestIntegrationTest.java index 70c471f7dd23..d5fefaa3e8cc 100644 --- a/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/MemberManagementServiceRestIntegrationTest.java +++ b/geode-web-management/src/integrationTest/java/org/apache/geode/management/internal/rest/MemberManagementServiceRestIntegrationTest.java @@ -75,14 +75,16 @@ public void listLocator() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.memberStatuses").doesNotExist()) .andExpect(jsonPath("$.statusCode", is("OK"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[*].memberName", contains("locator-0"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].locatorPort", greaterThan(0))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].server", is(false))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].status", is("online"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].cacheServerInfo").doesNotExist()) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].logFilePath", endsWith("locator-0.log"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].workingDirPath", notNullValue())) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].heapUsage", greaterThan(0))); + .andExpect( + jsonPath("$.result[0].groups[0].runtimeInfo[*].memberName", contains("locator-0"))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].locatorPort", greaterThan(0))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].server", is(false))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].status", is("online"))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].cacheServerInfo").doesNotExist()) + .andExpect( + jsonPath("$.result[0].groups[0].runtimeInfo[0].logFilePath", endsWith("locator-0.log"))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].workingDirPath", notNullValue())) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].heapUsage", greaterThan(0))); } @Test @@ -92,20 +94,20 @@ public void getLocator() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.memberStatuses").doesNotExist()) .andExpect(jsonPath("$.statusCode", is("OK"))) - .andExpect(jsonPath("$.result.configurationByGroup[0].runtimeInfo[*].memberName", + .andExpect(jsonPath("$.result.groups[0].runtimeInfo[*].memberName", contains("locator-0"))) .andExpect( - jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].locatorPort", greaterThan(0))) - .andExpect(jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].server", is(false))) - .andExpect(jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].status", is("online"))) - .andExpect(jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].cacheServerInfo") + jsonPath("$.result.groups[0].runtimeInfo[0].locatorPort", greaterThan(0))) + .andExpect(jsonPath("$.result.groups[0].runtimeInfo[0].server", is(false))) + .andExpect(jsonPath("$.result.groups[0].runtimeInfo[0].status", is("online"))) + .andExpect(jsonPath("$.result.groups[0].runtimeInfo[0].cacheServerInfo") .doesNotExist()) - .andExpect(jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].logFilePath", + .andExpect(jsonPath("$.result.groups[0].runtimeInfo[0].logFilePath", endsWith("locator-0.log"))) - .andExpect(jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].workingDirPath", + .andExpect(jsonPath("$.result.groups[0].runtimeInfo[0].workingDirPath", notNullValue())) .andExpect( - jsonPath("$.result.configurationByGroup[0].runtimeInfo[0].heapUsage", greaterThan(0))); + jsonPath("$.result.groups[0].runtimeInfo[0].heapUsage", greaterThan(0))); } @Test @@ -116,18 +118,24 @@ public void listServer() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.memberStatuses").doesNotExist()) .andExpect(jsonPath("$.statusCode", is("OK"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[*].memberName", contains("server-1"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].locatorPort", is(0))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].server", is(true))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].cacheServerInfo[0].port", greaterThan(0))) .andExpect( - jsonPath("$.result[0].runtimeInfo[0].cacheServerInfo[0].maxConnections", equalTo(800))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].cacheServerInfo[0].maxThreads", equalTo(0))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].groups", equalTo("group-1,group-2"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].logFilePath", endsWith("server-1.log"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].workingDirPath", endsWith("vm1"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].clientCount", equalTo(0))) - .andExpect(jsonPath("$.result[0].runtimeInfo[0].heapUsage", greaterThan(0))); + jsonPath("$.result[0].groups[0].runtimeInfo[*].memberName", contains("server-1"))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].locatorPort", is(0))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].server", is(true))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].cacheServerInfo[0].port", + greaterThan(0))) + .andExpect( + jsonPath("$.result[0].groups[0].runtimeInfo[0].cacheServerInfo[0].maxConnections", + equalTo(800))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].cacheServerInfo[0].maxThreads", + equalTo(0))) + .andExpect( + jsonPath("$.result[0].groups[0].runtimeInfo[0].groups", equalTo("group-1,group-2"))) + .andExpect( + jsonPath("$.result[0].groups[0].runtimeInfo[0].logFilePath", endsWith("server-1.log"))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].workingDirPath", endsWith("vm1"))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].clientCount", equalTo(0))) + .andExpect(jsonPath("$.result[0].groups[0].runtimeInfo[0].heapUsage", greaterThan(0))); } @Test @@ -137,7 +145,7 @@ public void listAllMembers() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.memberStatuses").doesNotExist()) .andExpect(jsonPath("$.statusCode", is("OK"))) - .andExpect(jsonPath("$.result[0].runtimeInfo[*].memberName", + .andExpect(jsonPath("$.result[*].id", containsInAnyOrder("locator-0", "server-1"))); } } diff --git a/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/MemberManagementController.java b/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/MemberManagementController.java index cc9f87700c9b..0e51cf3f7121 100644 --- a/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/MemberManagementController.java +++ b/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/MemberManagementController.java @@ -40,7 +40,7 @@ public class MemberManagementController extends AbstractManagementController { @ApiOperation(value = "get member", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result | .configurationByGroup[] | .runtimeInfo[] | {name:.memberName,status:.status}")})}) + value = ".result | .groups[] | .runtimeInfo[] | {name:.memberName,status:.status}")})}) @PreAuthorize("@securityService.authorize('CLUSTER', 'READ')") @GetMapping(MEMBER_ENDPOINT + "/{id:.+}") public ClusterManagementGetResult getMember( @@ -53,7 +53,7 @@ public ClusterManagementGetResult getMember( @ApiOperation(value = "list members", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result[] | .runtimeInfo[] | {name:.memberName,status:.status}")})}) + value = ".result[] | .groups[] | .runtimeInfo[] | {name:.memberName,status:.status}")})}) @PreAuthorize("@securityService.authorize('CLUSTER', 'READ')") @GetMapping(MEMBER_ENDPOINT) public ClusterManagementListResult listMembers( diff --git a/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/RegionManagementController.java b/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/RegionManagementController.java index 20389b2a5419..ff3e8d81130c 100644 --- a/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/RegionManagementController.java +++ b/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/controllers/RegionManagementController.java @@ -69,7 +69,7 @@ public ResponseEntity createRegion( @ApiOperation(value = "list regions", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result[] | .runtimeInfo[] + .configuration | {name:.name,type:.type,entryCount:.entryCount}")})}) + value = ".result[] | .groups[] | .runtimeInfo[] + .configuration | {name:.name,type:.type,entryCount:.entryCount}")})}) @PreAuthorize("@securityService.authorize('CLUSTER', 'READ')") @GetMapping(REGION_CONFIG_ENDPOINT) public ClusterManagementListResult listRegion( @@ -88,7 +88,7 @@ public ClusterManagementListResult listRegion( @ApiOperation(value = "get region", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result | .configurationByGroup[] | .runtimeInfo[] + .configuration | {name:.name,type:.type,entryCount:.entryCount}")})}) + value = ".result | .groups[] | .runtimeInfo[] + .configuration | {name:.name,type:.type,entryCount:.entryCount}")})}) @GetMapping(REGION_CONFIG_ENDPOINT + "/{id:.+}") public ClusterManagementGetResult getRegion( @PathVariable(name = "id") String id) { @@ -115,7 +115,7 @@ public ClusterManagementResult deleteRegion( @ApiOperation(value = "list region indexes", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result[] | .configuration | {name:.name,expression:.expression}")})}) + value = ".result[] | .groups[] | .configuration | {name:.name,expression:.expression}")})}) @GetMapping(REGION_CONFIG_ENDPOINT + "/{regionName}" + INDEXES) @PreAuthorize("@securityService.authorize('CLUSTER', 'READ', 'QUERY')") public ClusterManagementListResult listIndex( @@ -133,7 +133,7 @@ public ClusterManagementListResult listIndex( @ApiOperation(value = "list indexes", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result[] | .configuration | {name:.name,expression:.expression,regionPath:.regionPath}")})}) + value = ".result[] | .groups[] | .configuration | {name:.name,expression:.expression,regionPath:.regionPath}")})}) @GetMapping(INDEXES) @PreAuthorize("@securityService.authorize('CLUSTER', 'READ', 'QUERY')") public ClusterManagementListResult listAllIndex( @@ -148,7 +148,7 @@ public ClusterManagementListResult listAllIndex( @ApiOperation(value = "get index", extensions = {@Extension(properties = { @ExtensionProperty(name = "jqFilter", - value = ".result | .configurationByGroup[] | .configuration | {name:.name,expression:.expression}")})}) + value = ".result | .groups[] | .configuration | {name:.name,expression:.expression}")})}) @GetMapping(REGION_CONFIG_ENDPOINT + "/{regionName}" + INDEXES + "/{id:.+}") @PreAuthorize("@securityService.authorize('CLUSTER', 'READ', 'QUERY')") public ClusterManagementGetResult getIndex(