use of org.apache.jackrabbit.core.state.ISMLocking.WriteLock in project jackrabbit by apache.
the class AbstractISMLockingTest method testIntersectingWrites.
/**
* Checks the following requirement: <p/> While a write lock is held for a given change log <code>C</code>
* an implementation must ensure that no write lock is issued for a change log <code>C'</code> that intersects
* with <code>C</code>. That is both change logs contain a reference to the same item. Please note that an
* implementation is free to block requests entirely for additional write lock while a write lock is
* active. It is not a requirement to support concurrent write locks.
*
* @throws InterruptedException on interruption; this will err the test
*/
public void testIntersectingWrites() throws InterruptedException {
ChangeLog cl = new ChangeLog();
cl.added(state);
WriteLock wLock = locking.acquireWriteLock(cl);
for (ChangeLog changeLog : logs) {
verifyBlocked(startWriterThread(locking, changeLog));
}
wLock.release();
}
use of org.apache.jackrabbit.core.state.ISMLocking.WriteLock in project jackrabbit by apache.
the class AbstractISMLockingTest method testWriteBlocksRead.
/**
* Checks the following requirement: <p/> <i>While a write lock is held for a given change log
* <code>C</code> an implementation must ensure that no read lock is issued for an item that is contained
* in <code>C</code>, unless the current thread is the owner of the write lock!</i> <p/> The "unless"
* clause is tested by {@link #testWriteBlocksRead_notIfSameThread()} test.
*
* @throws InterruptedException on interruption; this will err the test
*/
public void testWriteBlocksRead() throws InterruptedException {
for (ChangeLog changeLog : logs) {
WriteLock wLock = locking.acquireWriteLock(changeLog);
verifyBlocked(startReaderThread(locking, state.getId()));
wLock.release();
}
}
use of org.apache.jackrabbit.core.state.ISMLocking.WriteLock in project jackrabbit by apache.
the class AbstractISMLockingTest method testDowngrade.
/**
* Checks if a downgraded write lock allows other threads to read again.
*
* @throws InterruptedException on interruption; this will err the test
*/
public void testDowngrade() throws InterruptedException {
for (ChangeLog changeLog : logs) {
WriteLock wLock = locking.acquireWriteLock(changeLog);
verifyBlocked(startReaderThread(locking, state.getId()));
ReadLock rLock = wLock.downgrade();
verifyNotBlocked(startReaderThread(locking, state.getId()));
rLock.release();
}
}
use of org.apache.jackrabbit.core.state.ISMLocking.WriteLock in project jackrabbit by apache.
the class DefaultISMLockingDeadlockTest method test.
public void test() throws InterruptedException {
final ISMLocking lock = new DefaultISMLocking();
WriteLock w1 = lock.acquireWriteLock(null);
ReadLock r1 = w1.downgrade();
final InterruptedException[] ex = new InterruptedException[1];
Thread thread = new Thread() {
public void run() {
try {
lock.acquireWriteLock(null).release();
} catch (InterruptedException e) {
ex[0] = e;
}
}
};
thread.start();
Thread.sleep(100);
lock.acquireReadLock(null).release();
r1.release();
thread.join();
if (ex[0] != null) {
throw ex[0];
}
}
Aggregations