/** * @param item Set item. * @return Item key. */ private SetItemKey itemKey(Object item) { return collocated ? new CollocatedSetItemKey(name, id, item) : new GridCacheSetItemKey(separated ? null : id, item); }
/** {@inheritDoc} */ @Override public void onUpdate(GridCacheSemaphoreState val) { if (sync == null) return; // Update broken flag. sync.setBroken(val.isBroken()); // Update permission count. sync.setPermits(val.getCount()); // Update waiters' counts. sync.setWaiters(val.getWaiters()); // Try to notify any waiting threads. sync.releaseShared(0); }
/** * @param id Queue unique ID. * @param queueName Queue name. * @param collocated Collocation flag. * @param idx Item index. * @return Item key. */ private static QueueItemKey itemKey(IgniteUuid id, String queueName, boolean collocated, long idx) { return collocated ? new CollocatedQueueItemKey(id, queueName, idx) : new GridCacheQueueItemKey(id, queueName, idx); }
/** * @param idx Item index. * @return Item key. */ protected QueueItemKey itemKey(Long idx) { return itemKey(id, queueName, collocated(), idx); }
/** {@inheritDoc} */ @Override public boolean isBroken() { try{ initializeReentrantLock(); return sync.isBroken(); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** * @param keys Keys to remove. */ private void retryPutAll(final Map<SetItemKey, Boolean> keys) { retry(new Callable<Void>() { @Override public Void call() throws Exception { cache.putAll(keys); return null; } }); }
protected Sync(int permits, Map<UUID, Integer> waiters, boolean failoverSafe) { setState(permits); nodeMap = waiters; this.failoverSafe = failoverSafe; }
/** * Gets the number of permissions currently available. * * @return Number of permits available at this semaphore. */ final int getPermits() { return getState(); }
/** * @param ctx Cache context. */ public void init(GridCacheContext ctx) { this.ctx = ctx; filter = filterKeys(); }
/** * Sets the number of permits currently acquired on this lock. This method should only be used in {@linkplain * GridCacheLockImpl#onUpdate(GridCacheLockState)}. * * @param permits Number of permits acquired at this reentrant lock. */ final synchronized void setPermits(int permits) { setState(permits); }
/** * Gets the number of permissions currently acquired at this lock. * * @return Number of permits acquired at this reentrant lock. */ final int getPermits() { return getState(); }
/** {@inheritDoc} */ @Override public long get() { checkRemoved(); return locVal; }
/** * Removes atomic stamped from cache. * * @param name Atomic stamped name. * @param grpName Group name. * @throws IgniteCheckedException If removing failed. */ final void removeAtomicStamped(final String name, final String grpName) throws IgniteCheckedException { removeDataStructure(null, name, grpName, ATOMIC_STAMPED, null); }
/** {@inheritDoc} */ @Override public String toString() { return delegate.toString(); } }
/** * @param keys Keys to remove. */ private void retryRemoveAll(final Collection<SetItemKey> keys) { retry(new Callable<Void>() { @Override public Void call() throws Exception { cache.removeAll(keys); return null; } }); }
/** * Sets the number of permits currently available on this semaphore. This method should only be used in * {@linkplain GridCacheSemaphoreImpl#onUpdate(GridCacheSemaphoreState)}. * * @param permits Number of permits available at this semaphore. */ final synchronized void setPermits(int permits) { setState(permits); }