/** {@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); } } }