/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ private Object readResolve() throws ObjectStreamException { String name = stash.get(); assert name != null; try { IgniteLock lock = IgnitionEx.localIgnite().context().dataStructures().reentrantLock( name, null, false, false, false); if (lock == null) throw new IllegalStateException("Lock was not found on deserialization: " + name); return lock; } catch (IgniteCheckedException e) { throw U.withCause(new InvalidObjectException(e.getMessage()), e); } finally { stash.remove(); } }
/** {@inheritDoc} */ @Nullable @Override public IgniteLock reentrantLock( String name, boolean failoverSafe, boolean fair, boolean create ) { guard(); try { checkClusterState(); return ctx.dataStructures().reentrantLock(name, null, failoverSafe, fair, create); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }
/** * @param lockName Reentrant lock name. * @throws Exception If failed. */ private void removeReentrantLock(String lockName, final boolean fair) throws Exception { IgniteLock lock = grid(RND.nextInt(NODES_CNT)).reentrantLock(lockName, false, fair, true); assert lock != null; // Remove lock on random node. IgniteLock lock0 = grid(RND.nextInt(NODES_CNT)).reentrantLock(lockName, false, fair, true); assertNotNull(lock0); lock0.close(); // Ensure reentrant lock is removed on all nodes. for (Ignite g : G.allGrids()) assertNull(((IgniteKernal)g).context().dataStructures().reentrantLock(lockName, null, false, fair, false)); checkRemovedReentrantLock(lock); }
/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ private Object readResolve() throws ObjectStreamException { String name = stash.get(); assert name != null; try { IgniteLock lock = IgnitionEx.localIgnite().context().dataStructures().reentrantLock( name, null, false, false, false); if (lock == null) throw new IllegalStateException("Lock was not found on deserialization: " + name); return lock; } catch (IgniteCheckedException e) { throw U.withCause(new InvalidObjectException(e.getMessage()), e); } finally { stash.remove(); } }
/** {@inheritDoc} */ @Nullable @Override public IgniteLock reentrantLock( String name, boolean failoverSafe, boolean fair, boolean create ) { guard(); try { checkClusterState(); return ctx.dataStructures().reentrantLock(name, null, failoverSafe, fair, create); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { unguard(); } }