Quick question(s) about binary vs. text mode
Thu, 12/01/2011 - 11:11
I've written a C++ client that successfully communicates via Membase in text mode, but I wish to convert it to binary. If I'm understanding things correctly, since my client is current not a vBucket aware client (more on that in a minute), I've been pointing to port 11211, which I believe is actually the Moxi server.
Here are my questions, in order of perceived difficulty:
- When testing binary mode without vBucket support, should I still connect on 11211 (which I presume is the Moxi server port?) If not, what port should I hit?
- Is it even possible to use the binary interface without vBucket support in the client?
- Where can I get more info on the actual hashing algorithm used to calculate a vBucket from a given key?
Thank you for your time!
1. When testing binary mode without vBucket support, should I still connect on 11211 (which I presume is the Moxy server port?) If not, what port should I hit?
memcached listens on port 11210 so connect to this port.
2. Is it even possible to use the binary interface without vBucket support in the client?
Yes, just put everything in vbucket 0. It is the clients responsibility to put things in the correct vbucket and Membase doesn't do any checks to make sure that the client is putting things in the right place. The one exception is in a multi-node cluster. In this scenario if you try to put a key in a vbucket that the server doesn't have then you will get a "not my vbucket" error.
3. Where can I get more info on the actual hashing algorithm used to calculate a vBucket from a given key?
You can actually use any hashing algorithm that you like in order to hash your keys. If you want to allow your client to be a smart client then you will have to read the hash algorithm type from the Membase config. You can get the config by doing
curl http://ipaddress:8091/pools/default/buckets/default
where default is the name of the bucket. Then grep for "hashAlgorithm"
Also check out this java code for some examples of the has algorithms we implement and how we implement them.
https://github.com/dustin/java-memcached-client/blob/master/src/main/jav...