gaojunda / simple-spring-memcached

Automatically exported from code.google.com/p/simple-spring-memcached
MIT License
0 stars 0 forks source link

Support server weights for XMemcachedClientBuilder #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Try to specify the weights of the servers (see 
https://code.google.com/p/xmemcached/wiki/Spring_Integration)

What is the expected output? What do you see instead?
XMemcachedClient created with weights, not possible to specify them in 

What version of the product are you using? On what operating system?
3.2.1

Please provide any additional information below.
My hack to get weights to work is to rewrite the factory and check the config 
before initializing the XMemcachedBuilder (since as you pointed out, there is 
no getter/setter for weights).

Something like:

        int[] weights = null;
        if (conf instanceof XMemcachedConfiguration) {
            weights = ((XMemcachedConfiguration) conf).getConvertedWeights();
        }

        MemcachedClientBuilder builder = new XMemcachedClientBuilder(addrs, weights);

I allowed the weights to be passed as a comma separated list of integers, and 
getConvertedWeights converts the comma separated list into an int[] (if the 
string is null or empty null is returned).

Original issue reported on code.google.com by MikeB7...@gmail.com on 4 Dec 2013 at 4:46

GoogleCodeExporter commented 8 years ago

Original comment by ragno...@gmail.com on 5 Dec 2013 at 1:50

GoogleCodeExporter commented 8 years ago
Code in trunk. Instead of coma separated list an array of int value has to be 
provided. In Spring xml it can be achieved using list tag:
<property name="weights">
  <list>
    <value>4</value>
    <value>8</value>
  </list>  
</property> 

Original comment by ragno...@gmail.com on 9 Dec 2013 at 12:19

GoogleCodeExporter commented 8 years ago
Included in release 3.3.0. The release is available in central maven 
repository. 

Original comment by ragno...@gmail.com on 17 Jan 2014 at 6:16