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

Set NodeLocatorFactory to a new VBucketNodeLocatorFactory in code?

1 reply [Last post]
  • Login or register to post comments
Thu, 01/12/2012 - 12:30
aselke
Offline
Joined: 12/15/2011
Groups: None

We have a singleton that we use to encapsulate the MembaseClient() and inside of its constructor we create a MembaseClientConfiguration object, set its properties and we are good to go. For various reasons, there is no way to make use of a traditional app/web config file.

There is no problem pointing the configuration at all the servers in our cluster, but when we try to store an object, the node locator fails because it has no nodes from which to pick. I had expected that it would figure the nodes out from the cluster configuration, but apparently not.

I am assuming that I need to assign either the MembaseClientConfiguration's NodeLocatorFactory or NodeLocator property, but I cannot find any examples or documentation on how to do this without an app/web config file. When I look at the config file values and try to map them myself manually, I am not certain how to deal with the nested integer array (meaning I am not sure what those numbers mean in the example).

Also, when I look at the supported hashing for the VBucketNodeLocator, none of them are the TigerHashKeyTransformer that I am using. Do the KeyTransformer type and the VBucketNodeLocator's hashAlgorithm constructor param need to be the same?

Here's what we are doing today:

public MembaseCacher()
{
    _config = new MembaseClientConfiguration();
    // get all the servers in our cluster
    string urlFormat = MembaseServer.ServerNodeUrlFormat;
    foreach (string serverName in ListMachinesForApplication(@"MembaseServers"))
    {
        _config.Urls.Add(
            new Uri(string.Format(urlFormat, 
            serverName, 
            MembaseServer.WebAdminPort, 
            MembaseBucketName)));
    }
    //  this is supposedly the best performance hasher for very large string keys
    _config.KeyTransformer = new TigerHashKeyTransformer();
 
    // one of these needs to be set in order to make the cluster work
    _config.NodeLocatorFactory = ???;
    _config.NodeLocator = ???;
 
    // don't bother instantiating the client if we don't need it
    if (!CachingEnabled) return;
    // new up the client
    _membaseClient = new MembaseClient(_config);
}

Any help is greatly appreciated! Thank you!

Tony

Top
  • Login or register to post comments
Thu, 01/12/2012 - 12:56
aselke
Offline
Joined: 12/15/2011
Groups: None

LOL! Never mind.

It turns out that if your "cluster" has only one node, then the automatic configuration that happens when your client hits the cluster the first time doesn't happen. Nothing throws an exception - it just never finds a node on which to store your objects. As soon as I spun up another node and joined my local cluster, everything worked as it used to - perfectly.

It does beg the question of whether this is expected/good behavior, but it isn't blocking me any longer.

Anyway, the only impact for us is that our developers can't run a "local cluster of one node" for testing/development purposes, but that's not a show-stopper.

Tony

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