vaseems / xmemcached

Automatically exported from code.google.com/p/xmemcached
Apache License 2.0
0 stars 0 forks source link

关于一致性Hash的算法KetamaMemcachedSessionLocator #243

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
你好。。我在使用xmemcached运行在centos 64位和sun 
jdk6上,发现set进去的数据,get出来的时候为空了,服务器配�
��了两个memcached节点,weight配置默认是一样都是int[]{1,1},过期�
��间为0,谢了一个测试代码在服务器,也是为空,测试代码如�
��
        XMemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddressMap("99.6.138.44:11211 99.6.138.44:11214"),new int[]{1,1});  
        builder.setSessionLocator(new KetamaMemcachedSessionLocator());
        builder.setFailureMode(true);

        MemcachedClient memcachedClient = builder.build();

    try {

        long start = System.currentTimeMillis();
        memcachedClient.delete("globalCacheSwitch");
        memcachedClient.set("globalCacheSwitch", 0, "test");
        String  result = (String)memcachedClient.get("globalCacheSwitch");
        long end = System.currentTimeMillis();
        System.out.println(result);
        System.out.println(end - start);
        memcachedClient.shutdown();
  }catch (Exception e) {
        System.err.println("MemcachedClient operation fail");

    }
使用xmemcached的版本为1.3.2,后来我把节点的weight调整了1,2发
现正常,但是从原理上看权值只是一个连接复制,如果一致��
�Hash存在问题那么应该还有出现不命中情况,还有有些JVM对于
Hash实现可能为负数,总之很奇怪,Set进去的key,get出来的时�
��为null!!

Original issue reported on code.google.com by lishi...@126.com on 21 Dec 2012 at 3:17

GoogleCodeExporter commented 9 years ago
在我的机器上完整正常,没有复现你说的现象,不知道还有��
�有这个现象?

Original comment by killme2...@gmail.com on 8 Jan 2013 at 12:21

GoogleCodeExporter commented 9 years ago
请更新到最新版本吧。1.3.2太老了都

Original comment by xzhu...@avos.com on 10 Jan 2013 at 9:23

GoogleCodeExporter commented 9 years ago
1.4.2 released.

这个问题应该跟https://code.google.com/p/xmemcached/issues/detail?id=256&c
an=1&start=200 这个是一样的

建议设置hosts列表和hostname来避免DNS解析

Original comment by killme2...@gmail.com on 19 Jul 2013 at 6:44