Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finagle-redis: Redis cluster management #645

Closed
wants to merge 17 commits into from

Conversation

mkhq
Copy link
Contributor

@mkhq mkhq commented Aug 17, 2017

Problem

The current finagle-redis client does not have support for the CLUSTER commands introduced in Redis 3.0.0.

Solution

This adds support for a number of new cluster commands that are necessary to setup and manage a redis cluster.

  • CLUSTER ADDSLOT, assigns a storage slot to a server
  • CLUSTER SETSLOT, updates the state of a slot
  • CLUSTER SLOTS, returns a list of slots known to the server
  • CLUSTER GETKEYSINSLOT, returns keys stored in a slot
  • CLUSTER REPLICATE, changes a node to become a replica of a server
  • CLUSTER MEET, introduces cluster nodes to each other
  • CLUSTER NODES, returns the list of cluster nodes known to the server
  • CLUSTER INFO, returns the cluster specific info
  • MIGRATE, used to transfer keys to another node

Result

Using the introduced commands it is possible to setup a redis cluster for testing and live re-sharding. This is the first step in implementing the redis cluster client protocol. The next step is to handle operation redirects, i.e. when the server returns ASK or MOVED.

Problem

Unit tests and integration tests are mixed in the finagle-redis project
under the test path. In addition, the SBT configuration is only running
unit tests. This solves issue twitter#360.

Solution

Added configuration for IntegrationTest in the finagle-redis project
and moved integration tests to the correct path. Redis process shutdown
always includes all processes.

Result

Running 'test' only executes unit tests. Running 'it:test' executes the
integration tests.
Problem

Unit tests and integration tests are mixed in the finagle-redis project
under the test path. In addition, the SBT configuration is only running
unit tests. This solves issue twitter#360.

Solution

Added configuration for IntegrationTest in the finagle-redis project
and moved integration tests to the correct path. Redis process shutdown
always includes all processes.

Result

Running 'test' only executes unit tests. Running 'it:test' executes the
integration tests.
- New commands: MIGRATE, SETSLOT, GETKEYSINSLOT
@mkhq
Copy link
Contributor Author

mkhq commented Aug 17, 2017

Note that this PR includes #642

@mkhq mkhq changed the title Redis cluster Redis cluster management Aug 17, 2017
@codecov-io
Copy link

Codecov Report

Merging #645 into develop will decrease coverage by 0.27%.
The diff coverage is 6.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #645      +/-   ##
===========================================
- Coverage    67.46%   67.18%   -0.28%     
===========================================
  Files          644      647       +3     
  Lines        21843    21937      +94     
  Branches      1689     1672      -17     
===========================================
+ Hits         14736    14738       +2     
- Misses        7107     7199      +92
Impacted Files Coverage Δ
.../scala/com/twitter/finagle/redis/KeyCommands.scala 0% <0%> (ø) ⬆️
...la/com/twitter/finagle/redis/util/TestServer.scala 0% <0%> (ø) ⬆️
...tter/finagle/redis/protocol/commands/Cluster.scala 0% <0%> (ø)
...la/com/twitter/finagle/redis/ClusterCommands.scala 0% <0%> (ø)
...cala/com/twitter/finagle/redis/ClusterClient.scala 0% <0%> (ø)
...a/com/twitter/finagle/redis/protocol/Command.scala 100% <100%> (ø) ⬆️
...twitter/finagle/redis/protocol/commands/Keys.scala 100% <100%> (ø) ⬆️
...a/com/twitter/finagle/http2/Http2Transporter.scala 72.72% <0%> (-7.58%) ⬇️
...rc/main/scala/com/twitter/finagle/mux/Server.scala 91.36% <0%> (-2.16%) ⬇️
...la/com/twitter/finagle/netty3/Netty3Listener.scala 89.39% <0%> (-0.76%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 796eca1...7384132. Read the comment docs.

@mkhq mkhq changed the title Redis cluster management finagle-redis: Redis cluster management Aug 25, 2017
@bryce-anderson
Copy link
Contributor

Looks good to me, but this is honestly the first time I've looked at redis technology so I'm far from an expert. If we can get another set of eyes or two, I think it's ready to go. Ping @vkostyukov, who I believe knows more than I do about this protocol implementation.

@mosesn mosesn self-assigned this Oct 16, 2017
Copy link
Contributor

@vkostyukov vkostyukov left a comment

Choose a reason for hiding this comment

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

That looks reasonable to me (assuming it's just wires in a support for cluster commands). I'd probably vote on making ClsuterClient private until we ship all the required machinery to make it a "cluster" client.

}

// jump past the '\r\n'
reader.skip(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we know \n follows \r? I don't see a check for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its an assumption from the protocol: https://redis.io/topics/protocol#bulk-string-reply

@mkhq
Copy link
Contributor Author

mkhq commented Nov 3, 2017

@vkostyukov Thanks for the review! I'll fix the visibility of ClusterClient.

In the meantime I've been working on another PR for transparently handling cluster slot redirect and management. Will try to submit soonish.

@bryce-anderson
Copy link
Contributor

@mkhq, perhaps you're already going to do this, but it would be helpful if you could rebase+squash the PR when you push the commit for visibility. (It makes it easier to merge internally, but its not a show stopper)

@CLAassistant
Copy link

CLAassistant commented Dec 19, 2017

CLA assistant check
All committers have signed the CLA.

@mkhq
Copy link
Contributor Author

mkhq commented Dec 19, 2017

@bryce-anderson Hey, I already merged in develop in the branch so rebase+squash would be a bit of a mess. Should I create a new branch/PR?

@mkhq
Copy link
Contributor Author

mkhq commented Jan 9, 2018

Ping @mosesn

@mosesn
Copy link
Contributor

mosesn commented Jan 9, 2018

@mkhq yeah, a new branch/PR would be great, if you can. Sorry for the delay!

@mkhq
Copy link
Contributor Author

mkhq commented Jan 12, 2018

@mosesn Replaced by #668

@bryce-anderson
Copy link
Contributor

@mkhq, I'm really sorry I didn't see your previous ping: a lot of things got lost in my inbox during that time period.

@mkhq
Copy link
Contributor Author

mkhq commented Jan 12, 2018

@bryce-anderson no worries :) I didnt have time to fix it until now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants