use of org.apache.ignite.internal.util.GridSpinReadWriteLock in project ignite by apache.
the class GridSpinReadWriteLockSelfTest method testWriteLockReentry.
/**
* @throws Exception If any error occurs.
*/
public void testWriteLockReentry() throws Exception {
GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
lock.writeLock();
lock.writeLock();
boolean b = lock.tryWriteLock();
assert b;
}
use of org.apache.ignite.internal.util.GridSpinReadWriteLock in project ignite by apache.
the class GridSpinReadWriteLockSelfTest method testReadLockReentry.
/**
* @throws Exception If any error occurs.
*/
public void testReadLockReentry() throws Exception {
final GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
lock.readLock();
final CountDownLatch latch = new CountDownLatch(1);
IgniteInternalFuture<?> f = multithreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
assert !lock.tryWriteLock();
info("Before write lock.");
latch.countDown();
lock.writeLock();
info("After write lock.");
return null;
}
}, 1);
latch.await();
U.sleep(100);
lock.readLock();
assert lock.tryReadLock();
lock.readUnlock();
lock.readUnlock();
lock.readUnlock();
f.get();
}
use of org.apache.ignite.internal.util.GridSpinReadWriteLock in project ignite by apache.
the class HadoopJobTracker method start.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void start(final HadoopContext ctx) throws IgniteCheckedException {
super.start(ctx);
busyLock = new GridSpinReadWriteLock();
evtProcSvc = Executors.newFixedThreadPool(1);
assert jobCls == null;
HadoopClassLoader ldr = ctx.kernalContext().hadoopHelper().commonClassLoader();
try {
jobCls = (Class<HadoopJobEx>) ldr.loadClass(HadoopCommonUtils.JOB_CLS_NAME);
} catch (Exception ioe) {
throw new IgniteCheckedException("Failed to load job class [class=" + HadoopCommonUtils.JOB_CLS_NAME + ']', ioe);
}
}
use of org.apache.ignite.internal.util.GridSpinReadWriteLock in project ignite by apache.
the class GridSpinReadWriteLockSelfTest method testLockDowngrade.
/**
* @throws Exception If any error occurs.
*/
public void testLockDowngrade() throws Exception {
GridSpinReadWriteLock lock = new GridSpinReadWriteLock();
// Read lock while holding write lock.
lock.writeLock();
lock.readLock();
lock.readUnlock();
lock.writeUnlock();
// Downgrade from write to read lock.
lock.writeLock();
lock.readLock();
lock.writeUnlock();
assert !lock.tryWriteLock();
lock.readUnlock();
// Test that we can operate with write locks now.
lock.writeLock();
lock.writeUnlock();
}
Aggregations