Tabnine Logo
KetamaMemcachedSessionLocator
Code IndexAdd Tabnine to your IDE (free)

How to use
KetamaMemcachedSessionLocator
in
net.rubyeye.xmemcached.impl

Best Java code snippets using net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator (Showing top 11 results out of 315)

origin: killme2008/xmemcached

public KetamaMemcachedSessionLocator(List<Session> list, HashAlgorithm alg) {
 super();
 this.hashAlg = alg;
 this.cwNginxUpstreamConsistent = false;
 this.gwhalinMemcachedJavaClientCompatibiltyConsistent = false;
 this.buildMap(list, alg);
}
origin: killme2008/xmemcached

public final Session getSessionByKey(final String key) {
 if (this.ketamaSessions == null || this.ketamaSessions.size() == 0) {
  return null;
 }
 long hash = this.hashAlg.hash(key);
 Session rv = this.getSessionByHash(hash);
 int tries = 0;
 while (!this.failureMode && (rv == null || rv.isClosed()) && tries++ < this.maxTries) {
  hash = this.nextHash(hash, key, tries);
  rv = this.getSessionByHash(hash);
 }
 return rv;
}
origin: killme2008/xmemcached

String sockStr = this.getSockStr(session);
     (long) (digest[3 + h * 4] & 0xFF) << 24 | (long) (digest[2 + h * 4] & 0xFF) << 16
       | (long) (digest[1 + h * 4] & 0xFF) << 8 | digest[h * 4] & 0xFF;
   this.getSessionList(sessionMap, k).add(session);
 for (int i = 0; i < numReps; i++) {
  long key = alg.hash(sockStr + "-" + i);
  this.getSessionList(sessionMap, key).add(session);
origin: heibaiying/spring-samples-for-all

@Bean
public MemcachedClient memcachedClientForCluster() {
  List<InetSocketAddress> addressList = new ArrayList<InetSocketAddress>();
  addressList.add(new InetSocketAddress("192.168.200.201", 11211));
  addressList.add(new InetSocketAddress("192.168.200.201", 11212));
  // 赋予权重
  int[] weights = {1, 2};
  XMemcachedClientBuilder builder = new XMemcachedClientBuilder(addressList, weights);
  // 设置连接池大小
  builder.setConnectionPoolSize(10);
  // 协议工厂
  builder.setCommandFactory(new TextCommandFactory());
  // 分布策略,一致性哈希KetamaMemcachedSessionLocator或者ArraySessionLocator(默认)
  builder.setSessionLocator(new KetamaMemcachedSessionLocator());
  // 设置序列化器
  builder.setTranscoder(new SerializingTranscoder());
  MemcachedClient memcachedClient = null;
  try {
    memcachedClient = builder.build();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return memcachedClient;
}
origin: heibaiying/spring-samples-for-all

public MemcachedClient memcachedClientForCluster() {
  List<InetSocketAddress> addressList = new ArrayList<>();
  addressList.add(new InetSocketAddress("192.168.0.108", 11211));
  addressList.add(new InetSocketAddress("192.168.0.108", 11212));
  // 赋予权重
  int[] weights = {1, 2};
  XMemcachedClientBuilder builder = new XMemcachedClientBuilder(addressList, weights);
  // 设置连接池大小
  builder.setConnectionPoolSize(10);
  // 协议工厂
  builder.setCommandFactory(new TextCommandFactory());
  // 分布策略,一致性哈希KetamaMemcachedSessionLocator或者ArraySessionLocator(默认)
  builder.setSessionLocator(new KetamaMemcachedSessionLocator());
  // 设置序列化器
  builder.setTranscoder(new SerializingTranscoder());
  MemcachedClient memcachedClient = null;
  try {
    memcachedClient = builder.build();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return memcachedClient;
}
origin: ragnor/simple-spring-memcached

builder.setSessionLocator(new KetamaMemcachedSessionLocator());
origin: com.googlecode.xmemcached/xmemcached

public final Session getSessionByKey(final String key) {
 if (this.ketamaSessions == null || this.ketamaSessions.size() == 0) {
  return null;
 }
 long hash = this.hashAlg.hash(key);
 Session rv = this.getSessionByHash(hash);
 int tries = 0;
 while (!this.failureMode && (rv == null || rv.isClosed()) && tries++ < this.maxTries) {
  hash = this.nextHash(hash, key, tries);
  rv = this.getSessionByHash(hash);
 }
 return rv;
}
origin: com.googlecode.xmemcached/xmemcached

String sockStr = this.getSockStr(session);
     (long) (digest[3 + h * 4] & 0xFF) << 24 | (long) (digest[2 + h * 4] & 0xFF) << 16
       | (long) (digest[1 + h * 4] & 0xFF) << 8 | digest[h * 4] & 0xFF;
   this.getSessionList(sessionMap, k).add(session);
 for (int i = 0; i < numReps; i++) {
  long key = alg.hash(sockStr + "-" + i);
  this.getSessionList(sessionMap, key).add(session);
origin: killme2008/xmemcached

 public final void updateSessions(final Collection<Session> list) {
  this.buildMap(list, this.hashAlg);
 }
}
origin: com.googlecode.xmemcached/xmemcached

public KetamaMemcachedSessionLocator(List<Session> list, HashAlgorithm alg) {
 super();
 this.hashAlg = alg;
 this.cwNginxUpstreamConsistent = false;
 this.gwhalinMemcachedJavaClientCompatibiltyConsistent = false;
 this.buildMap(list, alg);
}
origin: com.googlecode.xmemcached/xmemcached

 public final void updateSessions(final Collection<Session> list) {
  this.buildMap(list, this.hashAlg);
 }
}
net.rubyeye.xmemcached.implKetamaMemcachedSessionLocator

Javadoc

Consistent Hash Algorithm implementation,based on TreeMap.tailMap(hash) method.

Most used methods

  • <init>
    Create a KetamaMemcachedSessionLocator
  • buildMap
  • getSessionByHash
  • getSessionList
  • getSockStr
  • nextHash

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • notifyDataSetChanged (ArrayAdapter)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now