You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2021/03/11 15:47:21 UTC
[geode] branch support/1.14 updated: GEODE-8859: Fix
redis-compatability data structure bucket memory-usage reporting
This is an automated email from the ASF dual-hosted git repository.
sabbey37 pushed a commit to branch support/1.14
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/support/1.14 by this push:
new 5f0ccf3 GEODE-8859: Fix redis-compatability data structure bucket memory-usage reporting
5f0ccf3 is described below
commit 5f0ccf3712a986eabea274ae973d8a20009d95f9
Author: John Hutchison <jh...@gmail.com>
AuthorDate: Thu Mar 11 10:46:11 2021 -0500
GEODE-8859: Fix redis-compatability data structure bucket memory-usage reporting
---
.../test/dunit/rules/RedisClusterStartupRule.java | 7 ++
.../data/PartitionedRegionStatsUpdateTest.java | 76 ++++++++++++++++++++++
.../geode/redis/internal/GeodeRedisServer.java | 8 +++
.../geode/redis/internal/GeodeRedisService.java | 6 ++
.../geode/redis/internal/data/RedisData.java | 4 ++
5 files changed, 101 insertions(+)
diff --git a/geode-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java b/geode-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java
index f4f6eab..787cc67 100644
--- a/geode-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java
+++ b/geode-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java
@@ -63,6 +63,13 @@ public class RedisClusterStartupRule extends ClusterStartupRule {
return getRedisPort(getMember(vmNumber));
}
+ public Long getDataStoreBytesInUseForDataRegion(MemberVM vm) {
+ return vm.invoke(() -> {
+ GeodeRedisService service = ClusterStartupRule.getCache().getService(GeodeRedisService.class);
+ return service.getDataStoreBytesInUseForDataRegion();
+ });
+ }
+
public int getRedisPort(MemberVM vm) {
return vm.invoke(() -> {
GeodeRedisService service = ClusterStartupRule.getCache().getService(GeodeRedisService.class);
diff --git a/geode-redis/src/distributedTest/java/org/apache/geode/redis/internal/data/PartitionedRegionStatsUpdateTest.java b/geode-redis/src/distributedTest/java/org/apache/geode/redis/internal/data/PartitionedRegionStatsUpdateTest.java
new file mode 100644
index 0000000..5c28fca
--- /dev/null
+++ b/geode-redis/src/distributedTest/java/org/apache/geode/redis/internal/data/PartitionedRegionStatsUpdateTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.redis.internal.data;
+
+import static org.apache.geode.distributed.ConfigurationProperties.MAX_WAIT_TIME_RECONNECT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+
+public class PartitionedRegionStatsUpdateTest {
+
+ @ClassRule
+ public static RedisClusterStartupRule clusterStartUpRule = new RedisClusterStartupRule(2);
+
+ private static MemberVM server1;
+ private static final String LOCAL_HOST = "127.0.0.1";
+ private static final int JEDIS_TIMEOUT =
+ Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
+
+ private static Jedis jedis1;
+
+ @BeforeClass
+ public static void classSetup() {
+ Properties locatorProperties = new Properties();
+ locatorProperties.setProperty(MAX_WAIT_TIME_RECONNECT, "15000");
+
+ MemberVM locator = clusterStartUpRule.startLocatorVM(0, locatorProperties);
+ int locatorPort = locator.getPort();
+
+ server1 = clusterStartUpRule.startRedisVM(1, locatorPort);
+ int redisServerPort1 = clusterStartUpRule.getRedisPort(1);
+
+ jedis1 = new Jedis(LOCAL_HOST, redisServerPort1, JEDIS_TIMEOUT);
+ }
+
+ @Test
+ public void should_showIncreaseInDatastoreBytesInUse_givenValueSizeIncreases() {
+ String KEY = "key";
+ String LONG_APPEND_VALUE = String.valueOf(Integer.MAX_VALUE);
+ jedis1.set(KEY, "value");
+
+ long initialDataStoreBytesInUse =
+ clusterStartUpRule.getDataStoreBytesInUseForDataRegion(server1);
+
+ for (int i = 0; i < 1000; i++) {
+ jedis1.append(KEY, LONG_APPEND_VALUE);
+ }
+
+ long finalDataStoreBytesInUse = clusterStartUpRule.getDataStoreBytesInUseForDataRegion(server1);
+ assertThat(initialDataStoreBytesInUse).isLessThan(finalDataStoreBytesInUse);
+ }
+}
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
index 06fa6d6..92449a2 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
@@ -23,6 +23,7 @@ import org.apache.geode.cache.Cache;
import org.apache.geode.cache.Region;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.PartitionedRegion;
import org.apache.geode.internal.statistics.StatisticsClock;
import org.apache.geode.internal.statistics.StatisticsClockFactory;
import org.apache.geode.logging.internal.executors.LoggingExecutors;
@@ -134,6 +135,13 @@ public class GeodeRedisServer {
return redisStats;
}
+ @VisibleForTesting
+ protected Long getDataStoreBytesInUseForDataRegion() {
+ PartitionedRegion dataRegion = (PartitionedRegion) this.getRegionProvider().getDataRegion();
+ long dataStoreBytesInUse = dataRegion.getPrStats().getDataStoreBytesInUse();
+ return dataStoreBytesInUse;
+ }
+
/**
* Precedence of the internal property overrides the global system property.
*/
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java
index 082cfd8..b6d3238 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisService.java
@@ -17,6 +17,7 @@ package org.apache.geode.redis.internal;
import org.apache.logging.log4j.Logger;
+import org.apache.geode.annotations.VisibleForTesting;
import org.apache.geode.cache.Cache;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.distributed.internal.ResourceEvent;
@@ -102,6 +103,11 @@ public class GeodeRedisService implements CacheService, ResourceEventsListener {
return redisServer.getPort();
}
+ @VisibleForTesting
+ public Long getDataStoreBytesInUseForDataRegion() {
+ return redisServer.getDataStoreBytesInUseForDataRegion();
+ }
+
public void setEnableUnsupported(boolean unsupported) {
redisServer.setAllowUnsupportedCommands(unsupported);
}
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/data/RedisData.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/data/RedisData.java
index 5e24051..c5ff8e4 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/data/RedisData.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/data/RedisData.java
@@ -60,4 +60,8 @@ public interface RedisData extends Delta, DataSerializable {
boolean rename(Region<ByteArrayWrapper, RedisData> region, ByteArrayWrapper oldKey,
ByteArrayWrapper newKey);
+ default boolean getForceRecalculateSize() {
+ return true;
+ }
+
}