Package com.netflix.evcache.pool

Examples of com.netflix.evcache.pool.EVCacheClient


    public <T> T get(String key, EVCacheTranscoder<T> tc) throws EVCacheException {
        if (null == key) {
            throw new IllegalArgumentException("Key cannot be null");
        }

        final EVCacheClient client = _pool.getEVCacheClient();
        if (client == null) {
            NULL_CLIENT_COUNTER.increment();
            if (_throwException.get()) {
                throw new EVCacheException("Couldn't find an Client to get the data for key : " + key);
            }
            return null// Fast failure
        }

        try {
            final String canonicalKey = getCanonicalizedKey(key);
            T data = client.get(canonicalKey, tc);
            if (data == null && isInZoneFallback()) {
                final EVCacheClient fbClient = _pool.getEVCacheClientExcludeZone(client.getZone());
                if (fbClient == null) {
                    return null;
                }
                data = fbClient.get(canonicalKey, tc);
                if (data == null) {
                    FALLBACK_MISS_COUNTER.increment();
                } else {
                    FALLBACK_HIT_COUNTER.increment();
                }
View Full Code Here


    public <T> Future<T> getAsynchronous(String key, EVCacheTranscoder<T> tc) throws EVCacheException {
        if (null == key) {
            throw new IllegalArgumentException();
        }

        final EVCacheClient client = _pool.getEVCacheClient();
        if (client == null) {
            NULL_CLIENT_COUNTER.increment();
            if (_throwException.get()) {
                throw new EVCacheException("Could not find a client to asynchronously get the data");
            }
            return null// Fast failure
        }

        final Future<T> r;
        try {
            final String canonicalKey = getCanonicalizedKey(key);
            r = client.asyncGet(canonicalKey, tc);
        } catch (Exception ex) {
            if (log.isDebugEnabled()) {
                log.debug("Exception while getting data for keys Asynchronously key : " + key, ex);
            }
            if (!_throwException.get()) {
View Full Code Here

        }
        if (keys.isEmpty()) {
            return Collections.<String, T>emptyMap();
        }

        final EVCacheClient client = _pool.getEVCacheClient();
        if (client == null) {
            NULL_CLIENT_COUNTER.increment();
            if (_throwException.get()) {
                throw new EVCacheException("Could not find a client to get the data in bulk");
            }
            return null// Fast failure
        }

        final Collection<String> canonicalKeys = new ArrayList<String>();

        /* Canonicalize keys and perform fast failure checking */
        for (String k : keys) {
            final String canonicalK = getCanonicalizedKey(k);
            canonicalKeys.add(canonicalK);
        }

        try {
            final Map<String, T> retMap = client.getBulk(canonicalKeys, tc);
            if (retMap == null || retMap.isEmpty()) {
                return Collections.<String, T>emptyMap();
            }

            /* Decanonicalize the keys */
 
View Full Code Here

            final List<InetSocketAddress> memInstances = getMemcachedSocketAddressList(instances);
            final int poolSize = getPoolSize().get();
            final List<EVCacheClient> newClients = new ArrayList<EVCacheClient>(poolSize);
            for (int i = 0; i < poolSize; i++) {
                final int maxQueueSize = ConfigurationManager.getConfigInstance().getInt(getAppName() + ".max.queue.length", 16384);
                final EVCacheClient client = new SimpleEVCacheClientImpl(getAppName(), i, maxQueueSize, getReadTimeout(), memInstances);
                newClients.add(client);
                if (log.isDebugEnabled()) log.debug("AppName :" + getAppName() + "; intit : client.getId() : " + client.getId());
            }
            setupNewClients(newClients);
        } catch (Throwable t) {
            log.error("Exception while refreshing the Server list", t);
        }
View Full Code Here

TOP

Related Classes of com.netflix.evcache.pool.EVCacheClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.