public final void updateSessions(final Collection<Session> list) { this.buildMap(list, null); } }
public final Session getSessionByKey(final String key) { if (this.ketamaSessions == null || this.ketamaSessions.size() == 0) { return null; } long hash = hashAlgorithm.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; }
private final void buildMap(Collection<Session> list, HashAlgorithm alg) { TreeMap<Long, List<Session>> sessionMap = new TreeMap<Long, List<Session>>(); for (Session session : list) { String sockStr = null; if (session.getRemoteSocketAddress().getPort() != 11211) { sockStr = session.getRemoteSocketAddress().getHostName() + ":" + session.getRemoteSocketAddress().getPort(); } else { sockStr = session.getRemoteSocketAddress().getHostName(); } for (int i = 0; i < this.numReps; i++) { long key = hashAlgorithm.hash(sockStr + "-" + i); this.getSessionList(sessionMap, key).add(session); } } this.ketamaSessions = sessionMap; this.maxTries = list.size(); }
private final void buildMap(Collection<Session> list, HashAlgorithm alg) { TreeMap<Long, List<Session>> sessionMap = new TreeMap<Long, List<Session>>(); for (Session session : list) { String sockStr = null; if (session.getRemoteSocketAddress().getPort() != 11211) { sockStr = session.getRemoteSocketAddress().getHostName() + ":" + session.getRemoteSocketAddress().getPort(); } else { sockStr = session.getRemoteSocketAddress().getHostName(); } for (int i = 0; i < this.numReps; i++) { long key = hashAlgorithm.hash(sockStr + "-" + i); this.getSessionList(sessionMap, key).add(session); } } this.ketamaSessions = sessionMap; this.maxTries = list.size(); }
public final Session getSessionByKey(final String key) { if (this.ketamaSessions == null || this.ketamaSessions.size() == 0) { return null; } long hash = hashAlgorithm.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; }
public final void updateSessions(final Collection<Session> list) { this.buildMap(list, null); } }