/** * Allow new transactions to be started again if current thread is the one who called * {@link #blockNewTransactions()}. * * @throws IllegalStateException if current thread is not the one that called {@link #blockNewTransactions()}. */ public void unblockNewTransactions() { if ( !newTransactionsLock.writeLock().isHeldByCurrentThread() ) { throw new IllegalStateException( "This thread did not block transactions previously" ); } newTransactionsLock.writeLock().unlock(); }
/** * Closes the lock. This needs to be called in the finally block corresponding * to the try block of #startRegionOperation */ private void closeBulkRegionOperation(){ if (lock.writeLock().isHeldByCurrentThread()) lock.writeLock().unlock(); else lock.readLock().unlock(); }
@Override public void onException(IOException error) { if (failed.compareAndSet(false, true)) { stopMonitorThreads(); if (sendLock.writeLock().isHeldByCurrentThread()) { sendLock.writeLock().unlock(); } transportListener.onException(error); } }
protected void walIndexVal(long logPos, long ioRecid, long indexVal) { assert(locks[Store.lockPos(ioRecid)].writeLock().isHeldByCurrentThread()); assert(logSize>=logPos+1+8+8); log.putByte(logPos, WAL_INDEX_LONG); log.putLong(logPos + 1, ioRecid); log.putLong(logPos + 9, indexVal); logChecksumAdd(LongHashMap.longHash(logPos | WAL_INDEX_LONG | ioRecid | indexVal)); }
/** * Checks if busy lock was blocked by current thread. * * @return {@code True} if busy lock was blocked by current thread. */ public boolean blockedByCurrentThread() { return lock.writeLock().isHeldByCurrentThread(); }
protected void freeIoRecidPut(long ioRecid) { assert(ioRecid>IO_USER_START); assert(locks[lockPos(ioRecid)].writeLock().isHeldByCurrentThread()); if(spaceReclaimTrack) longStackPut(IO_FREE_RECID, ioRecid,false); }
protected void cleanTxQueue(){ assert(commitLock.writeLock().isHeldByCurrentThread()); for(Reference<? extends Tx> ref = txQueue.poll(); ref!=null; ref=txQueue.poll()){ txs.remove(ref); } }
if (checkpointLock.writeLock().isHeldByCurrentThread()) return;
assert !getSegment(fullPageId).writeLock().isHeldByCurrentThread();
log.info("Evicting " + fullPageId); assert getSegment(fullPageId).writeLock().isHeldByCurrentThread();
assert writeLock().isHeldByCurrentThread();
assert seg.writeLock().isHeldByCurrentThread();
/** * @param fullPageId Full page ID to remove all links placed on the page from row cache. * @param absPtr Absolute pointer of the page to evict. * @throws IgniteCheckedException On error. */ private void clearRowCache(FullPageId fullPageId, long absPtr) throws IgniteCheckedException { assert writeLock().isHeldByCurrentThread(); if (ctx.kernalContext().query() == null || !ctx.kernalContext().query().moduleEnabled()) return; long pageAddr = PageMemoryImpl.this.readLock(absPtr, fullPageId.pageId(), true, false); try { if (PageIO.getType(pageAddr) != PageIO.T_DATA) return; final GridQueryRowCacheCleaner cleaner = ctx.kernalContext().query() .getIndexing().rowCacheCleaner(fullPageId.groupId()); if (cleaner == null) return; DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr); io.forAllItems(pageAddr, new DataPageIO.CC<Void>() { @Override public Void apply(long link) { cleaner.remove(link); return null; } }); } finally { readUnlockPage(absPtr); } }
GridTestUtils.waitForCondition(() -> db.checkpointLock.writeLock().isHeldByCurrentThread(), 5000);
/** * @param nodeId Node to remove. */ private void removeNode(UUID nodeId) { assert nodeId != null; assert lock.writeLock().isHeldByCurrentThread(); ClusterNode loc = cctx.localNode(); if (node2part != null) { if (!node2part.nodeId().equals(loc.id())) { updateSeq.setIfGreater(node2part.updateSequence()); node2part = new GridDhtPartitionFullMap(loc.id(), loc.order(), updateSeq.incrementAndGet(), node2part, false); } else node2part = new GridDhtPartitionFullMap(node2part, node2part.updateSequence()); GridDhtPartitionMap parts = node2part.remove(nodeId); if (parts != null) { for (Integer p : parts.keySet()) { Set<UUID> nodeIds = part2node.get(p); if (nodeIds != null) { nodeIds.remove(nodeId); if (nodeIds.isEmpty()) part2node.remove(p); } } } consistencyCheck(); } }
assert lock.writeLock().isHeldByCurrentThread();
@Override public void run() { LOG.debug("Running {}", this); if (monitorStarted.get()) { try { // If we can't get the lock it means another // write beat us into the // send and we don't need to heart beat now. if (sendLock.writeLock().tryLock()) { KeepAliveInfo info = new KeepAliveInfo(); info.setResponseRequired(keepAliveResponseRequired); doOnewaySend(info); } } catch (IOException e) { onException(e); } finally { if (sendLock.writeLock().isHeldByCurrentThread()) { sendLock.writeLock().unlock(); } } } }
/** * Releases the checkpoint read lock. */ @Override public void checkpointReadUnlock() { if (checkpointLock.writeLock().isHeldByCurrentThread()) return; checkpointLock.readLock().unlock(); if (checkpointer != null) { Collection<DataRegion> dataRegs = context().database().dataRegions(); if (dataRegs != null) { for (DataRegion dataReg : dataRegs) { if (!dataReg.config().isPersistenceEnabled()) continue; PageMemoryEx mem = (PageMemoryEx)dataReg.pageMemory(); if (mem != null && !mem.safeToUpdate()) { checkpointer.wakeupForCheckpoint(0, "too many dirty pages"); break; } } } } if (ASSERTION_ENABLED) CHECKPOINT_LOCK_HOLD_COUNT.set(CHECKPOINT_LOCK_HOLD_COUNT.get() - 1); }
/** * Enters "busy" state. * * @return {@code true} if entered to busy state. */ public boolean enterBusy() { return !lock.writeLock().isHeldByCurrentThread() && lock.readLock().tryLock(); }
/** * Checks if busy lock was blocked by current thread. * * @return {@code True} if busy lock was blocked by current thread. */ public boolean blockedByCurrentThread() { return lock.writeLock().isHeldByCurrentThread(); }