Search in sources :

Example 26 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class RangeLockServiceTest method testReadLteisRangeBlockedIfWritingLtValue.

@Test
public void testReadLteisRangeBlockedIfWritingLtValue() 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.assertTrue(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.LESS_THAN_OR_EQUALS, value)));
    finishLatch.countDown();
}
Also used : Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest)

Example 27 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class RangeLockServiceTest method testReadLtIsRangeBlockedIfWritingLtValue.

@Test
public void testReadLtIsRangeBlockedIfWritingLtValue() 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.assertTrue(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.LESS_THAN, value)));
    finishLatch.countDown();
}
Also used : Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest)

Example 28 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class RangeLockServiceTest method testReadGtIsNotRangeBlockedIfWritingEqValue.

@Test
public void testReadGtIsNotRangeBlockedIfWritingEqValue() 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.assertFalse(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.GREATER_THAN, value)));
    finishLatch.countDown();
}
Also used : Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest)

Example 29 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class RangeLockServiceTest method testReadBwIsNotRangeBlockedIfWritingEqHigherValue.

@Test
public void testReadBwIsNotRangeBlockedIfWritingEqHigherValue() 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() {
            rangeLockService.getWriteLock(key, value1).lock();
            startLatch.countDown();
            try {
                finishLatch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            rangeLockService.getWriteLock(key, value1).unlock();
        }
    });
    t.start();
    startLatch.await();
    Assert.assertFalse(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.BETWEEN, value, value1)));
    finishLatch.countDown();
}
Also used : Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest)

Example 30 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class RangeLockServiceTest method testReadBwIsNotRangeBlockedIfWritingLtLowerValue.

@Test
public void testReadBwIsNotRangeBlockedIfWritingLtLowerValue() 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 ltLowerValue = Variables.register("ltLowerValue", decrease(value));
            rangeLockService.getWriteLock(key, ltLowerValue).lock();
            startLatch.countDown();
            try {
                finishLatch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            rangeLockService.getWriteLock(key, ltLowerValue).unlock();
        }
    });
    t.start();
    startLatch.await();
    Assert.assertFalse(rangeLockService.isRangeBlocked(LockType.READ, RangeToken.forReading(key, Operator.BETWEEN, value, value1)));
    finishLatch.countDown();
}
Also used : Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest)

Aggregations

Value (com.cinchapi.concourse.server.model.Value)73 Text (com.cinchapi.concourse.server.model.Text)60 Test (org.junit.Test)43 ConcourseBaseTest (com.cinchapi.concourse.test.ConcourseBaseTest)34 Identifier (com.cinchapi.concourse.server.model.Identifier)25 CountDownLatch (java.util.concurrent.CountDownLatch)22 Set (java.util.Set)14 Operator (com.cinchapi.concourse.thrift.Operator)10 Action (com.cinchapi.concourse.server.storage.Action)6 Range (com.google.common.collect.Range)6 LinkedHashSet (java.util.LinkedHashSet)6 TObject (com.cinchapi.concourse.thrift.TObject)5 LazyTransformSet (com.cinchapi.common.collect.lazy.LazyTransformSet)3 RangeToken (com.cinchapi.concourse.server.concurrent.RangeToken)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 ByteBuffer (java.nio.ByteBuffer)3 Path (java.nio.file.Path)3 NavigableSet (java.util.NavigableSet)3 CoalescableTreeMap (com.cinchapi.common.collect.CoalescableTreeMap)2 Position (com.cinchapi.concourse.server.model.Position)2