Search in sources :

Example 1 with BulkFuture

use of net.spy.memcached.internal.BulkFuture in project druid by druid-io.

the class MockMemcachedClient method asyncGetBulk.

@Override
public <T> BulkFuture<Map<String, T>> asyncGetBulk(final Iterator<String> keys, final Transcoder<T> tc) {
    return new BulkFuture<Map<String, T>>() {

        @Override
        public boolean isTimeout() {
            return false;
        }

        @Override
        public Map<String, T> getSome(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException {
            return get();
        }

        @Override
        public OperationStatus getStatus() {
            return null;
        }

        @Override
        public Future<Map<String, T>> addListener(BulkGetCompletionListener bulkGetCompletionListener) {
            return null;
        }

        @Override
        public Future<Map<String, T>> removeListener(BulkGetCompletionListener bulkGetCompletionListener) {
            return null;
        }

        @Override
        public boolean cancel(boolean b) {
            return false;
        }

        @Override
        public boolean isCancelled() {
            return false;
        }

        @Override
        public boolean isDone() {
            return true;
        }

        @Override
        public Map<String, T> get() throws InterruptedException, ExecutionException {
            Map<String, T> retVal = Maps.newHashMap();
            while (keys.hasNext()) {
                String key = keys.next();
                CachedData data = theMap.get(key);
                retVal.put(key, data != null ? tc.decode(data) : null);
            }
            return retVal;
        }

        @Override
        public Map<String, T> get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
            return get();
        }
    };
}
Also used : CachedData(net.spy.memcached.CachedData) TimeUnit(java.util.concurrent.TimeUnit) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) BulkGetCompletionListener(net.spy.memcached.internal.BulkGetCompletionListener) BulkFuture(net.spy.memcached.internal.BulkFuture)

Aggregations

Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 TimeUnit (java.util.concurrent.TimeUnit)1 CachedData (net.spy.memcached.CachedData)1 BulkFuture (net.spy.memcached.internal.BulkFuture)1 BulkGetCompletionListener (net.spy.memcached.internal.BulkGetCompletionListener)1