jdeppe-pivotal commented on a change in pull request #5954:
URL: https://github.com/apache/geode/pull/5954#discussion_r582967453



##########
File path: 
geode-redis/src/test/java/org/apache/geode/redis/internal/data/RedisHashTest.java
##########
@@ -42,6 +49,15 @@ public static void beforeClass() {
     InternalDataSerializer
         .getDSFIDSerializer()
         .registerDSFID(DataSerializableFixedID.REDIS_BYTE_ARRAY_WRAPPER, 
ByteArrayWrapper.class);
+    // setting expiration via system properties
+    System.setProperty("redis.hscan-snapshot-cleanup-interval", "500");
+    System.setProperty("redis.hscan-snapshot-expiry", "500");

Review comment:
       In general, system properties should be managed with a 
`RestoreSystemProperties` rule. Also, if possible, unit tests should avoid 
reliance on system properties. It really turns them into integration tests. I 
think your previous approach of having a test-only constructor, that took these 
parameters, was better and I think it would be cleaner to change to that model 
again.

##########
File path: 
geode-redis/src/main/java/org/apache/geode/redis/internal/data/RedisHash.java
##########
@@ -46,19 +52,68 @@
 public class RedisHash extends AbstractRedisData {
   public static final RedisHash NULL_REDIS_HASH = new NullRedisHash();
   private HashMap<ByteArrayWrapper, ByteArrayWrapper> hash;
+  private ConcurrentHashMap<UUID, List<ByteArrayWrapper>> hScanSnapShots;
+  private ConcurrentHashMap<UUID, Long> hScanSnapShotCreationTimes;
+  private ScheduledExecutorService HSCANSnapshotExpirationExecutor = null;
+  private final int HSCAN_SNAPSHOTS_EXPIRE_CHECK_FREQUENCY_MILLISECONDS;
+  private final int MINIMUM_MILLISECONDS_FOR_HSCAN_SNAPSHOTS_TO_LIVE;
+
+  // for serialization
+  public RedisHash() {
+    this.hash = new HashMap<>();
+    this.hScanSnapShots = new ConcurrentHashMap<>();
+    this.hScanSnapShotCreationTimes = new ConcurrentHashMap<>();
+
+    this.HSCAN_SNAPSHOTS_EXPIRE_CHECK_FREQUENCY_MILLISECONDS =
+        Integer.getInteger("redis.hscan-snapshot-cleanup-interval", 30000);
+
+    this.MINIMUM_MILLISECONDS_FOR_HSCAN_SNAPSHOTS_TO_LIVE =
+        Integer.getInteger("redis.hscan-snapshot-expiry", 30000);

Review comment:
       System properties like this should be set as `static final` instead of 
in the constructor since they are only intended to be set once for the life of 
the JVM. Also related is a comment in the associated test class.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to