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



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/RedisRestoreKeyExistsException.java
##########
@@ -17,7 +17,7 @@
 /**
  * An exception thrown when the key being restored already exists.
  */
-public class RedisRestoreKeyExistsException extends RuntimeException {
+public class RedisRestoreKeyExistsException extends RedisException {

Review comment:
       Very minor point, but might this class be better located in the 
`org.apache.geode.redis.internal.data` package?

##########
File path: 
geode-apis-compatible-with-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java
##########
@@ -154,4 +161,47 @@ public void enableDebugLogging(int vmId) {
       FastLogger.setDelegating(true);
     });
   }
+
+  /**
+   * Assuming a redundancy of 1, and at least 3 members, move the given key's 
primary bucket to a
+   * non-hosting member.
+   */
+  public DistributedMember moveBucketForKey(String key) {
+    return getMember(1).invoke("moveBucketForKey: " + key, () -> {
+      Region<RedisKey, RedisData> r = RedisClusterStartupRule.getCache()
+          .getRegion(RegionProvider.REDIS_DATA_REGION);
+
+      RedisKey redisKey = new RedisKey(key.getBytes());
+      DistributedMember primaryMember = 
PartitionRegionHelper.getPrimaryMemberForKey(r, redisKey);
+      Set<DistributedMember> allHosting = 
PartitionRegionHelper.getAllMembersForKey(r, redisKey);
+
+      // Returns all members, except the one calling.
+      Set<DistributedMember> allMembers = getCache().getMembers(r);
+      allMembers.add(getCache().getDistributedSystem().getDistributedMember());
+
+      allMembers.removeAll(allHosting);
+      DistributedMember targetMember = 
allMembers.stream().findFirst().orElseThrow(
+          () -> new IllegalStateException("No non-hosting member found for 
key: " + key));
+
+      PartitionRegionHelper.moveBucketByKey(r, primaryMember, targetMember, 
redisKey);
+
+      // Who is the primary now?
+      return PartitionRegionHelper.getPrimaryMemberForKey(r, redisKey);
+    });
+  }
+
+  public String getKeyOnServer(String keyPrefix, int vmId) {

Review comment:
       This method seems like it could use some documentation around its 
intended use, since it's not immediately clear how it's supposed to work.




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