@Override public boolean applyx(AtomicDataStructureValue val) throws IgniteCheckedException { assert val != null && val instanceof GridCacheSemaphoreState; GridCacheSemaphoreState semVal = (GridCacheSemaphoreState) val; if (semVal.getCount() < 0) throw new IgniteCheckedException("Failed to remove semaphore with blocked threads. "); return true; } }, name, grpName, SEMAPHORE, null);
@Override public Integer call() throws Exception { try ( GridNearTxLocal tx = CU.txStartInternal(ctx, cacheView, PESSIMISTIC, REPEATABLE_READ) ) { GridCacheSemaphoreState val = cacheView.get(key); if (val == null) throw new IgniteException("Failed to find semaphore with given name: " + name); int cnt = val.getCount(); tx.rollback(); return cnt; } } });
Integer permit = ((GridCacheSemaphoreState) val).getCount();
/** {@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); }
boolean retVal = val.getCount() == expVal;
@Override public Sync call() throws Exception { try (GridNearTxLocal tx = CU.txStartInternal(ctx, cacheView, PESSIMISTIC, REPEATABLE_READ)) { GridCacheSemaphoreState val = cacheView.get(key); if (val == null) { if (log.isDebugEnabled()) log.debug("Failed to find semaphore with given name: " + name); return null; } final int cnt = val.getCount(); Map<UUID, Integer> waiters = val.getWaiters(); final boolean failoverSafe = val.isFailoverSafe(); tx.commit(); Sync sync = new Sync(cnt, waiters, failoverSafe); sync.setBroken(val.isBroken()); return sync; } } });
val.setCount(val.getCount() + numPermits);
@Override public boolean applyx(AtomicDataStructureValue val) throws IgniteCheckedException { assert val != null && val instanceof GridCacheSemaphoreState; GridCacheSemaphoreState semVal = (GridCacheSemaphoreState) val; if (semVal.getCount() < 0) throw new IgniteCheckedException("Failed to remove semaphore with blocked threads. "); return true; } }, name, grpName, SEMAPHORE, null);
@Override public Integer call() throws Exception { try ( GridNearTxLocal tx = CU.txStartInternal(ctx, cacheView, PESSIMISTIC, REPEATABLE_READ) ) { GridCacheSemaphoreState val = cacheView.get(key); if (val == null) throw new IgniteException("Failed to find semaphore with given name: " + name); int cnt = val.getCount(); tx.rollback(); return cnt; } } });
Integer permit = ((GridCacheSemaphoreState) val).getCount();
/** {@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); }
boolean retVal = val.getCount() == expVal;
val.setCount(val.getCount() + numPermits);
@Override public Sync call() throws Exception { try (GridNearTxLocal tx = CU.txStartInternal(ctx, cacheView, PESSIMISTIC, REPEATABLE_READ)) { GridCacheSemaphoreState val = cacheView.get(key); if (val == null) { if (log.isDebugEnabled()) log.debug("Failed to find semaphore with given name: " + name); return null; } final int cnt = val.getCount(); Map<UUID, Integer> waiters = val.getWaiters(); final boolean failoverSafe = val.isFailoverSafe(); tx.commit(); Sync sync = new Sync(cnt, waiters, failoverSafe); sync.setBroken(val.isBroken()); return sync; } } });