/** {@inheritDoc} */ @Override public Map<?, ?> waitForAttributes(Collection<?> keys, long timeout) throws InterruptedException { A.notNull(keys, "keys"); if (keys.isEmpty()) return Collections.emptyMap(); if (timeout == 0) timeout = Long.MAX_VALUE; long now = System.currentTimeMillis(); // Prevent overflow. long end = now + timeout < 0 ? Long.MAX_VALUE : now + timeout; // Don't wait longer than session timeout. if (end > endTime) end = endTime; synchronized (mux) { while (!closed && !attrs.keySet().containsAll(keys) && now < end) { mux.wait(end - now); now = System.currentTimeMillis(); } if (closed) throw new InterruptedException("Session was closed: " + this); Map<Object, Object> retVal = new HashMap<Object, Object>(keys.size()); for (Object key : keys) retVal.put(key, attrs.get(key)); return retVal; } }
/** {@inheritDoc} */ @Override public GridFuture<Map<K, V>> getAllAsync( @Nullable Collection<? extends K> keys, @Nullable GridPredicate<? super GridCacheEntry<K, V>>[] filter) { ctx.denyOnFlag(LOCAL); if (F.isEmpty(keys)) return new GridFinishedFuture<Map<K, V>>(ctx.kernalContext(), Collections.<K, V>emptyMap()); GridCacheTxLocalAdapter<K, V> tx = ctx.tm().threadLocalTx(); if (tx != null && !tx.implicit()) return ctx.wrapCloneMap(tx.getAllAsync(keys, filter)); return loadAsync(keys, false, filter); }
/** * @param keys Keys to load. * @param reload Reload flag. * @param filter Filter. * @return Loaded values. */ public GridFuture<Map<K, V>> loadAsync( @Nullable Collection<? extends K> keys, boolean reload, @Nullable GridPredicate<? super GridCacheEntry<K, V>>[] filter) { if (F.isEmpty(keys)) return new GridFinishedFuture<Map<K, V>>(ctx.kernalContext(), Collections.<K, V>emptyMap()); GridNearGetFuture<K, V> fut = new GridNearGetFuture<K, V>(ctx, keys, reload, null, filter); // Register future for responses. ctx.mvcc().addFuture(fut); fut.init(); return ctx.wrapCloneMap(fut); }
/** {@inheritDoc} */ @Override public Map<K, Collection<GridCacheMvccCandidate<K>>> localCandidates() { return Collections.emptyMap(); }