nodes, getHashAlg(), new DefaultKetamaNodeLocatorConfiguration()
private List<Long> ketamaNodePositionsAtIteration(MemcachedNode node, int iteration) { List<Long> positions = new ArrayList<Long>(); byte[] digest = DefaultHashAlgorithm.computeMd5(config.getKeyForNode(node, iteration)); for (int h = 0; h < 4; h++) { Long k = ((long) (digest[3 + h * 4] & 0xFF) << 24) | ((long) (digest[2 + h * 4] & 0xFF) << 16); k |= ((long) (digest[1 + h * 4] & 0xFF) << 8) | (digest[h * 4] & 0xFF); positions.add(k); } return positions; } }
/** * the previous 7 may be too small to reduce the chance to get all down nodes * @param k * @return */ public Iterator<MemcachedNode> getSequence(String k) { // Seven searches gives us a 1 in 2^maxTry chance of hitting the // same dead node all of the time. int maxTry = config.getNodeRepetitions() + 1; if (maxTry < 20) { maxTry = 20; } return new KetamaIterator(k, maxTry, getKetamaNodes(), hashAlg); }
final int numReps = config.getNodeRepetitions(); for (MemcachedNode node : nodes) { final String hashString = config.getKeyForNode(node, i); byte[] digest = DefaultHashAlgorithm.computeMd5(hashString); if (log.isDebugEnabled()) log.debug("digest : " + digest); final Long hashL = Long.valueOf(hashingAlgorithm.hash(config.getKeyForNode(node, i))); newNodeMap.put(hashL, node);
@Override public String toString() { return "Cmd: " + cmd + " Keys: " + StringUtils.join(keys, " ") + "Exp: " + exp; } }
while (keyIter.hasNext()) { final String key = keyIter.next(); StringUtils.validateKey(key, opFact instanceof BinaryOperationFactory); final MemcachedNode primaryNode = locator.getPrimary(key); if (primaryNode.isActive()) {
public BTreeSMGetWithByteTypeBkey(List<String> keyList, byte[] from, byte[] to, ElementFlagFilter eFlagFilter, int count, SMGetMode smgetMode) { this.keyList = keyList; this.range = BTreeUtil.toHex(from) + ".." + BTreeUtil.toHex(to); this.eFlagFilter = eFlagFilter; this.count = count; this.smgetMode = smgetMode; this.reverse = BTreeUtil.compareByteArraysInLexOrder(from, to) > 0; }
public BTreeDelete(byte[] from, byte[] to, int count, boolean noreply, boolean dropIfEmpty, ElementMultiFlagsFilter elementMultiFlagsFilter) { this.range = BTreeUtil.toHex(from) + ".." + BTreeUtil.toHex(to); this.count = count; this.noreply = noreply; this.dropIfEmpty = dropIfEmpty; this.elementFlagFilter = (ElementFlagFilter) elementMultiFlagsFilter; }
public EVCacheKetamaNodeLocatorConfiguration(String appId, ServerGroup serverGroup, EVCacheClientPoolManager poolManager) { this.appId = appId; this.serverGroup = serverGroup; this.poolManager = poolManager; bucketSize = EVCacheConfig.getInstance().getChainedIntProperty(appId + "." + serverGroup.getName() + ".bucket.size",appId + ".bucket.size", super.getNodeRepetitions(), null); }
/** * insert a node from the internal node-address map. * * @param node */ public void insertNode(MemcachedNode node) { getSocketAddressForNode(node); }
int numReps = config.getNodeRepetitions(); int nodeCount = nodes.size(); int totalWeight = 0; float percent = (totalWeight == 0 ? 0f : (float) thisWeight / (float) totalWeight); int pointerPerServer = (int) ((Math.floor( (float) (percent * (float) config.getNodeRepetitions() / 4 * (float) nodeCount + 0.0000000001))) * 4); for (int i = 0; i < pointerPerServer / 4; i++) { newNodeMap.put(hashAlg.hash(config.getKeyForNode(node, i)), node);
/** * Create a new KetamaNodeLocator with specific nodes, hash, node key format, * and weight * * @param nodes The List of nodes to use in the Ketama consistent hash * continuum * @param alg The hash algorithm to use when choosing a node in the Ketama * consistent hash continuum * @param nodeKeyFormat the format used to name the nodes in Ketama, either * SPYMEMCACHED or LIBMEMCACHED * @param weights node weights for ketama, a map from InetSocketAddress to * weight as Integer */ public RefinedKetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg, KetamaNodeKeyFormatter.Format nodeKeyFormat, Map<InetSocketAddress, Integer> weights) { this(nodes, alg, weights, new DefaultKetamaNodeLocatorConfiguration(new KetamaNodeKeyFormatter(nodeKeyFormat))); }
@Override public String toString() { return "Cmd: " + cmd + " Keys: " + StringUtils.join(keys, " ") + "Exp: " + exp; } }
public BTreeSMGetWithByteTypeBkeyOld(List<String> keyList, byte[] from, byte[] to, ElementFlagFilter eFlagFilter, int offset, int count) { this.keyList = keyList; this.range = BTreeUtil.toHex(from) + ".." + BTreeUtil.toHex(to); this.eFlagFilter = eFlagFilter; this.offset = offset; this.count = count; this.reverse = BTreeUtil.compareByteArraysInLexOrder(from, to) > 0; }
public BTreeDelete(byte[] bkey, boolean noreply, boolean dropIfEmpty, ElementMultiFlagsFilter elementMultiFlagsFilter) { this.range = BTreeUtil.toHex(bkey); this.noreply = noreply; this.dropIfEmpty = dropIfEmpty; this.elementFlagFilter = (ElementFlagFilter) elementMultiFlagsFilter; }
/** * Create a new KetamaNodeLocator using specified nodes and the specifed hash * algorithm. * * @param nodes The List of nodes to use in the Ketama consistent hash * continuum * @param alg The hash algorithm to use when choosing a node in the Ketama * consistent hash continuum */ public KetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg) { this(nodes, alg, new DefaultKetamaNodeLocatorConfiguration()); }
@Override public String toString() { return "Cmd: " + cmd + " Keys: " + StringUtils.join(keys, " ") + "Exp: " + exp; } }
protected BTreeGetBulkImpl(List<String> keyList, byte[] from, byte[] to, ElementFlagFilter eFlagFilter, int offset, int count) { this.keyList = keyList; this.range = BTreeUtil.toHex(from) + ".." + BTreeUtil.toHex(to); this.eFlagFilter = eFlagFilter; this.offset = offset; this.count = count; this.reverse = BTreeUtil.compareByteArraysInLexOrder(from, to) > 0; }
/** * Create a new KetamaNodeLocator using specified nodes and the specifed hash algorithm. * * @param nodes The List of nodes to use in the Ketama consistent hash continuum * @param alg The hash algorithm to use when choosing a node in the Ketama consistent hash continuum */ public KetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg) { this(nodes, alg, new DefaultKetamaNodeLocatorConfiguration()); }
/** * Create a new KetamaNodeLocator using specified nodes and the specifed hash * algorithm. * * @param nodes The List of nodes to use in the Ketama consistent hash * continuum * @param alg The hash algorithm to use when choosing a node in the Ketama * consistent hash continuum */ public KetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg) { this(nodes, alg, new DefaultKetamaNodeLocatorConfiguration()); }