/** * Queries if the write lock is held by the current thread. * * @return {@code true} if the current thread holds the write lock and * {@code false} otherwise */ public boolean isWriteLockedByCurrentThread() { return locks[locks.length - 1].isWriteLockedByCurrentThread(); }
private void assertCurrentThreadIsNotBlockingNewTransactions() { if ( newTransactionsLock.isWriteLockedByCurrentThread() ) { throw new IllegalStateException( "Thread that is blocking new transactions from starting can't start new transaction" ); } }
/** {@inheritDoc} */ @Override public boolean checkpointLockIsHeldByThread() { return !ASSERTION_ENABLED || checkpointLock.isWriteLockedByCurrentThread() || CHECKPOINT_LOCK_HOLD_COUNT.get() > 0 || Thread.currentThread().getName().startsWith(CHECKPOINT_RUNNER_THREAD_PREFIX); }
/** * Increment modification counter to force recompilation of existing prepared statements. */ private void incrementModificationCounter() { assert lock.isWriteLockedByCurrentThread(); setModified(); }
/** {@inheritDoc} */ @Override public boolean holdsLock() { return lock.isWriteLockedByCurrentThread() || lock.getReadHoldCount() > 0; }
private void supplyLookupSources() checkState(!lock.isWriteLockedByCurrentThread());
/** * @param stopError Error to shutdown resources. */ private void stopProcessor(IgniteCheckedException stopError) { assert opsLock.isWriteLockedByCurrentThread(); depMgr.stopProcessing(stopError); cancelDeployedServices(); registeredServices.clear(); // If user requests sent to network but not received back to handle in deployment manager. Stream.concat(depFuts.values().stream(), undepFuts.values().stream()).forEach(fut -> { try { fut.onDone(stopError); } catch (Exception ignore) { // No-op. } }); depFuts.clear(); undepFuts.clear(); if (log.isDebugEnabled()) log.debug("Stopped service processor."); }
/** * Cancels deployed services. */ private void cancelDeployedServices() { assert opsLock.isWriteLockedByCurrentThread(); deployedServices.clear(); locServices.values().stream().flatMap(Collection::stream).forEach(srvcCtx -> { cancel(srvcCtx); if (ctx.isStopping()) { try { if (log.isInfoEnabled()) { log.info("Shutting down distributed service [name=" + srvcCtx.name() + ", execId8=" + U.id8(srvcCtx.executionId()) + ']'); } srvcCtx.executor().awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); U.error(log, "Got interrupted while waiting for service to shutdown (will continue " + "stopping node): " + srvcCtx.name()); } } }); locServices.clear(); }
/** {@inheritDoc} */ @Override public void onEvicted(GridDhtLocalPartition part, boolean updateSeq) { assert updateSeq || lock.isWriteLockedByCurrentThread(); lock.writeLock().lock(); try { if (stopping) return; assert part.state() == EVICTED; long seq = updateSeq ? this.updateSeq.incrementAndGet() : this.updateSeq.get(); updateLocal(part.id(), cctx.localNodeId(), part.state(), seq); consistencyCheck(); } finally { lock.writeLock().unlock(); } }
case RUN: while(outboundLock.isWriteLockedByCurrentThread()) { outboundLock.writeLock().unlock(); while(outboundLock.isWriteLockedByCurrentThread()) { outboundLock.writeLock().unlock();
assert lock.isWriteLockedByCurrentThread(); assert nodeId.equals(cctx.localNodeId());
/** * Tests {@link LockResource} with {@link ReentrantReadWriteLock}. */ @Test public void reentrantReadWriteLock() { ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); try (LockResource r1 = new LockResource(lock.readLock())) { try (LockResource r2 = new LockResource(lock.readLock())) { assertEquals(lock.getReadHoldCount(), 2); assertTrue(lock.readLock().tryLock()); lock.readLock().unlock(); } } assertEquals(lock.getReadHoldCount(), 0); try (LockResource r1 = new LockResource(lock.writeLock())) { try (LockResource r2 = new LockResource(lock.readLock())) { assertTrue(lock.isWriteLockedByCurrentThread()); assertEquals(lock.getReadHoldCount(), 1); } } assertFalse(lock.isWriteLockedByCurrentThread()); assertEquals(lock.getReadHoldCount(), 0); try (LockResource r = new LockResource(lock.readLock())) { assertFalse(lock.writeLock().tryLock()); } } }
boolean hasWriteLock() { return this.dirLock.isWriteLockedByCurrentThread(); }
public boolean isWriteLockedByCurrentThread() { return coarseLock.isWriteLockedByCurrentThread(); }
/** * {@inheritDoc} */ public boolean isHeldByCurrentThread(LockType type) { switch (type) { case READ: throw new UnsupportedOperationException("Querying of read lock is not supported."); case WRITE: return lock.isWriteLockedByCurrentThread(); default: throw new IllegalArgumentException("We don't support any other lock type than READ or WRITE!"); } }
/** * {@inheritDoc} */ public boolean isHeldByCurrentThread(LockType type) { switch (type) { case READ: throw new UnsupportedOperationException("Querying of read lock is not supported."); case WRITE: return rrwl.isWriteLockedByCurrentThread(); default: throw new IllegalArgumentException("We don't support any other lock type than READ or WRITE!"); } } }
private synchronized void close() throws IOException { if (!logIdLock.isWriteLockedByCurrentThread()) { throw new IllegalStateException("close should be called with write lock held!"); } try { if (currentLog != null) { try { currentLog.close(); } catch (DfsLogger.LogClosedException ex) { // ignore } catch (Throwable ex) { log.error("Unable to cleanly close log " + currentLog.getFileName() + ": " + ex, ex); } finally { this.tserver.walogClosed(currentLog); } currentLog = null; logSizeEstimate.set(0); } } catch (Throwable t) { throw new IOException(t); } }
return; final boolean writeLockHeld = rwLock.isWriteLockedByCurrentThread(); try { if (!writeLockHeld) {
protected final void closeNoLock(String reason, CountDownLatch closedLatch) { if (isClosed.compareAndSet(false, true)) { assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread() : "Either the write lock must be held or the engine must be currently be failing itself"; try {
.getWriteHoldCount() == 1 && coarseLock.isWriteLockedByCurrentThread(); final long currentTimeNanos = timer.monotonicNowNanos(); final long writeLockIntervalNanos =