net.spy.memcached.util.KetamaNodeLocatorConfiguration Java Examples

The following examples show how to use net.spy.memcached.util.KetamaNodeLocatorConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EVCacheNodeLocator.java    From EVCache with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new KetamaNodeLocator using specified nodes and the specifed
 * hash algorithm and configuration.
 *
 * @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 conf
 */
public EVCacheNodeLocator(EVCacheClient client, List<MemcachedNode> nodes, HashAlgorithm alg, KetamaNodeLocatorConfiguration conf) {
    super();
    this.allNodes = nodes;
    this.hashingAlgorithm = alg;
    this.config = conf;
    this.client = client;

    this.partialStringHash = EVCacheConfig.getInstance().getPropertyRepository().get(client.getAppName() + "." + client.getServerGroupName() + ".hash.on.partial.key", Boolean.class)
            .orElseGet(client.getAppName()+ ".hash.on.partial.key").orElse(false);
    this.hashDelimiter = EVCacheConfig.getInstance().getPropertyRepository().get(client.getAppName() + "." + client.getServerGroupName() + ".hash.delimiter", String.class)
            .orElseGet(client.getAppName() + ".hash.delimiter").orElse(":");


    setKetamaNodes(nodes);
}
 
Example #2
Source File: RefinedKetamaNodeLocator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private RefinedKetamaNodeLocator(TreeMap<Long, MemcachedNode> smn, Collection<MemcachedNode> an, HashAlgorithm alg,
        Map<InetSocketAddress, Integer> nodeWeights, KetamaNodeLocatorConfiguration conf) {
    super();
    ketamaNodes.set(smn);
    allNodes.set(an);
    hashAlg = alg;
    config = conf;
    weights = nodeWeights;
    isWeightedKetama = !weights.isEmpty();
}
 
Example #3
Source File: RefinedKetamaNodeLocator.java    From kylin with Apache License 2.0 5 votes vote down vote up
private RefinedKetamaNodeLocator(TreeMap<Long, MemcachedNode> smn, Collection<MemcachedNode> an, HashAlgorithm alg,
        Map<InetSocketAddress, Integer> nodeWeights, KetamaNodeLocatorConfiguration conf) {
    super();
    ketamaNodes.set(smn);
    allNodes.set(an);
    hashAlg = alg;
    config = conf;
    weights = nodeWeights;
    isWeightedKetama = !weights.isEmpty();
}
 
Example #4
Source File: EVCacheNodeLocator.java    From EVCache with Apache License 2.0 5 votes vote down vote up
private EVCacheNodeLocator(EVCacheClient client, TreeMap<Long, MemcachedNode> smn, Collection<MemcachedNode> an, HashAlgorithm alg, KetamaNodeLocatorConfiguration conf) {
    super();
    this.ketamaNodes = smn;
    this.allNodes = an;
    this.hashingAlgorithm = alg;
    this.config = conf;
    this.client = client;

    this.partialStringHash = EVCacheConfig.getInstance().getPropertyRepository().get(client.getAppName() + "." + client.getServerGroupName() + ".hash.on.partial.key", Boolean.class)
            .orElseGet(client.getAppName()+ ".hash.on.partial.key").orElse(false);
    this.hashDelimiter = EVCacheConfig.getInstance().getPropertyRepository().get(client.getAppName() + "." + client.getServerGroupName() + ".hash.delimiter", String.class)
            .orElseGet(client.getAppName() + ".hash.delimiter").orElse(":");
}
 
Example #5
Source File: RefinedKetamaNodeLocator.java    From kylin-on-parquet-v2 with Apache License 2.0 3 votes vote down vote up
/**
 * 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 nodeWeights node weights for ketama, a map from InetSocketAddress to
 *          weight as Integer
 * @param configuration node locator configuration
 */
public RefinedKetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg,
        Map<InetSocketAddress, Integer> nodeWeights, KetamaNodeLocatorConfiguration configuration) {
    super();
    allNodes.set(nodes);
    hashAlg = alg;
    config = configuration;
    weights = nodeWeights;
    isWeightedKetama = !weights.isEmpty();
    setKetamaNodes(nodes);
}
 
Example #6
Source File: RefinedKetamaNodeLocator.java    From kylin with Apache License 2.0 3 votes vote down vote up
/**
 * 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 nodeWeights node weights for ketama, a map from InetSocketAddress to
 *          weight as Integer
 * @param configuration node locator configuration
 */
public RefinedKetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg,
        Map<InetSocketAddress, Integer> nodeWeights, KetamaNodeLocatorConfiguration configuration) {
    super();
    allNodes.set(nodes);
    hashAlg = alg;
    config = configuration;
    weights = nodeWeights;
    isWeightedKetama = !weights.isEmpty();
    setKetamaNodes(nodes);
}
 
Example #7
Source File: RefinedKetamaNodeLocator.java    From kylin-on-parquet-v2 with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new KetamaNodeLocator using specified nodes and the specifed hash
 * algorithm and configuration.
 *
 * @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 conf
 */
public RefinedKetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg, KetamaNodeLocatorConfiguration conf) {
    this(nodes, alg, new HashMap<InetSocketAddress, Integer>(), conf);
}
 
Example #8
Source File: RefinedKetamaNodeLocator.java    From kylin with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new KetamaNodeLocator using specified nodes and the specifed hash
 * algorithm and configuration.
 *
 * @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 conf
 */
public RefinedKetamaNodeLocator(List<MemcachedNode> nodes, HashAlgorithm alg, KetamaNodeLocatorConfiguration conf) {
    this(nodes, alg, new HashMap<InetSocketAddress, Integer>(), conf);
}