Skip to content

GEODE-9585: adding support for the KEYSLOT command - #6847

Merged
upthewaterspout merged 7 commits into
apache:developfrom
upthewaterspout:feature/support-cluster-keyslots-GEODE-9585
Sep 13, 2021
Merged

GEODE-9585: adding support for the KEYSLOT command#6847
upthewaterspout merged 7 commits into
apache:developfrom
upthewaterspout:feature/support-cluster-keyslots-GEODE-9585

Conversation

@upthewaterspout

Copy link
Copy Markdown
Contributor

Adding support for the keyslot command. refactoring the RedisKey code a little
bit to move the slot calculation into a static method that can be used and
tested separately. Changing RedisKey.crc16 to slot, because that is only thing
we are using the crc16 field for.

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?

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.

Adding support for the keyslot command. refactoring the RedisKey code a little
bit to move the slot calculation into a static method that can be used and
tested separately. Changing RedisKey.crc16 to slot, because that is only thing
we are using the crc16 field for.
@upthewaterspout
upthewaterspout marked this pull request as draft September 8, 2021 17:20
@jdeppe-pivotal jdeppe-pivotal added the redis Issues related to the geode-for-redis module label Sep 8, 2021
Fixing the argument parsing to return the correct error for different cluster
subcommands, and adding additional tests for argument parsing and results from
CLUSTER KEYSLOT
@upthewaterspout
upthewaterspout marked this pull request as ready for review September 9, 2021 04:05
/**
* Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
*/
public class KeyHashUtil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a unit test for KeyHashUtil would be valuable and pretty easy to write.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new test. This code was previously covered by the RedisKey unit test. I moved that testing into KeyHashUtilTest and added more coverage.

upthewaterspout and others added 5 commits September 9, 2021 14:15
Changing the implementation of slotForKey to more closely mirror the logic of
the native redis keyHashSlot method. This reproduces the same behavior as
native redis with malformed hashtags with unmatched parens.

Moving hashing until test from RedisKeyTest to KeyHashUtilTest. Adding more
test cases including a junit quick check case, that catch the problem that
Darrel pointed out with mismatched parens.

Applying additional review comments.
Removing an unneeded comment and assertion
Co-authored-by: Eric Zoerner <zoernere@vmware.com>
@upthewaterspout

Copy link
Copy Markdown
Contributor Author

@ezoerner - added the randomized integration test.

* byte identifier of a bulk string
*/
public static final byte BULK_STRING_ID = 36; // '$'
public static final byte BULK_STRING_ID = '$';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a java character literal's ordinal value stable? Or can it change based on the locale? If you know the answer can you send a link?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only link I have is the java language spec - https://docs.oracle.com/javase/specs/jls/se16/html/jls-3.html#jls-3.10.4. The character literals are UTF-16.

@upthewaterspout
upthewaterspout merged commit d0c734f into apache:develop Sep 13, 2021
@upthewaterspout
upthewaterspout deleted the feature/support-cluster-keyslots-GEODE-9585 branch September 13, 2021 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

redis Issues related to the geode-for-redis module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants