sync.releaseShared(0);
/** {@inheritDoc} */ @Override public void onNodeRemoved(UUID nodeId) { try { initializeSemaphore(); } catch (IgniteCheckedException e) { U.error(log, "Failed to recover from failover because distributed semaphore cannot be initialized " + "(Ignore if this node is failing also)." ); // Degrade gracefully, no exception is thrown // because other semaphores might also attempt to recover from failover. return; } int numPermits = sync.getPermitsForNode(nodeId); if (numPermits > 0) { // Semaphore is broken if reaches this point in non-failover safe mode. boolean broken = !sync.failoverSafe; // Release permits acquired by threads on failing node. sync.releaseFailedNode(nodeId, broken); if (broken) { // Interrupt every waiting thread if this semaphore is not failover safe. sync.setBroken(true); for (Thread t : sync.getSharedQueuedThreads()) t.interrupt(); // Try to notify any waiting threads. sync.releaseShared(0); } } }
/** {@inheritDoc} */ @Override public void onNodeRemoved(UUID nodeId) { try { initializeSemaphore(); } catch (IgniteCheckedException e) { U.error(log, "Failed to recover from failover because distributed semaphore cannot be initialized " + "(Ignore if this node is failing also)." ); // Degrade gracefully, no exception is thrown // because other semaphores might also attempt to recover from failover. return; } int numPermits = sync.getPermitsForNode(nodeId); if (numPermits > 0) { // Semaphore is broken if reaches this point in non-failover safe mode. boolean broken = !sync.failoverSafe; // Release permits acquired by threads on failing node. sync.releaseFailedNode(nodeId, broken); if (broken) { // Interrupt every waiting thread if this semaphore is not failover safe. sync.setBroken(true); for (Thread t : sync.getSharedQueuedThreads()) t.interrupt(); // Try to notify any waiting threads. sync.releaseShared(0); } } }
/** {@inheritDoc} */ @Override public void release(int permits) { ctx.kernalContext().gateway().readLock(); A.ensure(permits >= 0, "Number of permits must be non-negative."); try { initializeSemaphore(); sync.releaseShared(permits); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@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); }
/** {@inheritDoc} */ @Override public void release(int permits) { ctx.kernalContext().gateway().readLock(); A.ensure(permits >= 0, "Number of permits must be non-negative."); try { initializeSemaphore(); sync.releaseShared(permits); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { ctx.kernalContext().gateway().readUnlock(); } }
/** {@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); }