From 901fce5f7ec29c66170030f2928872128f13bf16 Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 22 Jan 2020 17:07:21 -0800 Subject: [PATCH] Do first revision (review and refactoring) of Apache Geode's Actuator support and HealthIndicators in order to adapt to Spring Boot's new HealthContributor API. --- ...GeodeHealthIndicatorAutoConfiguration.java | 5 ++-- ...BaseGeodeHealthIndicatorConfiguration.java | 2 +- ...ientCacheHealthIndicatorConfiguration.java | 2 +- ...PeerCacheHealthIndicatorConfiguration.java | 1 + .../GeodeAsyncEventQueuesHealthIndicator.java | 4 ++-- .../actuate/GeodeCacheHealthIndicator.java | 3 ++- .../GeodeCacheServersHealthIndicator.java | 3 ++- ...GeodeContinuousQueriesHealthIndicator.java | 7 +++--- .../GeodeDiskStoresHealthIndicator.java | 6 ++--- .../GeodeGatewayReceiversHealthIndicator.java | 4 ++-- .../GeodeGatewaySendersHealthIndicator.java | 3 ++- .../actuate/GeodeIndexesHealthIndicator.java | 3 ++- .../actuate/GeodePoolsHealthIndicator.java | 8 +++---- .../actuate/GeodeRegionsHealthIndicator.java | 3 ++- .../GeodePoolsHealthIndicatorUnitTests.java | 19 +++++++-------- .../GeodeRegionsHealthIndicatorUnitTests.java | 23 ++++++++++--------- 16 files changed, 51 insertions(+), 45 deletions(-) diff --git a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/GeodeHealthIndicatorAutoConfiguration.java b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/GeodeHealthIndicatorAutoConfiguration.java index 5b010511..5b48dc0b 100644 --- a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/GeodeHealthIndicatorAutoConfiguration.java +++ b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/GeodeHealthIndicatorAutoConfiguration.java @@ -18,10 +18,8 @@ package org.springframework.geode.boot.actuate.autoconfigure; import org.apache.geode.cache.GemFireCache; import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; -import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -41,8 +39,10 @@ import org.springframework.geode.boot.autoconfigure.ClientCacheAutoConfiguration * @see org.apache.geode.cache.GemFireCache * @see org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator * @see org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration + * @see org.springframework.boot.autoconfigure.EnableAutoConfiguration * @see org.springframework.context.annotation.Configuration * @see org.springframework.context.annotation.Import + * @see org.springframework.data.gemfire.CacheFactoryBean * @see org.springframework.geode.boot.actuate.autoconfigure.config.BaseGeodeHealthIndicatorConfiguration * @see org.springframework.geode.boot.actuate.autoconfigure.config.ClientCacheHealthIndicatorConfiguration * @see org.springframework.geode.boot.actuate.autoconfigure.config.PeerCacheHealthIndicatorConfiguration @@ -51,7 +51,6 @@ import org.springframework.geode.boot.autoconfigure.ClientCacheAutoConfiguration */ @Configuration @AutoConfigureAfter(ClientCacheAutoConfiguration.class) -@AutoConfigureBefore(HealthContributorAutoConfiguration.class) @ConditionalOnBean(GemFireCache.class) @ConditionalOnClass(CacheFactoryBean.class) @ConditionalOnEnabledHealthIndicator("geode") diff --git a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/BaseGeodeHealthIndicatorConfiguration.java b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/BaseGeodeHealthIndicatorConfiguration.java index 73b8ec86..905934d6 100644 --- a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/BaseGeodeHealthIndicatorConfiguration.java +++ b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/BaseGeodeHealthIndicatorConfiguration.java @@ -13,12 +13,12 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate.autoconfigure.config; import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.client.ClientCache; + import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/ClientCacheHealthIndicatorConfiguration.java b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/ClientCacheHealthIndicatorConfiguration.java index c1ba314e..d6c841f4 100644 --- a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/ClientCacheHealthIndicatorConfiguration.java +++ b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/ClientCacheHealthIndicatorConfiguration.java @@ -13,12 +13,12 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate.autoconfigure.config; import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.client.ClientCache; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.context.annotation.Bean; diff --git a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/PeerCacheHealthIndicatorConfiguration.java b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/PeerCacheHealthIndicatorConfiguration.java index ba6853e6..f90449db 100644 --- a/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/PeerCacheHealthIndicatorConfiguration.java +++ b/spring-geode-actuator-autoconfigure/src/main/java/org/springframework/geode/boot/actuate/autoconfigure/config/PeerCacheHealthIndicatorConfiguration.java @@ -22,6 +22,7 @@ import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.server.ServerLoadProbe; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.boot.actuate.health.HealthIndicator; diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeAsyncEventQueuesHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeAsyncEventQueuesHealthIndicator.java index e1030fe2..611b3647 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeAsyncEventQueuesHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeAsyncEventQueuesHealthIndicator.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate; import java.util.Collections; @@ -23,6 +22,7 @@ import java.util.Set; import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.asyncqueue.AsyncEventQueue; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.gemfire.util.CacheUtils; @@ -65,7 +65,7 @@ public class GeodeAsyncEventQueuesHealthIndicator extends AbstractGeodeHealthInd } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getGemFireCache().filter(CacheUtils::isPeer).isPresent()) { diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheHealthIndicator.java index 507cd3f1..776df16c 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheHealthIndicator.java @@ -23,6 +23,7 @@ import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.control.ResourceManager; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.distributed.DistributedSystem; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.Status; @@ -90,7 +91,7 @@ public class GeodeCacheHealthIndicator extends AbstractGeodeHealthIndicator { } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getGemFireCache().isPresent()) { diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheServersHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheServersHealthIndicator.java index 2d6e07c9..6bee225b 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheServersHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeCacheServersHealthIndicator.java @@ -25,6 +25,7 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.server.ServerLoad; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.gemfire.util.CacheUtils; @@ -69,7 +70,7 @@ public class GeodeCacheServersHealthIndicator extends AbstractGeodeHealthIndicat } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getGemFireCache().filter(CacheUtils::isPeer).isPresent()) { diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeContinuousQueriesHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeContinuousQueriesHealthIndicator.java index 0857a774..aafbc854 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeContinuousQueriesHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeContinuousQueriesHealthIndicator.java @@ -27,6 +27,7 @@ import org.apache.geode.cache.query.CqStatistics; import org.apache.geode.cache.query.Query; import org.apache.geode.cache.query.QueryService; import org.apache.geode.cache.query.QueryStatistics; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer; @@ -102,14 +103,14 @@ public class GeodeContinuousQueriesHealthIndicator extends AbstractGeodeHealthIn queryService .map(QueryService::getCqStatistics) - .ifPresent(cqServiceStatistics -> { + .ifPresent(cqServiceStatistics -> builder.withDetail("geode.continuous-query.number-of-active", cqServiceStatistics.numCqsActive()) .withDetail("geode.continuous-query.number-of-closed", cqServiceStatistics.numCqsClosed()) .withDetail("geode.continuous-query.number-of-created", cqServiceStatistics.numCqsCreated()) .withDetail("geode.continuous-query.number-of-stopped", cqServiceStatistics.numCqsStopped()) - .withDetail("geode.continuous-query.number-on-client", cqServiceStatistics.numCqsOnClient()); - }); + .withDetail("geode.continuous-query.number-on-client", cqServiceStatistics.numCqsOnClient()) + ); continuousQueries.stream() .filter(Objects::nonNull) diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeDiskStoresHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeDiskStoresHealthIndicator.java index 273c89bd..04c4c4ce 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeDiskStoresHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeDiskStoresHealthIndicator.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate; import java.io.File; @@ -22,7 +21,6 @@ import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; import org.apache.geode.cache.DiskStore; @@ -88,7 +86,7 @@ public class GeodeDiskStoresHealthIndicator extends AbstractGeodeHealthIndicator } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getApplicationContext().isPresent()) { @@ -137,7 +135,7 @@ public class GeodeDiskStoresHealthIndicator extends AbstractGeodeHealthIndicator return Arrays.toString(Arrays.stream(ArrayUtils.nullSafeArray(files, File.class)) .filter(Objects::nonNull) .map(File::getAbsolutePath) - .collect(Collectors.toSet()) + .distinct() .toArray()); } } diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewayReceiversHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewayReceiversHealthIndicator.java index 42df7113..c2a76316 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewayReceiversHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewayReceiversHealthIndicator.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate; import java.util.Collections; @@ -24,6 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.wan.GatewayReceiver; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.gemfire.util.CacheUtils; @@ -66,7 +66,7 @@ public class GeodeGatewayReceiversHealthIndicator extends AbstractGeodeHealthInd } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getGemFireCache().filter(CacheUtils::isPeer).isPresent()) { diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewaySendersHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewaySendersHealthIndicator.java index 70b90eef..d2f3488a 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewaySendersHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeGatewaySendersHealthIndicator.java @@ -22,6 +22,7 @@ import java.util.Set; import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.wan.GatewaySender; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.gemfire.util.CacheUtils; @@ -65,7 +66,7 @@ public class GeodeGatewaySendersHealthIndicator extends AbstractGeodeHealthIndic } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getGemFireCache().filter(CacheUtils::isPeer).isPresent()) { diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeIndexesHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeIndexesHealthIndicator.java index acebde27..9b6723fb 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeIndexesHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeIndexesHealthIndicator.java @@ -87,7 +87,7 @@ public class GeodeIndexesHealthIndicator extends AbstractGeodeHealthIndicator { } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getApplicationContext().isPresent()) { @@ -144,6 +144,7 @@ public class GeodeIndexesHealthIndicator extends AbstractGeodeHealthIndicator { return String.format("geode.index.%1$s.statistics.%2$s", indexName, suffix); } + @SuppressWarnings("rawtypes") private String toRegionPath(Region region) { String regionPath = region != null ? region.getFullPath() : null; diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicator.java index 5882b29f..c6fa25ac 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicator.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate; import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList; @@ -29,6 +28,7 @@ import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.client.Pool; import org.apache.geode.cache.client.PoolManager; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.data.gemfire.util.CacheUtils; @@ -72,7 +72,7 @@ public class GeodePoolsHealthIndicator extends AbstractGeodeHealthIndicator { } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { + protected void doHealthCheck(Health.Builder builder) { if (getGemFireCache().filter(CacheUtils::isClient).isPresent()) { @@ -106,8 +106,8 @@ public class GeodePoolsHealthIndicator extends AbstractGeodeHealthIndicator { .withDetail(poolKey(poolName, "subscription-ack-interval"), pool.getSubscriptionAckInterval()) .withDetail(poolKey(poolName, "subscription-enabled"), toYesNoString(pool.getSubscriptionEnabled())) .withDetail(poolKey(poolName, "subscription-message-tracking-timeout"), pool.getSubscriptionMessageTrackingTimeout()) - .withDetail(poolKey(poolName, "subscription-redundancy"), pool.getSubscriptionRedundancy()) - .withDetail(poolKey(poolName, "thread-local-connections"), toYesNoString(pool.getThreadLocalConnections())); + .withDetail(poolKey(poolName, "subscription-redundancy"), pool.getSubscriptionRedundancy()); + //.withDetail(poolKey(poolName, "thread-local-connections"), toYesNoString(pool.getThreadLocalConnections())); getGemFireCache() .map(ClientCache.class::cast) diff --git a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicator.java b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicator.java index 3a8585fb..46520242 100644 --- a/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicator.java +++ b/spring-geode-actuator/src/main/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicator.java @@ -30,6 +30,7 @@ import org.apache.geode.cache.PartitionAttributes; import org.apache.geode.cache.Region; import org.apache.geode.cache.RegionAttributes; import org.apache.geode.internal.cache.LocalDataSet; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.geode.boot.actuate.health.AbstractGeodeHealthIndicator; @@ -160,7 +161,7 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator { builder.withDetail(cachePartitionRegionKey(regionName, "collocated-with"), emptyIfUnset(partitionAttributes.getColocatedWith())) .withDetail(cachePartitionRegionKey(regionName, "local-max-memory"), partitionAttributes.getLocalMaxMemory()) .withDetail(cachePartitionRegionKey(regionName, "redundant-copies"), partitionAttributes.getRedundantCopies()) - .withDetail(cachePartitionRegionKey(regionName, "total-max-memory"), partitionAttributes.getTotalMaxMemory()) + //.withDetail(cachePartitionRegionKey(regionName, "total-max-memory"), partitionAttributes.getTotalMaxMemory()) .withDetail(cachePartitionRegionKey(regionName, "total-number-of-buckets"), partitionAttributes.getTotalNumBuckets()); } } diff --git a/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicatorUnitTests.java b/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicatorUnitTests.java index 737e93af..f3473124 100644 --- a/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicatorUnitTests.java +++ b/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodePoolsHealthIndicatorUnitTests.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate; import static org.assertj.core.api.Assertions.assertThat; @@ -30,16 +29,18 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.client.ClientCache; -import org.apache.geode.cache.client.Pool; -import org.apache.geode.distributed.DistributedSystem; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.GemFireCache; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.Pool; +import org.apache.geode.distributed.DistributedSystem; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Status; import org.springframework.data.gemfire.tests.mock.PoolMockObjects; @@ -97,7 +98,7 @@ public class GeodePoolsHealthIndicatorUnitTests { } @Test - public void healthCheckCapturesDetails() throws Exception { + public void healthCheckCapturesDetails() { List mockLocators = Arrays.asList(testSocketAddress("mailbox", 1234), @@ -149,12 +150,12 @@ public class GeodePoolsHealthIndicatorUnitTests { assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-enabled", "Yes"); assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-message-tracking-timeout", 5000); assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-redundancy", 2); - assertThat(healthDetails).containsEntry("geode.pool.MockPool.thread-local-connections", "No"); + //assertThat(healthDetails).containsEntry("geode.pool.MockPool.thread-local-connections", "No"); verify(this.poolsHealthIndicator, times(1)).findAllPools(); } - public void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception { + public void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) { GeodePoolsHealthIndicator healthIndicator = gemfireCache != null ? new GeodePoolsHealthIndicator(gemfireCache) diff --git a/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicatorUnitTests.java b/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicatorUnitTests.java index 0afebde7..a7d845f7 100644 --- a/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicatorUnitTests.java +++ b/spring-geode-actuator/src/test/java/org/springframework/geode/boot/actuate/GeodeRegionsHealthIndicatorUnitTests.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.geode.boot.actuate; import static org.assertj.core.api.Assertions.assertThat; @@ -28,6 +27,12 @@ import java.util.Currency; import java.util.Map; import java.util.Set; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + import org.apache.geode.cache.CacheStatistics; import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.EvictionAction; @@ -39,11 +44,7 @@ import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.PartitionAttributes; import org.apache.geode.cache.Region; import org.apache.geode.cache.Scope; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Status; import org.springframework.data.gemfire.tests.mock.CacheMockObjects; @@ -79,8 +80,8 @@ public class GeodeRegionsHealthIndicatorUnitTests { } @Test - @SuppressWarnings("unchecked") - public void healthCheckCapturesDetails() throws Exception { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void healthCheckCapturesDetails() { Region mockRegionOne = CacheMockObjects.mockRegion("MockRegionOne", DataPolicy.PARTITION); @@ -99,7 +100,7 @@ public class GeodeRegionsHealthIndicatorUnitTests { when(mockPartitionAttributes.getColocatedWith()).thenReturn("CollocatedRegion"); when(mockPartitionAttributes.getLocalMaxMemory()).thenReturn(10240); when(mockPartitionAttributes.getRedundantCopies()).thenReturn(2); - when(mockPartitionAttributes.getTotalMaxMemory()).thenReturn(4096000L); + //when(mockPartitionAttributes.getTotalMaxMemory()).thenReturn(4096000L); when(mockPartitionAttributes.getTotalNumBuckets()).thenReturn(226); when(mockRegionOne.getAttributes().getPartitionAttributes()).thenReturn(mockPartitionAttributes); @@ -176,7 +177,7 @@ public class GeodeRegionsHealthIndicatorUnitTests { assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.partition.collocated-with", "CollocatedRegion"); assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.partition.local-max-memory", 10240); assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.partition.redundant-copies", 2); - assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.partition.total-max-memory", 4096000L); + //assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.partition.total-max-memory", 4096000L); assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.partition.total-number-of-buckets", 226); assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.pool-name", ""); assertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.scope", Scope.DISTRIBUTED_ACK.toString()); @@ -206,7 +207,7 @@ public class GeodeRegionsHealthIndicatorUnitTests { } @Test - public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception { + public void healthCheckFailsWhenGemFireCacheIsNotPresent() { GeodeRegionsHealthIndicator healthIndicator = new GeodeRegionsHealthIndicator();