Set NodeLocatorFactory to a new VBucketNodeLocatorFactory in code?
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
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