Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Membase | Membase Server 1.7.x

Using Moxi and vBucket

6 replies [Last post]
  • Login or register to post comments
Thu, 10/06/2011 - 11:30
abhihome
Offline
Joined: 03/14/2011
Groups: None

Hi,

I am using spymemcached-2.7.jar, which is vBucket aware client.

Here is my code

URI base = new URI("http://<membase-server-ip>:8091/pools");
ArrayList baseURIs = new ArrayList();
baseURIs.add(base);
MemcachedClient c = new MemcachedClient(baseURIs, "bucket1", "");

I wish to use the moxi as the base url instead of the actual membase server, because, that will help me adding a new membase servers to the cluster without changing this code, or a config file & without restarting application servers.

I tried
URI base = new URI("http://localhost:11211/pools"); and installed moxi on the client machine.

But it doesn't work. It didn't give any error, it just wait in order to get connected.

What am I doing wrong? Please help.

Thanks
Abhilash

Top
  • Login or register to post comments
Fri, 10/07/2011 - 11:00
alex
Offline
Joined: 08/29/2011
Groups: None

Hi Abhilash,

Is your local Moxi configured to talk to the cluster?
http://www.couchbase.org/wiki/display/membase/Standalone+Moxi+Component#...

If not, that may be why you're not seeing anything.

Also, the Membase server itself runs a instance of moxi, I would configure your code to point at 2 membase server IP's and you'll get the same functionality along with reduced network hops.

hope this helps

-Alex.

Top
  • Login or register to post comments
Mon, 10/10/2011 - 09:32
abhihome
Offline
Joined: 03/14/2011
Groups: None

Thanks Alex.

Yes, my local moxi is configured to talk to the cluster.

/opt/moxi/bin/moxi -u membase -d http://<membase-server-ip>:8091/pools/default/bucketsStreaming/bucket1

and I have created bucket1 via Admin console.

Should I use a different MemcachedClient constructor to work with Moxi & vBucket?

The only reason, why I am trying to do it with Moxi is that, I need not change the code when I add a new membase server, and I need not change this code to work with different development environments.

Thanks
Abhilash

Top
  • Login or register to post comments
Mon, 10/10/2011 - 10:46
mikew
Offline
Joined: 03/14/2011
Groups:

First off, the following will not work correctly:

URI base = new URI("http://localhost:11211/pools");

The reason that you use port 8091 is that it's the cluster management port. Spymemcached will connect to this port and get the cluster configuration. So if you put one URI into the Spymemcached constructor then Spymemcached will actually connect to all of the nodes in the cluster. Let's say that later you add another server to your cluster. Since Spymemcached is connected to the cluster management port it will receive an updated configuration from the cluster and immediately begin sending requests to the new server. I will give instruction on how to connect to moxi with Symemcached below, but I think what you really want to do is do things the way that you are currently doing them because it will give you the lowest latency requests and Spymemcached will react to any type of topology change in the cluster.

Connecting to moxi:

In order to do this you should use the constructor that takes a list of InetSocketAddresses. This constructor will allow you to connect directly to moxi, but be aware that if you do this you are really just creating more work for yourself. Spymemcached already has all of the moxi capabilities built into it and we highly recommend using the constructor that takes a list of URI's.

Top
  • Login or register to post comments
Tue, 10/11/2011 - 12:27
abhihome
Offline
Joined: 03/14/2011
Groups: None

Thanks Mike, make sense.

Top
  • Login or register to post comments
Tue, 10/11/2011 - 17:08
abhihome
Offline
Joined: 03/14/2011
Groups: None

One another question related to this.

What is the benefit of creating multiple "buckets", and associating MemcachedClient's to each "bucket" as opposed to using "default" bucket for all MemcachedClients?

private static MemcachedClient m[] = null;
MemcachedClient c0 = new MemcachedClient(baseURIs, "bucket1", "");
MemcachedClient c1 = new MemcachedClient(baseURIs, "bucket2", "");
m[0] = c0;
m[1] = c1;

V/s

private static MemcachedClient m[] = null;
for(int i=0;i<2;i++){
MemcachedClient c = new MemcachedClient(baseURIs, "default", "");
m[i] = c;
}

Thanks
Abhilash

Top
  • Login or register to post comments
Tue, 10/11/2011 - 17:20
mikew
Offline
Joined: 03/14/2011
Groups:

We added the concept of buckets in Membase so that your system could be multi-tenant. You can think of it as the equivalent of having two databases in one mysql server. I would recommend putting everything into a single bucket unless your specific application would benefit from having multiple buckets.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker