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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]