DonalEvans commented on a change in pull request #7080:
URL: https://github.com/apache/geode/pull/7080#discussion_r743225208



##########
File path: 
geode-for-redis/src/main/java/org/apache/geode/redis/internal/netty/ByteToCommandDecoder.java
##########
@@ -51,16 +53,16 @@
 public class ByteToCommandDecoder extends ByteToMessageDecoder {
 
   public static final String UNAUTHENTICATED_MAX_ARRAY_SIZE_PARAM =
-      "gemfire.geode-for-redis-unauthenticated-max-array-size";
+      RedisProperties.UNAUTHENTICATED_MAX_ARRAY_SIZE;
   public static final String UNAUTHENTICATED_MAX_BULK_STRING_LENGTH_PARAM =
-      "gemfire.geode-for-redis-unauthenticated-max-bulk-string-length";
+      RedisProperties.UNAUTHENTICATED_MAX_BULK_STRING_LENGTH;
 
   private static final int MAX_BULK_STRING_LENGTH = 512 * 1024 * 1024; // 512 
MB
   // These 2 defaults are taken from native Redis
   public static final int UNAUTHENTICATED_MAX_ARRAY_SIZE =
-      Integer.getInteger(UNAUTHENTICATED_MAX_ARRAY_SIZE_PARAM, 10);
+      getIntegerSystemProperty(UNAUTHENTICATED_MAX_ARRAY_SIZE_PARAM, 10, 1);
   public static final int UNAUTHENTICATED_MAX_BULK_STRING_LENGTH =
-      Integer.getInteger(UNAUTHENTICATED_MAX_BULK_STRING_LENGTH_PARAM, 16384);
+      getIntegerSystemProperty(UNAUTHENTICATED_MAX_BULK_STRING_LENGTH_PARAM, 
16384, 1);

Review comment:
       Could `UNAUTHENTICATED_MAX_ARRAY_SIZE_PARAM` and 
`UNAUTHENTICATED_MAX_BULK_STRING_LENGTH_PARAM` be replaced directly with 
`UNAUTHENTICATED_MAX_ARRAY_SIZE` and `UNAUTHENTICATED_MAX_BULK_STRING_LENGTH`? 
Having the same constant duplicated in two classes seems unnecessary.

##########
File path: 
geode-for-redis/src/main/java/org/apache/geode/redis/internal/RedisProperties.java
##########
@@ -16,38 +16,90 @@
 package org.apache.geode.redis.internal;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.logging.internal.log4j.api.LogService;
 
 public class RedisProperties {
-  /** System Property Names **/
-  public static final String REDIS_REGION_NAME_PROPERTY = 
"geode-for-redis-region-name";
-  public static final String WRITE_TIMEOUT_SECONDS = 
"geode-for-redis-write-timeout-seconds";
-  public static final String EXPIRATION_INTERVAL_SECONDS =
-      "geode-for-redis-expiration-interval-seconds";
+  private static final Logger logger = LogService.getLogger();
+
+  private static final String PREFIX = "geode.geode-for-redis-";
+  public static final String REDIS_REGION_NAME_PROPERTY = PREFIX + 
"region-name";
+  public static final String WRITE_TIMEOUT_SECONDS = PREFIX + 
"write-timeout-seconds";
+  public static final String EXPIRATION_INTERVAL_SECONDS = PREFIX + 
"expiration-interval-seconds";
+  public static final String REGION_BUCKETS = PREFIX + "region-buckets";
+  public static final String UNAUTHENTICATED_MAX_ARRAY_SIZE =
+      PREFIX + "unauthenticated-max-array-size";
+  public static final String UNAUTHENTICATED_MAX_BULK_STRING_LENGTH =
+      PREFIX + "unauthenticated-max-bulk-string-length";
+
+
+  private static String convertToGemfire(String geodeName) {
+    return "gemfire." + geodeName.substring("geode.".length());
+  }
+
+  private static void validatePropertyName(String geodeName) {
+    if (!geodeName.startsWith(PREFIX)) {
+      throw new IllegalStateException("Property names must start with \"" + 
PREFIX + "\"");
+    }
+  }
 
   public static String getStringSystemProperty(String propName, String 
defaultValue) {
-    String geodeValue = System.getProperty("geode." + propName, defaultValue);
-    String gemfireValue = System.getProperty("gemfire." + propName, 
defaultValue);
+    validatePropertyName(propName);
 
+    String geodeValue = System.getProperty(propName, defaultValue);
     if (StringUtils.isNotEmpty(geodeValue) && 
!geodeValue.equals(defaultValue)) {

Review comment:
       Do we actually need to check if the value here is equal the the default? 
If the property exists, we should just return it; checking if it's equal to the 
default just results in extra work and the same outcome in the end. This 
comment also applies to the check on line 56.




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to