/** {@inheritDoc} */ @Override public boolean lock(Object key, long timeout) throws IgniteCheckedException { return delegate.get().lock(keyTransformer.transform(key), timeout); }
/** {@inheritDoc} */ @Override public boolean lock(K key, long timeout) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.lock(key, timeout); } finally { gate.leave(prev); } }
@Override public void run() { while (run) { TreeMap<Integer, String> vals = generateValues(keys); try { // Explicit lock. cache.lock(vals.firstKey(), 0); try { // Put or remove. if (ThreadLocalRandom.current().nextDouble(1) < 0.65) cache.putAll(vals); else cache.removeAll(vals.keySet()); } catch (IgniteCheckedException e) { U.error(log(), "Failed cache operation.", e); } finally { cache.unlock(vals.firstKey()); } U.sleep(100); } catch (Throwable e){ U.error(log(), "Failed unlock.", e); err = e; return; } } } };
/** {@inheritDoc} */ @Override public boolean lock(K key, long timeout) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.lock(key, timeout); } finally { gate.leave(prev); } }