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



##########
File path: 
geode-for-redis/src/main/java/org/apache/geode/redis/internal/pubsub/AbstractSubscriptionManager.java
##########
@@ -87,6 +90,18 @@ public int getSubscriptionCount() {
     return sum;
   }
 
+  public int getUniqueSubscriptionCount() {
+    Set<ByteBuffer> uniques = new HashSet<>();
+    for (ClientSubscriptionManager manager : clientManagers.values()) {
+      for (Subscription s : manager.getSubscriptions()) {
+        for (byte[] bytes : s.getClient().getPatternSubscriptions()) {
+          uniques.add(ByteBuffer.wrap(bytes).asReadOnlyBuffer());
+        }
+      }
+    }
+    return uniques.size();

Review comment:
       I don't know if it's necessarily better, but this can be simplified 
somewhat by using an `ObjectOpenCustomHashSet`:
   ```
       Set<byte[]> uniques = new 
ObjectOpenCustomHashSet<>(ByteArrays.HASH_STRATEGY);
       for (ClientSubscriptionManager manager : clientManagers.values()) {
         for (Subscription s : manager.getSubscriptions()) {
           uniques.addAll(s.getClient().getPatternSubscriptions());
         }
       }
       return uniques.size();
   ```

##########
File path: 
geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/AbstractUnknownIntegrationTest.java
##########
@@ -64,12 +64,6 @@ public void 
givenUnknownCommand_withEmptyStringArgument_returnsUnknownCommandErr
                 "ERR unknown command `fhqwhgads`, with args beginning with: 
`EVERYBODY`, ``, ");
   }
 
-  @Test // HELLO is not a recognized command until Redis 6.0.0
-  public void 
givenHelloCommand_returnsUnknownCommandErrorWithArgumentsListed() {
-    assertThatThrownBy(() -> jedis.sendCommand(() -> "HELLO".getBytes()))
-        .hasMessage("ERR unknown command `HELLO`, with args beginning with: ");
-  }
-

Review comment:
       Could a modified version of this test be moved to 
`UnknownIntegrationTest`? Removing it entirely loses us coverage of this 
behaviour, I think.

##########
File path: 
geode-for-redis/src/commonTest/java/org/apache/geode/redis/internal/proxy/RedisProxyInboundHandler.java
##########
@@ -129,6 +133,13 @@ public void channelRead(final ChannelHandlerContext ctx, 
Object msg) {
             outboundHandler.addResponseProcessor(nodesResponseProcessor);
           }
           break;
+        case "hello":
+          // Lettuce tries to use RESP 3 if possible but Netty's Redis codecs 
can't handle that yet.
+          // We implicitly fake the client into thinking this is an older 
Redis so that it uses
+          // RESP 2.
+          RedisMessage error = new ErrorRedisMessage("ERR unknown command");

Review comment:
       Should this error message follow the same format as other unknown 
command messages, namely
   ```
   String.format(ERROR_UNKNOWN_COMMAND, commandText, commandArguments)
   ``` 




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

To unsubscribe, e-mail: [email protected]

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


Reply via email to