You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/02/14 18:37:28 UTC

[GitHub] [geode] jdeppe-pivotal opened a new pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

jdeppe-pivotal opened a new pull request #7363:
URL: https://github.com/apache/geode/pull/7363


   - Geode for Redis statistics are broken up by category. For example
     stats will appear as `GeodeForRedisStats:STRING` or
     `GeodeForRedisStats:HASH`. Each type will then only contain stats
     relevant to the commands associated with that category.
   
   <!-- Thank you for submitting a contribution to Apache Geode. -->
   
   <!-- In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken: 
   -->
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   <!-- Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   -->
   


-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806268209



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();

Review comment:
       Same as above?




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806451743



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
##########
@@ -110,23 +108,7 @@ private static RedisStats createStats(InternalCache cache, String bindAddress, i
         StatisticsClockFactory.clock(true);
 
     return new RedisStats(statisticsClock,
-        new GeodeRedisStats(system.getStatisticsManager(), getServerName(bindAddress, port),
-            statisticsClock));
-  }
-
-  private static String getServerName(String bindAddress, int port) {
-    String name = "geodeForRedis:";
-    if (bindAddress != null && !bindAddress.isEmpty()) {
-      name += bindAddress;
-    } else {
-      try {
-        name += LocalHostUtil.getCanonicalLocalHostName();
-      } catch (UnknownHostException e) {
-        name += "*.*.*.*";
-      }
-    }
-    name += ':' + port;
-    return name;
+        new GeodeRedisStats(system.getStatisticsManager(), statisticsClock));

Review comment:
       Removed.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806264838



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);

Review comment:
       Seems like if I do that the `textId` just ends up being empty.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null

Review comment:
       Remove this ternary check.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null

Review comment:
       Removed this ternary check.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       I've moved the lookup outside the loop, however I'm still passing in `category` since that is used to do the lookup on which commands are in the category.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);
+      fillListWithTimeCommandDescriptors(statisticsTypeFactory, category, descriptors);
+
+      StatisticDescriptor[] descriptorsArray = descriptors.toArray(new StatisticDescriptor[0]);
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              descriptorsArray);
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);

Review comment:
       See my comment above. I'm not sure if you were thinking something else or I'm missing something.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();

Review comment:
       Yes, I wanted to, but since I also have this "General" category (which only exists to satisfy the stat naming and isn't a real Category) I opted to use String as the key. Perhaps you have a suggestion on how to do this better?

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();

Review comment:
       Same as above?

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);

Review comment:
       Good idea!

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);

Review comment:
       Yes!

##########
File path: geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/statistics/GeodeRedisStatsIntegrationTest.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.statistics;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import org.apache.geode.Statistics;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.statistics.StatisticsManager;
+import org.apache.geode.redis.GeodeRedisServerRule;
+import org.apache.geode.redis.internal.commands.RedisCommandType;
+
+public class GeodeRedisStatsIntegrationTest {
+
+  @ClassRule
+  public static GeodeRedisServerRule server = new GeodeRedisServerRule();
+
+  @Test
+  public void checkGeodeRedisStatsExist() {
+    Cache cache = CacheFactory.getAnyInstance();
+    InternalDistributedSystem internalSystem =
+        (InternalDistributedSystem) cache.getDistributedSystem();
+    StatisticsManager statisticsManager = internalSystem.getStatisticsManager();
+
+    List<String> statDescriptions = statisticsManager.getStatsList()
+        .stream().map(Statistics::getTextId).collect(Collectors.toList());
+
+    assertThat(statDescriptions).contains(GeodeRedisStats.STATS_BASENAME);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String name = GeodeRedisStats.STATS_BASENAME + ":" + category.name();
+      assertThat(statDescriptions).contains(name);
+    }

Review comment:
       What line 49 is doing or are you thinking something else?

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
##########
@@ -110,23 +108,7 @@ private static RedisStats createStats(InternalCache cache, String bindAddress, i
         StatisticsClockFactory.clock(true);
 
     return new RedisStats(statisticsClock,
-        new GeodeRedisStats(system.getStatisticsManager(), getServerName(bindAddress, port),
-            statisticsClock));
-  }
-
-  private static String getServerName(String bindAddress, int port) {
-    String name = "geodeForRedis:";
-    if (bindAddress != null && !bindAddress.isEmpty()) {
-      name += bindAddress;
-    } else {
-      try {
-        name += LocalHostUtil.getCanonicalLocalHostName();
-      } catch (UnknownHostException e) {
-        name += "*.*.*.*";
-      }
-    }
-    name += ':' + port;
-    return name;
+        new GeodeRedisStats(system.getStatisticsManager(), statisticsClock));

Review comment:
       Removed.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807440211



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();

Review comment:
       I opted to keep "General" separate and switch to an `EnumMap`.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807439676



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       Now passing in both category and type.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);
+      fillListWithTimeCommandDescriptors(statisticsTypeFactory, category, descriptors);
+
+      StatisticDescriptor[] descriptorsArray = descriptors.toArray(new StatisticDescriptor[0]);
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              descriptorsArray);
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);

Review comment:
       Done




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806162348



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);

Review comment:
       It looks to me like your textId you pass to createAtomicStatistics is now always the same as your StatisticType name. So instead of calling createAtomicStatistics(StatisticType, String) you should call createAtomicStatistics(StatisticType) which will end up using the name of the type as the textId.
   You would make this change here and on line 78.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();

Review comment:
       instead of using String as the key it seems like Category would be stronger and then you could use EnumMap instead of HashMap

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       or consider my other idea of just passing type in as a parameter

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);
+      fillListWithTimeCommandDescriptors(statisticsTypeFactory, category, descriptors);
+
+      StatisticDescriptor[] descriptorsArray = descriptors.toArray(new StatisticDescriptor[0]);
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              descriptorsArray);
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);

Review comment:
       consider just passing "type" in to these two fill methods instead of them turning around and looking it up.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();

Review comment:
       instead of using String as the key, Category would be stronger and then you could use EnumMap instead of HashMap

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null

Review comment:
       factory should not be null. If it is, it must be because of a test that did not mock getStatisticsManager() on InternalDistributedSystem.
   I think you should clean this method up to expect factory to not be null and fix any test that has incomplete mocking

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       Could the lookup of the type be moved outside the for loop and "category" used instead of "command.category"?

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);

Review comment:
       refactor this method to just return a StatisticDescriptor[] that it will create. Then the ugly ArrayList and toArray code can be in fillListWithCommandDescriptors. And give the method a better name like createGeneralStatisticsDescriptors

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);

Review comment:
       consider refactoring fillListWithCompletedCommandDescriptors and fillListWithTimeCommandDescriptors into "StatisticsDescriptor[] createCategoryStatisticsDescriptors(factory, category)". Then you can get rid of the ugly ArrayList and toArray at this level and the code the two fill methods have in common can no longer be duplicated. Foreach command you can call "StatisticDescriptor createTimeDescriptor(factory, name)" and "createCompletedDescriptor(factory, name)". This seems a little cleaner to me. 




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806266435



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       I've moved the lookup outside the loop, however I'm still passing in `category` since that is used to do the lookup on which commands are in the category.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807245028



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,279 +32,298 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats =
+        factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();

Review comment:
       you don't need to recreate "statName" here. It was already added as the name of the type. So when you call createAtomicStatistics just pass it the type and the lower levels will use the type's name as the statistics name.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,279 +32,298 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats =
+        factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats =
+          factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
-    ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
-
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
-
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
 
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
-            descriptorArray);
-
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+            createGeneralStatisticDescriptors(statisticsTypeFactory));
+
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              createCategoryStatisticDescriptors(statisticsTypeFactory, category));
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);
+      fillTimeIdMap(category);
+    }
   }
 
   private long getCurrentTimeNanos() {
     return clock.getTime();
   }
 
   public void endCommand(RedisCommandType command, long start) {
+    Statistics stat = statistics.get(command.category().name());
     if (clock.isEnabled()) {
-      stats.incLong(timeCommandStatIds.get(command), getCurrentTimeNanos() - start);
+      stat.incLong(timeCommandStatIds.get(command), getCurrentTimeNanos() - start);
     }
-    stats.incLong(completedCommandStatIds.get(command), 1);
+    stat.incLong(completedCommandStatIds.get(command), 1);
   }
 
   public void addClient() {
-    stats.incLong(currentlyConnectedClients, 1);
-    stats.incLong(totalConnectionsReceived, 1);
+    generalStats.incLong(currentlyConnectedClientsId, 1);
+    generalStats.incLong(totalConnectionsReceivedId, 1);
   }
 
   public void removeClient() {
-    stats.incLong(currentlyConnectedClients, -1);
+    generalStats.incLong(currentlyConnectedClientsId, -1);
   }
 
   public void endPassiveExpirationCheck(long start, long expireCount) {
     if (expireCount > 0) {
       incPassiveExpirations(expireCount);
     }
     if (clock.isEnabled()) {
-      stats.incLong(passiveExpirationCheckTimeId, getCurrentTimeNanos() - start);
+      generalStats.incLong(passiveExpirationCheckTimeId, getCurrentTimeNanos() - start);
     }
-    stats.incLong(passiveExpirationChecksId, 1);
+    generalStats.incLong(passiveExpirationChecksId, 1);
   }
 
   private void incPassiveExpirations(long count) {
-    stats.incLong(passiveExpirationsId, count);
+    generalStats.incLong(passiveExpirationsId, count);
   }
 
   public void endExpiration(long start) {
     if (clock.isEnabled()) {
-      stats.incLong(expirationTimeId, getCurrentTimeNanos() - start);
+      generalStats.incLong(expirationTimeId, getCurrentTimeNanos() - start);
     }
-    stats.incLong(expirationsId, 1);
+    generalStats.incLong(expirationsId, 1);
   }
 
   public void incrementCommandsProcessed() {
-    stats.incLong(commandsProcessed, 1);
+    generalStats.incLong(commandsProcessedId, 1);
   }
 
   public void incrementTotalNetworkBytesRead(long bytes) {
-    stats.incLong(totalNetworkBytesRead, bytes);
+    generalStats.incLong(totalNetworkBytesReadId, bytes);
   }
 
   public void incrementKeyspaceHits() {
-    stats.incLong(keyspaceHits, 1);
+    generalStats.incLong(keyspaceHitsId, 1);
   }
 
   public void incrementKeyspaceMisses() {
-    stats.incLong(keyspaceMisses, 1);
+    generalStats.incLong(keyspaceMissesId, 1);
   }
 
   public long startPublish() {
-    stats.incLong(publishRequestsInProgressId, 1);
+    generalStats.incLong(publishRequestsInProgressId, 1);
     return getCurrentTimeNanos();
   }
 
   public void endPublish(long publishCount, long time) {
-    stats.incLong(publishRequestsInProgressId, -publishCount);
-    stats.incLong(publishRequestsCompletedId, publishCount);
+    generalStats.incLong(publishRequestsInProgressId, -publishCount);
+    generalStats.incLong(publishRequestsCompletedId, publishCount);
     if (clock.isEnabled()) {
-      stats.incLong(publishRequestTimeId, time);
+      generalStats.incLong(publishRequestTimeId, time);
     }
   }
 
   public void changeSubscribers(long delta) {
-    stats.incLong(subscribersId, delta);
+    generalStats.incLong(subscribersId, delta);
   }
 
   public void changeUniqueChannelSubscriptions(long delta) {
-    stats.incLong(uniqueChannelSubscriptionsId, delta);
+    generalStats.incLong(uniqueChannelSubscriptionsId, delta);
   }
 
   public void changeUniquePatternSubscriptions(long delta) {
-    stats.incLong(uniquePatternSubscriptionsId, delta);
+    generalStats.incLong(uniquePatternSubscriptionsId, delta);
   }
 
   public void close() {
-    if (stats != null) {
-      stats.close();
+    if (generalStats != null) {

Review comment:
       this null check is not needed

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);
+      fillListWithTimeCommandDescriptors(statisticsTypeFactory, category, descriptors);
+
+      StatisticDescriptor[] descriptorsArray = descriptors.toArray(new StatisticDescriptor[0]);
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              descriptorsArray);
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);

Review comment:
       type is associated with category. So instead of just passing category in to fillCompletedIdMap and fillTimeIdMap also pass in type. Currently those fill methods turn around and lookup the type inside the for loop

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,279 +32,298 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats =
+        factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);

Review comment:
       given that most of the code directly references "generateStats" why do we need to also put it in the "statistics" map? You could do the same with the type "generalType" and then the map could be EnumMap




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806266948



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);
+      fillListWithTimeCommandDescriptors(statisticsTypeFactory, category, descriptors);
+
+      StatisticDescriptor[] descriptorsArray = descriptors.toArray(new StatisticDescriptor[0]);
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              descriptorsArray);
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);

Review comment:
       See my comment above. I'm not sure if you were thinking something else or I'm missing something.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807441145



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,279 +32,298 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats =
+        factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);

Review comment:
       Done




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] DonalEvans commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806271995



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
##########
@@ -110,23 +108,7 @@ private static RedisStats createStats(InternalCache cache, String bindAddress, i
         StatisticsClockFactory.clock(true);
 
     return new RedisStats(statisticsClock,
-        new GeodeRedisStats(system.getStatisticsManager(), getServerName(bindAddress, port),
-            statisticsClock));
-  }
-
-  private static String getServerName(String bindAddress, int port) {
-    String name = "geodeForRedis:";
-    if (bindAddress != null && !bindAddress.isEmpty()) {
-      name += bindAddress;
-    } else {
-      try {
-        name += LocalHostUtil.getCanonicalLocalHostName();
-      } catch (UnknownHostException e) {
-        name += "*.*.*.*";
-      }
-    }
-    name += ':' + port;
-    return name;
+        new GeodeRedisStats(system.getStatisticsManager(), statisticsClock));

Review comment:
       With these changes, the `bindAddress` and `port` arguments in the `createStats()` method are not used and can be removed.

##########
File path: geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/statistics/GeodeRedisStatsIntegrationTest.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.statistics;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import org.apache.geode.Statistics;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.statistics.StatisticsManager;
+import org.apache.geode.redis.GeodeRedisServerRule;
+import org.apache.geode.redis.internal.commands.RedisCommandType;
+
+public class GeodeRedisStatsIntegrationTest {
+
+  @ClassRule
+  public static GeodeRedisServerRule server = new GeodeRedisServerRule();
+
+  @Test
+  public void checkGeodeRedisStatsExist() {
+    Cache cache = CacheFactory.getAnyInstance();
+    InternalDistributedSystem internalSystem =
+        (InternalDistributedSystem) cache.getDistributedSystem();
+    StatisticsManager statisticsManager = internalSystem.getStatisticsManager();
+
+    List<String> statDescriptions = statisticsManager.getStatsList()
+        .stream().map(Statistics::getTextId).collect(Collectors.toList());
+
+    assertThat(statDescriptions).contains(GeodeRedisStats.STATS_BASENAME);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String name = GeodeRedisStats.STATS_BASENAME + ":" + category.name();
+      assertThat(statDescriptions).contains(name);
+    }

Review comment:
       Should this test also check for the presence of the "general" stat category?




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807213669



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);

Review comment:
       If you look all the down in StatisticsImpl line 131 you will find it handling a null textId by using the type's name: `this.textId = StringUtils.isEmpty(textId) ? statisticsManager.getName() : textId;`

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();

Review comment:
       It seems like you should either add General as a Category (does that cause other problems?) or keep the general one out of these maps. If you do the latter then you would just have a map for the category ones and you would have another instance variable that just directly references the general one. So in this example you would have "EnumMap<Category, StatisticsType> categoryTypes;" and "StatisticsType generalType".




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806265167



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null

Review comment:
       Remove this ternary check.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null

Review comment:
       Removed this ternary check.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806451052



##########
File path: geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/statistics/GeodeRedisStatsIntegrationTest.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.statistics;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import org.apache.geode.Statistics;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.statistics.StatisticsManager;
+import org.apache.geode.redis.GeodeRedisServerRule;
+import org.apache.geode.redis.internal.commands.RedisCommandType;
+
+public class GeodeRedisStatsIntegrationTest {
+
+  @ClassRule
+  public static GeodeRedisServerRule server = new GeodeRedisServerRule();
+
+  @Test
+  public void checkGeodeRedisStatsExist() {
+    Cache cache = CacheFactory.getAnyInstance();
+    InternalDistributedSystem internalSystem =
+        (InternalDistributedSystem) cache.getDistributedSystem();
+    StatisticsManager statisticsManager = internalSystem.getStatisticsManager();
+
+    List<String> statDescriptions = statisticsManager.getStatsList()
+        .stream().map(Statistics::getTextId).collect(Collectors.toList());
+
+    assertThat(statDescriptions).contains(GeodeRedisStats.STATS_BASENAME);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String name = GeodeRedisStats.STATS_BASENAME + ":" + category.name();
+      assertThat(statDescriptions).contains(name);
+    }

Review comment:
       What line 49 is doing or are you thinking something else?




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806267991



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();

Review comment:
       Yes, I wanted to, but since I also have this "General" category (which only exists to satisfy the stat naming and isn't a real Category) I opted to use String as the key. Perhaps you have a suggestion on how to do this better?




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806264838



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);

Review comment:
       Seems like if I do that the `textId` just ends up being empty.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807439472



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);

Review comment:
       With some additional refactoring, I think this is sorted out now.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r807440295



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();

Review comment:
       Done




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806268362



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);

Review comment:
       Good idea!

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);

Review comment:
       Yes!




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806162348



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);

Review comment:
       It looks to me like your textId you pass to createAtomicStatistics is now always the same as your StatisticType name. So instead of calling createAtomicStatistics(StatisticType, String) you should call createAtomicStatistics(StatisticType) which will end up using the name of the type as the textId.
   You would make this change here and on line 78.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();

Review comment:
       instead of using String as the key it seems like Category would be stronger and then you could use EnumMap instead of HashMap

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       or consider my other idea of just passing type in as a parameter

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);
+      fillListWithTimeCommandDescriptors(statisticsTypeFactory, category, descriptors);
+
+      StatisticDescriptor[] descriptorsArray = descriptors.toArray(new StatisticDescriptor[0]);
+      StatisticsType type = statisticsTypeFactory
+          .createType(STATS_BASENAME + ":" + category.name(),
+              category.name() + " statistics for a geode-for-redis server",
+              descriptorsArray);
+      statisticTypes.put(category.name(), type);
+
+      fillCompletedIdMap(category);

Review comment:
       consider just passing "type" in to these two fill methods instead of them turning around and looking it up.

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();

Review comment:
       instead of using String as the key, Category would be stronger and then you could use EnumMap instead of HashMap

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null

Review comment:
       factory should not be null. If it is, it must be because of a test that did not mock getStatisticsManager() on InternalDistributedSystem.
   I think you should clean this method up to expect factory to not be null and fix any test that has incomplete mocking

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -218,12 +248,21 @@ private static void fillListWithCompletedCommandDescriptors(StatisticsTypeFactor
     }
   }
 
-  private static void fillCompletedIdMap() {
-    for (RedisCommandType command : RedisCommandType.values()) {
+  private static void fillCompletedIdMap(RedisCommandType.Category category) {
+    for (RedisCommandType command : RedisCommandType.getCommandsForCategory(category)) {
       String name = command.name().toLowerCase();
       String statName = name + "Completed";
+      completedCommandStatIds.put(command,
+          statisticTypes.get(command.category().name()).nameToId(statName));

Review comment:
       Could the lookup of the type be moved outside the for loop and "category" used instead of "command.category"?

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);

Review comment:
       refactor this method to just return a StatisticDescriptor[] that it will create. Then the ugly ArrayList and toArray code can be in fillListWithCommandDescriptors. And give the method a better name like createGeneralStatisticsDescriptors

##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/GeodeRedisStats.java
##########
@@ -30,170 +32,197 @@
 import org.apache.geode.redis.internal.commands.RedisCommandType;
 
 public class GeodeRedisStats {
+
+  public static final String STATS_BASENAME = "GeodeForRedisStats";
+  private static final String GENERAL_CATEGORY = "General";
+
   @Immutable
-  private static final StatisticsType type;
+  private static final Map<String, StatisticsType> statisticTypes = new HashMap<>();
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> completedCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
   @Immutable
   private static final EnumMap<RedisCommandType, Integer> timeCommandStatIds =
       new EnumMap<>(RedisCommandType.class);
 
-  private static final int currentlyConnectedClients;
+  private static final int currentlyConnectedClientsId;
   private static final int passiveExpirationChecksId;
   private static final int passiveExpirationCheckTimeId;
   private static final int passiveExpirationsId;
   private static final int expirationsId;
   private static final int expirationTimeId;
-  private static final int totalConnectionsReceived;
-  private static final int commandsProcessed;
-  private static final int keyspaceHits;
-  private static final int keyspaceMisses;
-  private static final int totalNetworkBytesRead;
+  private static final int totalConnectionsReceivedId;
+  private static final int commandsProcessedId;
+  private static final int keyspaceHitsId;
+  private static final int keyspaceMissesId;
+  private static final int totalNetworkBytesReadId;
   private static final int publishRequestsCompletedId;
   private static final int publishRequestsInProgressId;
   private static final int publishRequestTimeId;
   private static final int subscribersId;
   private static final int uniqueChannelSubscriptionsId;
   private static final int uniquePatternSubscriptionsId;
-  private final Statistics stats;
+  private final Statistics generalStats;
+  private final Map<String, Statistics> statistics = new HashMap<>();
   private final StatisticsClock clock;
 
-  public GeodeRedisStats(StatisticsFactory factory, String name, StatisticsClock clock) {
+  public GeodeRedisStats(StatisticsFactory factory, StatisticsClock clock) {
     this.clock = clock;
-    stats = factory == null ? null : factory.createAtomicStatistics(type, name);
+    generalStats = factory == null ? null
+        : factory.createAtomicStatistics(statisticTypes.get(GENERAL_CATEGORY), STATS_BASENAME);
+    statistics.put(GENERAL_CATEGORY, generalStats);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String statName = STATS_BASENAME + ":" + category.name();
+      Statistics stats = factory == null ? null
+          : factory.createAtomicStatistics(statisticTypes.get(category.name()), statName);
+      statistics.put(category.name(), stats);
+    }
   }
 
   static {
     StatisticsTypeFactory statisticsTypeFactory = StatisticsTypeFactoryImpl.singleton();
     ArrayList<StatisticDescriptor> descriptorList = new ArrayList<>();
 
-    fillListWithCompletedCommandDescriptors(statisticsTypeFactory, descriptorList);
-    fillListWithTimeCommandDescriptors(statisticsTypeFactory, descriptorList);
     fillListWithCommandDescriptors(statisticsTypeFactory, descriptorList);
+    StatisticDescriptor[] descriptorArray = descriptorList.toArray(new StatisticDescriptor[0]);
 
-    StatisticDescriptor[] descriptorArray =
-        descriptorList.toArray(new StatisticDescriptor[0]);
-
-    type = statisticsTypeFactory
-        .createType("GeodeForRedisStats",
+    StatisticsType generalType = statisticsTypeFactory
+        .createType(STATS_BASENAME,
             "Statistics for a geode-for-redis server",
             descriptorArray);
 
-    fillCompletedIdMap();
-    fillTimeIdMap();
-
-    currentlyConnectedClients = type.nameToId("connectedClients");
-    passiveExpirationChecksId = type.nameToId("passiveExpirationChecks");
-    passiveExpirationCheckTimeId = type.nameToId("passiveExpirationCheckTime");
-    passiveExpirationsId = type.nameToId("passiveExpirations");
-    expirationsId = type.nameToId("expirations");
-    expirationTimeId = type.nameToId("expirationTime");
-    totalConnectionsReceived = type.nameToId("totalConnectionsReceived");
-    commandsProcessed = type.nameToId("commandsProcessed");
-    totalNetworkBytesRead = type.nameToId("totalNetworkBytesRead");
-    keyspaceHits = type.nameToId("keyspaceHits");
-    keyspaceMisses = type.nameToId("keyspaceMisses");
-    publishRequestsCompletedId = type.nameToId("publishRequestsCompleted");
-    publishRequestsInProgressId = type.nameToId("publishRequestsInProgress");
-    publishRequestTimeId = type.nameToId("publishRequestTime");
-    subscribersId = type.nameToId("subscribers");
-    uniqueChannelSubscriptionsId = type.nameToId("uniqueChannelSubscriptions");
-    uniquePatternSubscriptionsId = type.nameToId("uniquePatternSubscriptions");
+    currentlyConnectedClientsId = generalType.nameToId("connectedClients");
+    passiveExpirationChecksId = generalType.nameToId("passiveExpirationChecks");
+    passiveExpirationCheckTimeId = generalType.nameToId("passiveExpirationCheckTime");
+    passiveExpirationsId = generalType.nameToId("passiveExpirations");
+    expirationsId = generalType.nameToId("expirations");
+    expirationTimeId = generalType.nameToId("expirationTime");
+    totalConnectionsReceivedId = generalType.nameToId("totalConnectionsReceived");
+    commandsProcessedId = generalType.nameToId("commandsProcessed");
+    totalNetworkBytesReadId = generalType.nameToId("totalNetworkBytesRead");
+    keyspaceHitsId = generalType.nameToId("keyspaceHits");
+    keyspaceMissesId = generalType.nameToId("keyspaceMisses");
+    publishRequestsCompletedId = generalType.nameToId("publishRequestsCompleted");
+    publishRequestsInProgressId = generalType.nameToId("publishRequestsInProgress");
+    publishRequestTimeId = generalType.nameToId("publishRequestTime");
+    subscribersId = generalType.nameToId("subscribers");
+    uniqueChannelSubscriptionsId = generalType.nameToId("uniqueChannelSubscriptions");
+    uniquePatternSubscriptionsId = generalType.nameToId("uniquePatternSubscriptions");
+
+    statisticTypes.put(GENERAL_CATEGORY, generalType);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      ArrayList<StatisticDescriptor> descriptors = new ArrayList<>();
+      fillListWithCompletedCommandDescriptors(statisticsTypeFactory, category, descriptors);

Review comment:
       consider refactoring fillListWithCompletedCommandDescriptors and fillListWithTimeCommandDescriptors into "StatisticsDescriptor[] createCategoryStatisticsDescriptors(factory, category)". Then you can get rid of the ugly ArrayList and toArray at this level and the code the two fill methods have in common can no longer be duplicated. Foreach command you can call "StatisticDescriptor createTimeDescriptor(factory, name)" and "createCompletedDescriptor(factory, name)". This seems a little cleaner to me. 




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] DonalEvans commented on a change in pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #7363:
URL: https://github.com/apache/geode/pull/7363#discussion_r806271995



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
##########
@@ -110,23 +108,7 @@ private static RedisStats createStats(InternalCache cache, String bindAddress, i
         StatisticsClockFactory.clock(true);
 
     return new RedisStats(statisticsClock,
-        new GeodeRedisStats(system.getStatisticsManager(), getServerName(bindAddress, port),
-            statisticsClock));
-  }
-
-  private static String getServerName(String bindAddress, int port) {
-    String name = "geodeForRedis:";
-    if (bindAddress != null && !bindAddress.isEmpty()) {
-      name += bindAddress;
-    } else {
-      try {
-        name += LocalHostUtil.getCanonicalLocalHostName();
-      } catch (UnknownHostException e) {
-        name += "*.*.*.*";
-      }
-    }
-    name += ':' + port;
-    return name;
+        new GeodeRedisStats(system.getStatisticsManager(), statisticsClock));

Review comment:
       With these changes, the `bindAddress` and `port` arguments in the `createStats()` method are not used and can be removed.

##########
File path: geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/statistics/GeodeRedisStatsIntegrationTest.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.statistics;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import org.apache.geode.Statistics;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.statistics.StatisticsManager;
+import org.apache.geode.redis.GeodeRedisServerRule;
+import org.apache.geode.redis.internal.commands.RedisCommandType;
+
+public class GeodeRedisStatsIntegrationTest {
+
+  @ClassRule
+  public static GeodeRedisServerRule server = new GeodeRedisServerRule();
+
+  @Test
+  public void checkGeodeRedisStatsExist() {
+    Cache cache = CacheFactory.getAnyInstance();
+    InternalDistributedSystem internalSystem =
+        (InternalDistributedSystem) cache.getDistributedSystem();
+    StatisticsManager statisticsManager = internalSystem.getStatisticsManager();
+
+    List<String> statDescriptions = statisticsManager.getStatsList()
+        .stream().map(Statistics::getTextId).collect(Collectors.toList());
+
+    assertThat(statDescriptions).contains(GeodeRedisStats.STATS_BASENAME);
+
+    for (RedisCommandType.Category category : RedisCommandType.Category.values()) {
+      String name = GeodeRedisStats.STATS_BASENAME + ":" + category.name();
+      assertThat(statDescriptions).contains(name);
+    }

Review comment:
       Should this test also check for the presence of the "general" stat category?




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal merged pull request #7363: GEODE-10034: Organize Geode For Redis Stats By Category

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal merged pull request #7363:
URL: https://github.com/apache/geode/pull/7363


   


-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org