public void acquireReadLock() throws InterruptedException { this.lock.attemptLock(LockMode.READ_ONLY, -1, null); }
public void acquireWriteLock() throws InterruptedException { this.lock.attemptLock(LockMode.EX, -1, null); }
public final boolean attemptLock(final LockMode mode, final long msecs, final Object owner) { return attemptLock(mode, 0, LockingPolicy.NONE, msecs, owner, null); }
public void acquireWriteLock() throws InterruptedException { this.lock.attemptLock(LockMode.EX, -1, null); }
public void acquireWriteLock() throws InterruptedException { this.lock.attemptLock(LockMode.EX_SH, -1, null); }
public void acquireReadLock() throws InterruptedException { this.lock.attemptLock(LockMode.SH, -1, null); }
public void acquireReadLock() throws InterruptedException { this.lock.attemptLock(LockMode.READ_ONLY, -1, null); }
public void run() { try { if (this.l.attemptLock(LockMode.SH, waitMillisForTakingLock, null)) { Thread.sleep(this.sleepMillisAfterTakingLock); } else { failed = true; } } catch (InterruptedException e) { fail("did not expect exception in taking read locks"); } this.l.releaseLock(LockMode.SH, false, null); } }
public void testLockBehaviourWithDIfferentThread() throws Exception { final Object id = new String("id"); final ReentrantReadWriteWriteShareLock lock = new ReentrantReadWriteWriteShareLock(); assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); Locker locker = new Locker(lock, id, true, true, "R:S:E", "P:P:P"); Thread t = new Thread(locker); t.start(); t.join(); // lock again as it would have been released assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); locker = new Locker(lock, id, false, true, "R:S:E", "P:F:F"); Thread t1 = new Thread(locker); t1.start(); t1.join(); }
case 'R': if (shouldPass) { assertTrue(this.l.attemptLock(LockMode.SH, 0, null)); assertFalse(this.l.attemptLock(LockMode.SH, 0, null)); assertTrue(this.l.attemptLock(LockMode.EX_SH, 0, this.id)); assertTrue(this.l.attemptLock(LockMode.EX_SH, 0, "someId")); assertFalse(this.l.attemptLock(LockMode.EX_SH, 0, "someId")); assertTrue(this.l.attemptLock(LockMode.EX, 0, this.id)); assertTrue(this.l.attemptLock(LockMode.EX, 0, "someid")); assertFalse(this.l.attemptLock(LockMode.EX, 0, "someid"));
new ReentrantReadWriteWriteShareLock(); assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); assertTrue(lock.attemptLock(LockMode.SH, 0, null)); for (int i = 0; i < MAX_READ_SHARED_COUNT * 5; i++) { if (i % MAX_WRITE_COUNT == 0) {
public void takeLock() { if (this.logger.fineEnabled() || GemFireXDUtils.TracePersistIndex) { GfxdIndexManager.traceIndex( "IRFLockAcquireOp::takeLock calling acquiring lock on=%s ", this.lock); } this.lock.attemptLock(LockMode.EX, -1, this.owner); if (this.logger.fineEnabled() || GemFireXDUtils.TracePersistIndex) { GfxdIndexManager.traceIndex( "IRFLockAcquireOp::takeLock acquired lock on=%s ", this.lock); } }
public void takeLock() { if (this.logger.fineEnabled() || GemFireXDUtils.TracePersistIndex) { GfxdIndexManager.traceIndex( "IRFLockAcquireOp::takeLock calling acquiring lock on=%s ", this.lock); } this.lock.attemptLock(LockMode.EX, -1, this.owner); if (this.logger.fineEnabled() || GemFireXDUtils.TracePersistIndex) { GfxdIndexManager.traceIndex( "IRFLockAcquireOp::takeLock acquired lock on=%s ", this.lock); } }
public void takeLock() { if (this.logger.fineEnabled() || GemFireXDUtils.TracePersistIndex) { GfxdIndexManager.traceIndex( "IRFLockAcquireOp::takeLock calling acquiring lock on=%s ", this.lock); } this.lock.attemptLock(LockMode.EX, -1, this.owner); if (this.logger.fineEnabled() || GemFireXDUtils.TracePersistIndex) { GfxdIndexManager.traceIndex( "IRFLockAcquireOp::takeLock acquired lock on=%s ", this.lock); } }
assertTrue(lock.attemptLock(LockMode.SH, 0, null)); assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); assertFalse(lock.attemptLock(LockMode.EX, 0, id)); assertTrue(lock.attemptLock(LockMode.SH, 0, null)); assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); assertFalse(lock.attemptLock(LockMode.EX, 0, id)); assertTrue(lock.attemptLock(LockMode.SH, 0, id)); assertFalse(lock.attemptLock(LockMode.EX, 0, id)); lock.releaseLock(LockMode.SH, true, null); assertTrue(lock.attemptLock(LockMode.SH, 0, null)); assertFalse(lock.attemptLock(LockMode.EX, 0, id)); lock.releaseLock(LockMode.SH, false, id); assertTrue(lock.attemptLock(LockMode.SH, 0, id)); assertFalse(lock.attemptLock(LockMode.EX, 0, id)); lock.releaseLock(LockMode.SH, true, id); assertTrue(lock.attemptLock(LockMode.EX, 0, id)); lock.releaseLock(LockMode.EX, true, id); assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); assertTrue(lock.attemptLock(LockMode.SH, 0, null)); assertFalse(lock.attemptLock(LockMode.EX, 0, "newid")); assertFalse(lock.attemptLock(LockMode.EX, 0, id)); lock.releaseLock(LockMode.SH, false, null); assertTrue(lock.attemptLock(LockMode.EX, 0, id));
assertTrue(lock.attemptLock(LockMode.SH, 0, null)); lock.attemptLock(LockMode.SH, 0, null); fail("attempt to acquire read lock after max possible read: " + MAX_READ_SHARED_COUNT + " should have failed"); assertTrue(lock.attemptLock(LockMode.EX_SH, 0, id)); lock.attemptLock(LockMode.EX_SH, 0, id); fail("attempt to acquire write share lock after max possible write share: " + MAX_WRITE_COUNT + " should have failed"); assertTrue(lock.attemptLock(LockMode.EX, 0, id)); lock.attemptLock(LockMode.EX, 0, id); fail("attempt to acquire write ex lock after max possible write ex: " + MAX_WRITE_COUNT + " should have failed");
public void takeSnapshotGIIReadLock() { if (readLockEnabled()) { if (this.getPartitionedRegion().isInternalColumnTable()) { BucketRegion bufferRegion = getBufferRegion(); bufferRegion.takeSnapshotGIIReadLock(); } else { final LogWriterI18n logger = getCache().getLoggerI18n(); if (logger.fineEnabled()) { logger.fine("Taking readonly snapshotGIILock on bucket " + this); } snapshotGIILock.attemptLock(LockMode.SH, -1, giiReadLockForSIOwner); } } }
public boolean takeSnapshotGIIWriteLock(MembershipListener listener) { if (writeLockEnabled()) { if (this.getPartitionedRegion().isInternalColumnTable()) { BucketRegion bufferRegion = getBufferRegion(); return bufferRegion.takeSnapshotGIIWriteLock(listener); } else { final LogWriterI18n logger = getCache().getLoggerI18n(); if (logger.fineEnabled()) { logger.fine("Taking exclusive snapshotGIILock on bucket " + this.getName()); } snapshotGIILock.attemptLock(LockMode.EX, -1, giiWriteLockForSIOwner); getBucketAdvisor() .addMembershipListenerAndAdviseGeneric(listener); snapshotGIILocked = true; this.giiListener = listener; // Set the listener only after taking the write lock. if (logger.fineEnabled()) { logger.fine("Succesfully took exclusive lock on bucket " + this.getName()); } return true; } } else { return false; } }