use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class RangeLockServiceTest method testReadGteisRangeBlockedIfWritingEqValue.
@Test
public void testReadGteisRangeBlockedIfWritingEqValue() throws InterruptedException {
final Text key = Variables.register("key", TestData.getText());
final Value value = Variables.register("value", TestData.getValue());
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
rangeLockService.getWriteLock(key, value).lock();
startLatch.countDown();
try {
finishLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
rangeLockService.getWriteLock(key, value).unlock();
}
});
t.start();
startLatch.await();
Assert.assertTrue(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.GREATER_THAN_OR_EQUALS, value)));
finishLatch.countDown();
}
use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class RangeLockServiceTest method testReadBwisRangeBlockedIfWritingGtLowerValue.
@Test
public void testReadBwisRangeBlockedIfWritingGtLowerValue() throws InterruptedException {
final Text key = Variables.register("key", TestData.getText());
final Value value = Variables.register("value", TestData.getValue());
final Value value1 = Variables.register("value1", increase(value));
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Value gtLowerValue = Variables.register("gtLowerValue", increase(value, value1));
rangeLockService.getWriteLock(key, gtLowerValue).lock();
startLatch.countDown();
try {
finishLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
rangeLockService.getWriteLock(key, gtLowerValue).unlock();
}
});
t.start();
startLatch.await();
Assert.assertTrue(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.BETWEEN, value, value1)));
finishLatch.countDown();
}
use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class RangeLockServiceTest method testReadGtIsNotRangeBlockedIfWritingLtValue.
@Test
public void testReadGtIsNotRangeBlockedIfWritingLtValue() throws InterruptedException {
final Text key = Variables.register("key", TestData.getText());
final Value value = Variables.register("value", TestData.getValue());
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Value ltValue = Variables.register("ltValue", decrease(value));
rangeLockService.getWriteLock(key, ltValue).lock();
startLatch.countDown();
try {
finishLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
rangeLockService.getWriteLock(key, ltValue).unlock();
}
});
t.start();
startLatch.await();
Assert.assertFalse(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.GREATER_THAN, value)));
finishLatch.countDown();
}
use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class RangeLockServiceTest method testReadGtisRangeBlockedIfWritingGtValue.
@Test
public void testReadGtisRangeBlockedIfWritingGtValue() throws InterruptedException {
final Text key = Variables.register("key", TestData.getText());
final Value value = Variables.register("value", TestData.getValue());
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Value gtValue = Variables.register("gtValue", increase(value));
rangeLockService.getWriteLock(key, gtValue).lock();
startLatch.countDown();
try {
finishLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
rangeLockService.getWriteLock(key, gtValue).unlock();
}
});
t.start();
startLatch.await();
Assert.assertTrue(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.GREATER_THAN, value)));
finishLatch.countDown();
}
use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class RangeLockServiceTest method testReadBwIsNotRangeBlockedIfWritingGtHigherValue.
@Test
public void testReadBwIsNotRangeBlockedIfWritingGtHigherValue() throws InterruptedException {
final Text key = Variables.register("key", TestData.getText());
final Value value = Variables.register("value", TestData.getValue());
final Value value1 = Variables.register("value1", increase(value));
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Value getHigherValue = Variables.register("gtHigherValue", increase(value1));
rangeLockService.getWriteLock(key, getHigherValue).lock();
startLatch.countDown();
try {
finishLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
rangeLockService.getWriteLock(key, getHigherValue).unlock();
}
});
t.start();
startLatch.await();
Assert.assertFalse(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.BETWEEN, value, value1)));
finishLatch.countDown();
}
Aggregations