Remove unnecessary use of java.util.Optional.
This commit is contained in:
@@ -13,12 +13,9 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.geode.boot.actuate;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.geode.CancelCriterion;
|
||||
@@ -29,6 +26,7 @@ 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;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.geode.boot.actuate.health.AbstractGeodeHealthIndicator;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -137,23 +135,11 @@ public class GeodeCacheHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
return healthBuilder -> getGemFireCache()
|
||||
.map(GemFireCache::getDistributedSystem)
|
||||
.map(distributedSystem -> healthBuilder
|
||||
.withDetail("geode.distributed-system.member-count", Optional.of(distributedSystem)
|
||||
.map(DistributedSystem::getAllOtherMembers)
|
||||
.map(Collection::size)
|
||||
.map(size -> size + 1)
|
||||
.orElse(1))
|
||||
.withDetail("geode.distributed-system.member-count", toMemberCount(distributedSystem))
|
||||
.withDetail("geode.distributed-system.connection", toConnectedNoConnectedString(distributedSystem.isConnected()))
|
||||
.withDetail("geode.distributed-system.reconnecting", toYesNoString(distributedSystem.isReconnecting()))
|
||||
.withDetail("geode.distributed-system.properties-location",
|
||||
Optional.ofNullable(DistributedSystem.getPropertiesFileURL())
|
||||
.map(URL::toExternalForm)
|
||||
.filter(StringUtils::hasText)
|
||||
.orElse(""))
|
||||
.withDetail("geode.distributed-system.security-properties-location",
|
||||
Optional.ofNullable(DistributedSystem.getSecurityPropertiesFileURL())
|
||||
.map(URL::toExternalForm)
|
||||
.filter(StringUtils::hasText)
|
||||
.orElse(""))
|
||||
.withDetail("geode.distributed-system.properties-location", toString(DistributedSystem.getPropertiesFileURL()))
|
||||
.withDetail("geode.distributed-system.security-properties-location", toString(DistributedSystem.getSecurityPropertiesFileURL()))
|
||||
)
|
||||
.orElse(healthBuilder);
|
||||
}
|
||||
@@ -171,7 +157,22 @@ public class GeodeCacheHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
.orElse(healthBuilder);
|
||||
}
|
||||
|
||||
private String emptyIfUnset(String value) {
|
||||
return StringUtils.hasText(value) ? value : "";
|
||||
}
|
||||
|
||||
private String toConnectedNoConnectedString(Boolean connected) {
|
||||
return Boolean.TRUE.equals(connected) ? "Connected" : "Not Connected";
|
||||
}
|
||||
|
||||
private int toMemberCount(DistributedSystem distributedSystem) {
|
||||
return CollectionUtils.nullSafeSize(distributedSystem.getAllOtherMembers()) + 1;
|
||||
}
|
||||
|
||||
private String toString(URL url) {
|
||||
|
||||
String urlString = url != null ? url.toExternalForm() : null;
|
||||
|
||||
return emptyIfUnset(urlString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -25,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
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;
|
||||
@@ -112,14 +112,15 @@ public class GeodeCacheServersHealthIndicator extends AbstractGeodeHealthIndicat
|
||||
.withDetail(cacheServerMetricsKey(cacheServerIndex, "open-connection-count"), serverMetrics.getConnectionCount())
|
||||
.withDetail(cacheServerMetricsKey(cacheServerIndex, "subscription-connection-count"), serverMetrics.getSubscriptionConnectionCount());
|
||||
|
||||
Optional.ofNullable(cacheServer.getLoadProbe().getLoad(serverMetrics))
|
||||
.ifPresent(serverLoad -> {
|
||||
ServerLoad serverLoad = cacheServer.getLoadProbe().getLoad(serverMetrics);
|
||||
|
||||
builder.withDetail(cacheServerLoadKey(cacheServerIndex, "connection-load"), serverLoad.getConnectionLoad())
|
||||
.withDetail(cacheServerLoadKey(cacheServerIndex, "load-per-connection"), serverLoad.getLoadPerConnection())
|
||||
.withDetail(cacheServerLoadKey(cacheServerIndex, "subscription-connection-load"), serverLoad.getSubscriptionConnectionLoad())
|
||||
.withDetail(cacheServerLoadKey(cacheServerIndex, "load-per-subscription-connection"), serverLoad.getLoadPerSubscriptionConnection());
|
||||
});
|
||||
if (serverLoad != null) {
|
||||
|
||||
builder.withDetail(cacheServerLoadKey(cacheServerIndex, "connection-load"), serverLoad.getConnectionLoad())
|
||||
.withDetail(cacheServerLoadKey(cacheServerIndex, "load-per-connection"), serverLoad.getLoadPerConnection())
|
||||
.withDetail(cacheServerLoadKey(cacheServerIndex, "subscription-connection-load"), serverLoad.getSubscriptionConnectionLoad())
|
||||
.withDetail(cacheServerLoadKey(cacheServerIndex, "load-per-subscription-connection"), serverLoad.getLoadPerSubscriptionConnection());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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.Arrays;
|
||||
@@ -24,8 +23,10 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.geode.cache.query.CqQuery;
|
||||
import org.apache.geode.cache.query.CqState;
|
||||
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;
|
||||
@@ -85,7 +86,7 @@ public class GeodeContinuousQueriesHealthIndicator extends AbstractGeodeHealthIn
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
protected void doHealthCheck(Health.Builder builder) {
|
||||
|
||||
if (getContinuousQueryListenerContainer().isPresent()) {
|
||||
|
||||
@@ -118,28 +119,34 @@ public class GeodeContinuousQueriesHealthIndicator extends AbstractGeodeHealthIn
|
||||
|
||||
builder.withDetail(continuousQueryKey(continuousQueryName,"oql-query-string"), continuousQuery.getQueryString())
|
||||
.withDetail(continuousQueryKey(continuousQueryName, "closed"), toYesNoString(continuousQuery.isClosed()))
|
||||
.withDetail(continuousQueryKey(continuousQueryName, "closing"), Optional.ofNullable(continuousQuery.getState())
|
||||
.map(CqState::isClosing)
|
||||
.map(this::toYesNoString)
|
||||
.orElse(UNKNOWN))
|
||||
.withDetail(continuousQueryKey(continuousQueryName, "closing"), toYesNoString(continuousQuery.getState()))
|
||||
.withDetail(continuousQueryKey(continuousQueryName, "durable"), toYesNoString(continuousQuery.isDurable()))
|
||||
.withDetail(continuousQueryKey(continuousQueryName, "running"), toYesNoString(continuousQuery.isRunning()))
|
||||
.withDetail(continuousQueryKey(continuousQueryName, "stopped"), toYesNoString(continuousQuery.isStopped()));
|
||||
|
||||
Optional.ofNullable(continuousQuery.getQuery())
|
||||
.map(Query::getStatistics)
|
||||
.ifPresent(queryStatistics ->
|
||||
Query query = continuousQuery.getQuery();
|
||||
|
||||
if (query != null) {
|
||||
|
||||
QueryStatistics queryStatistics = query.getStatistics();
|
||||
|
||||
if (queryStatistics != null) {
|
||||
builder.withDetail(continuousQueryQueryKey(continuousQueryName, "number-of-executions"), queryStatistics.getNumExecutions())
|
||||
.withDetail(continuousQueryQueryKey(continuousQueryName, "total-execution-time"), queryStatistics.getTotalExecutionTime()));
|
||||
.withDetail(continuousQueryQueryKey(continuousQueryName, "total-execution-time"), queryStatistics.getTotalExecutionTime());
|
||||
}
|
||||
}
|
||||
|
||||
Optional.ofNullable(continuousQuery.getStatistics())
|
||||
.ifPresent(continuousQueryStatistics ->
|
||||
builder.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-deletes"), continuousQueryStatistics.numDeletes())
|
||||
.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-events"), continuousQueryStatistics.numEvents())
|
||||
.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-inserts"), continuousQueryStatistics.numInserts())
|
||||
.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-updates"), continuousQueryStatistics.numUpdates()));
|
||||
CqStatistics continuousQueryStatistics = continuousQuery.getStatistics();
|
||||
|
||||
if (continuousQueryStatistics != null) {
|
||||
|
||||
builder.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-deletes"), continuousQueryStatistics.numDeletes())
|
||||
.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-events"), continuousQueryStatistics.numEvents())
|
||||
.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-inserts"), continuousQueryStatistics.numInserts())
|
||||
.withDetail(continuousQueryStatisticsKey(continuousQueryName, "number-of-updates"), continuousQueryStatistics.numUpdates());
|
||||
}
|
||||
});
|
||||
|
||||
builder.up();
|
||||
|
||||
return;
|
||||
@@ -159,4 +166,8 @@ public class GeodeContinuousQueriesHealthIndicator extends AbstractGeodeHealthIn
|
||||
private String continuousQueryStatisticsKey(String continuousQueryName, String suffix) {
|
||||
return String.format("geode.continuous-query.%1$s.statistics.%2$s", continuousQueryName, suffix);
|
||||
}
|
||||
|
||||
private String toYesNoString(CqState continuousQueryState) {
|
||||
return continuousQueryState != null ? toYesNoString(continuousQueryState.isClosing()) : UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@
|
||||
* 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;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
@@ -88,9 +86,7 @@ public class GeodeGatewaySendersHealthIndicator extends AbstractGeodeHealthIndic
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "batch-conflation-enabled"), toYesNoString(gatewaySender.isBatchConflationEnabled()))
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "batch-size"), gatewaySender.getBatchSize())
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "batch-time-interval"), gatewaySender.getBatchTimeInterval())
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "disk-store-name"), Optional.ofNullable(gatewaySender.getDiskStoreName())
|
||||
.filter(StringUtils::hasText)
|
||||
.orElse(""))
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "disk-store-name"), emptyIfUnset(gatewaySender.getDiskStoreName()))
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "disk-synchronous"), toYesNoString(gatewaySender.isDiskSynchronous()))
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "dispatcher-threads"), gatewaySender.getDispatcherThreads())
|
||||
.withDetail(gatewaySendersKey(gatewaySenderId, "max-queue-memory"), gatewaySender.getMaximumQueueMemory())
|
||||
@@ -113,6 +109,10 @@ public class GeodeGatewaySendersHealthIndicator extends AbstractGeodeHealthIndic
|
||||
builder.unknown();
|
||||
}
|
||||
|
||||
private String emptyIfUnset(String value) {
|
||||
return StringUtils.hasText(value) ? value : "";
|
||||
}
|
||||
|
||||
private String gatewaySendersKey(String id, String suffix) {
|
||||
return String.format("geode.gateway-sender.%1$s.%2$s", id, suffix);
|
||||
}
|
||||
|
||||
@@ -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,11 +22,13 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
import org.apache.geode.cache.query.IndexStatistics;
|
||||
import org.apache.shiro.util.Assert;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.geode.boot.actuate.health.AbstractGeodeHealthIndicator;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The {@link GeodeIndexesHealthIndicator} class is a Spring Boot {@link HealthIndicator} providing details about
|
||||
@@ -104,23 +105,22 @@ public class GeodeIndexesHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
builder.withDetail(indexKey(indexName, "from-clause"), index.getFromClause())
|
||||
.withDetail(indexKey(indexName, "indexed-expression"), index.getIndexedExpression())
|
||||
.withDetail(indexKey(indexName, "projection-attributes"), index.getProjectionAttributes())
|
||||
.withDetail(indexKey(indexName, "region"), Optional.ofNullable(index.getRegion())
|
||||
.map(Region::getFullPath)
|
||||
.orElse(""))
|
||||
.withDetail(indexKey(indexName, "region"), toRegionPath(index.getRegion()))
|
||||
.withDetail(indexKey(indexName, "type"), String.valueOf(index.getType()));
|
||||
|
||||
Optional.ofNullable(index.getStatistics())
|
||||
.ifPresent(indexStatistics -> {
|
||||
IndexStatistics indexStatistics = index.getStatistics();
|
||||
|
||||
builder.withDetail(indexStatisticsKey(indexName, "number-of-bucket-indexes"), indexStatistics.getNumberOfBucketIndexes())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-keys"), indexStatistics.getNumberOfKeys())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-map-index-keys"), indexStatistics.getNumberOfMapIndexKeys())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-values"), indexStatistics.getNumberOfValues())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-updates"), indexStatistics.getNumUpdates())
|
||||
.withDetail(indexStatisticsKey(indexName, "read-lock-count"), indexStatistics.getReadLockCount())
|
||||
.withDetail(indexStatisticsKey(indexName, "total-update-time"), indexStatistics.getTotalUpdateTime())
|
||||
.withDetail(indexStatisticsKey(indexName, "total-uses"), indexStatistics.getTotalUses());
|
||||
});
|
||||
if (indexStatistics != null) {
|
||||
|
||||
builder.withDetail(indexStatisticsKey(indexName, "number-of-bucket-indexes"), indexStatistics.getNumberOfBucketIndexes())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-keys"), indexStatistics.getNumberOfKeys())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-map-index-keys"), indexStatistics.getNumberOfMapIndexKeys())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-values"), indexStatistics.getNumberOfValues())
|
||||
.withDetail(indexStatisticsKey(indexName, "number-of-updates"), indexStatistics.getNumUpdates())
|
||||
.withDetail(indexStatisticsKey(indexName, "read-lock-count"), indexStatistics.getReadLockCount())
|
||||
.withDetail(indexStatisticsKey(indexName, "total-update-time"), indexStatistics.getTotalUpdateTime())
|
||||
.withDetail(indexStatisticsKey(indexName, "total-uses"), indexStatistics.getTotalUses());
|
||||
}
|
||||
});
|
||||
|
||||
builder.up();
|
||||
@@ -131,6 +131,10 @@ public class GeodeIndexesHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
builder.unknown();
|
||||
}
|
||||
|
||||
private String emptyIfUnset(String value) {
|
||||
return StringUtils.hasText(value) ? value : "";
|
||||
}
|
||||
|
||||
private String indexKey(String indexName, String suffix) {
|
||||
return String.format("geode.index.%1$s.%2$s", indexName, suffix);
|
||||
}
|
||||
@@ -138,4 +142,11 @@ public class GeodeIndexesHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
private String indexStatisticsKey(String indexName, String suffix) {
|
||||
return String.format("geode.index.%1$s.statistics.%2$s", indexName, suffix);
|
||||
}
|
||||
|
||||
private String toRegionPath(Region region) {
|
||||
|
||||
String regionPath = region != null ? region.getFullPath() : null;
|
||||
|
||||
return emptyIfUnset(regionPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,7 +22,11 @@ import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.geode.cache.EvictionAlgorithm;
|
||||
import org.apache.geode.cache.EvictionAttributes;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
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;
|
||||
@@ -89,7 +92,7 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
protected void doHealthCheck(Health.Builder builder) {
|
||||
|
||||
if (getGemFireCache().isPresent()) {
|
||||
|
||||
@@ -125,42 +128,42 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
|
||||
builder.withDetail(cacheRegionKey(regionName, "full-path"), region.getFullPath());
|
||||
|
||||
Optional.ofNullable(region.getAttributes())
|
||||
.ifPresent(regionAttributes -> builder
|
||||
.withDetail(cacheRegionKey(regionName, "cloning-enabled"), toYesNoString(regionAttributes.getCloningEnabled()))
|
||||
if (isRegionAttributesPresent(region)) {
|
||||
|
||||
RegionAttributes<?, ?> regionAttributes = region.getAttributes();
|
||||
|
||||
builder.withDetail(cacheRegionKey(regionName, "cloning-enabled"), toYesNoString(regionAttributes.getCloningEnabled()))
|
||||
.withDetail(cacheRegionKey(regionName, "data-policy"), String.valueOf(regionAttributes.getDataPolicy()))
|
||||
.withDetail(cacheRegionKey(regionName, "initial-capacity"), regionAttributes.getInitialCapacity())
|
||||
.withDetail(cacheRegionKey(regionName, "load-factor"), regionAttributes.getLoadFactor())
|
||||
.withDetail(cacheRegionKey(regionName, "key-constraint"), nullSafeClassName(regionAttributes.getKeyConstraint()))
|
||||
.withDetail(cacheRegionKey(regionName, "off-heap"), toYesNoString(regionAttributes.getOffHeap()))
|
||||
.withDetail(cacheRegionKey(regionName, "pool-name"), Optional.ofNullable(regionAttributes.getPoolName())
|
||||
.filter(StringUtils::hasText)
|
||||
.orElse(""))
|
||||
.withDetail(cacheRegionKey(regionName, "pool-name"), emptyIfUnset(regionAttributes.getPoolName()))
|
||||
.withDetail(cacheRegionKey(regionName, "scope"), String.valueOf(regionAttributes.getScope()))
|
||||
.withDetail(cacheRegionKey(regionName, "statistics-enabled"), toYesNoString(regionAttributes.getStatisticsEnabled()))
|
||||
.withDetail(cacheRegionKey(regionName, "value-constraint"), nullSafeClassName(regionAttributes.getValueConstraint())));
|
||||
.withDetail(cacheRegionKey(regionName, "value-constraint"), nullSafeClassName(regionAttributes.getValueConstraint())); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private BiConsumer<Region<?, ?>, Health.Builder> withPartitionRegionDetails() {
|
||||
|
||||
return (region, builder) -> {
|
||||
|
||||
String regionName = region.getName();
|
||||
if (isRegionAttributesPresent(region)) {
|
||||
|
||||
Optional.of(region)
|
||||
.filter(this::isRegionAttributesPresent)
|
||||
.map(Region::getAttributes)
|
||||
.map(RegionAttributes::getPartitionAttributes)
|
||||
.ifPresent(partitionAttributes -> builder
|
||||
.withDetail(cachePartitionRegionKey(regionName, "collocated-with"), Optional.ofNullable(partitionAttributes.getColocatedWith())
|
||||
.filter(StringUtils::hasText)
|
||||
.orElse(""))
|
||||
.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-number-of-buckets"), partitionAttributes.getTotalNumBuckets()));
|
||||
PartitionAttributes<?, ?> partitionAttributes = region.getAttributes().getPartitionAttributes();
|
||||
|
||||
if (partitionAttributes != null) {
|
||||
|
||||
String regionName = region.getName();
|
||||
|
||||
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-number-of-buckets"), partitionAttributes.getTotalNumBuckets());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -168,23 +171,26 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
|
||||
return (region, builder) -> {
|
||||
|
||||
String regionName = region.getName();
|
||||
if (isRegionAttributesPresent(region)) {
|
||||
|
||||
Optional.of(region)
|
||||
.filter(this::isRegionAttributesPresent)
|
||||
.map(Region::getAttributes)
|
||||
.map(RegionAttributes::getEvictionAttributes)
|
||||
.ifPresent(evictionAttributes -> {
|
||||
EvictionAttributes evictionAttributes = region.getAttributes().getEvictionAttributes();
|
||||
|
||||
if (evictionAttributes != null) {
|
||||
|
||||
String regionName = region.getName();
|
||||
|
||||
builder.withDetail(cacheRegionEvictionKey(regionName, "action"), String.valueOf(evictionAttributes.getAction()))
|
||||
.withDetail(cacheRegionEvictionKey(regionName, "algorithm"), String.valueOf(evictionAttributes.getAlgorithm()));
|
||||
|
||||
// NOTE: Careful! Eviction Maximum does not apply when Eviction Algorithm is Heap LRU.
|
||||
Optional.ofNullable(evictionAttributes.getAlgorithm())
|
||||
.filter(it -> !it.isLRUHeap())
|
||||
.ifPresent(it -> builder
|
||||
.withDetail(cacheRegionEvictionKey(regionName,"maximum"), evictionAttributes.getMaximum()));
|
||||
});
|
||||
EvictionAlgorithm evictionAlgorithm = evictionAttributes.getAlgorithm();
|
||||
|
||||
// NOTE: Eviction Maximum does not apply when Eviction Algorithm is Heap LRU.
|
||||
if (evictionAlgorithm != null && !evictionAlgorithm.isLRUHeap()) {
|
||||
builder.withDetail(cacheRegionEvictionKey(regionName,"maximum"),
|
||||
evictionAttributes.getMaximum());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,23 +198,26 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
|
||||
return (region, builder) -> {
|
||||
|
||||
String regionName = region.getName();
|
||||
if (isRegionAttributesPresent(region)) {
|
||||
|
||||
Optional.of(region)
|
||||
.filter(this::isRegionAttributesPresent)
|
||||
.map(Region::getAttributes)
|
||||
.map(RegionAttributes::getEntryTimeToLive)
|
||||
.ifPresent(expirationAttributes -> builder
|
||||
.withDetail(cacheRegionExpirationKey(regionName, "entry.ttl.action"), String.valueOf(expirationAttributes.getAction()))
|
||||
.withDetail(cacheRegionExpirationKey(regionName, "entry.ttl.timeout"), expirationAttributes.getTimeout()));
|
||||
String regionName = region.getName();
|
||||
|
||||
Optional.of(region)
|
||||
.filter(this::isRegionAttributesPresent)
|
||||
.map(Region::getAttributes)
|
||||
.map(RegionAttributes::getEntryIdleTimeout)
|
||||
.ifPresent(expirationAttributes -> builder
|
||||
.withDetail(cacheRegionExpirationKey(regionName, "entry.tti.action"), String.valueOf(expirationAttributes.getAction()))
|
||||
.withDetail(cacheRegionExpirationKey(regionName, "entry.tti.timeout"), expirationAttributes.getTimeout()));
|
||||
RegionAttributes<?, ?> regionAttributes = region.getAttributes();
|
||||
|
||||
ExpirationAttributes entryTimeToLive = regionAttributes.getEntryTimeToLive();
|
||||
|
||||
if (entryTimeToLive != null) {
|
||||
builder.withDetail(cacheRegionExpirationKey(regionName, "entry.ttl.action"), String.valueOf(entryTimeToLive.getAction()))
|
||||
.withDetail(cacheRegionExpirationKey(regionName, "entry.ttl.timeout"), entryTimeToLive.getTimeout());
|
||||
}
|
||||
|
||||
ExpirationAttributes entryIdleTimeout = regionAttributes.getEntryIdleTimeout();
|
||||
|
||||
if (entryIdleTimeout != null) {
|
||||
builder.withDetail(cacheRegionExpirationKey(regionName, "entry.tti.action"), String.valueOf(entryIdleTimeout.getAction()))
|
||||
.withDetail(cacheRegionExpirationKey(regionName, "entry.tti.timeout"), entryIdleTimeout.getTimeout());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -241,18 +250,11 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
}
|
||||
|
||||
private boolean isRegionAttributesPresent(Region<?, ?> region) {
|
||||
|
||||
return Optional.ofNullable(region)
|
||||
.map(Region::getAttributes)
|
||||
.isPresent();
|
||||
return region != null && region.getAttributes() != null;
|
||||
}
|
||||
|
||||
private boolean isStatisticsEnabled(Region<?, ?> region) {
|
||||
|
||||
return Optional.ofNullable(region)
|
||||
.map(Region::getAttributes)
|
||||
.filter(RegionAttributes::getStatisticsEnabled)
|
||||
.isPresent();
|
||||
return isRegionAttributesPresent(region) && region.getAttributes().getStatisticsEnabled();
|
||||
}
|
||||
|
||||
private String cachePartitionRegionKey(String regionName, String suffix) {
|
||||
@@ -274,4 +276,8 @@ public class GeodeRegionsHealthIndicator extends AbstractGeodeHealthIndicator {
|
||||
private String cacheRegionStatisticsKey(String regionName, String suffix) {
|
||||
return cacheRegionKey(regionName, String.format("statistics.%s", suffix));
|
||||
}
|
||||
|
||||
private String emptyIfUnset(String value) {
|
||||
return StringUtils.hasText(value) ? value : "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.health.support;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -49,11 +48,11 @@ public class RegionStatisticsResolver {
|
||||
|
||||
public static CacheStatistics resolve(Region<?, ?> region) {
|
||||
|
||||
return Optional.ofNullable(region)
|
||||
.map(it -> PartitionRegionHelper.isPartitionedRegion(it)
|
||||
return region != null
|
||||
? PartitionRegionHelper.isPartitionedRegion(region)
|
||||
? new PartitionRegionCacheStatistics(region)
|
||||
: it.getStatistics())
|
||||
.orElse(null);
|
||||
: region.getStatistics()
|
||||
: null;
|
||||
}
|
||||
|
||||
protected static class PartitionRegionCacheStatistics implements CacheStatistics {
|
||||
|
||||
Reference in New Issue
Block a user