Package com.netflix.astyanax.recipes.uniqueness

Examples of com.netflix.astyanax.recipes.uniqueness.MultiRowUniquenessConstraint


        }
    }
   
    @Test
    public void testMultiLock() {
        MultiRowUniquenessConstraint unique = new MultiRowUniquenessConstraint(keyspace)
            .withConsistencyLevel(ConsistencyLevel.CL_ONE)
            .withTtl(60)
            .withLockId("abc")
            .withColumnPrefix("prefix_")
            .withRow(UNIQUE_CF, "testMultiLock_A")
            .withRow(UNIQUE_CF, "testMultiLock_B");
       
        ColumnPrefixUniquenessConstraint<String> singleUnique
            = new ColumnPrefixUniquenessConstraint<String>(keyspace, UNIQUE_CF, "testMultiLock_A")
                .withConsistencyLevel(ConsistencyLevel.CL_ONE)
                .withPrefix("prefix_");
        try {
            unique.acquire();
            String uniqueColumn = singleUnique.readUniqueColumn();
            Assert.assertEquals("abc", uniqueColumn);
            LOG.info("UniqueColumn: " + uniqueColumn);
        }
        catch (Exception e) {
            Assert.fail(e.getMessage());
        }
       
        MultiRowUniquenessConstraint unique2 = new MultiRowUniquenessConstraint(keyspace)
            .withTtl(60)
            .withConsistencyLevel(ConsistencyLevel.CL_ONE)
            .withColumnPrefix("prefix_")
            .withRow(UNIQUE_CF, "testMultiLock_B");
        try {
            unique2.acquire();
            Assert.fail();
        }
        catch (Exception e) {
            LOG.info(e.getMessage());
        }
       
        try {
            Assert.assertEquals("abc", singleUnique.readUniqueColumn());
            unique.release();
        }
        catch (Exception e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }
       
        try {
            unique2.acquire();
        }
        catch (Exception e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }
       
        try {
            unique2.release();
        } catch (Exception e) {
            LOG.error(e.getMessage());
            Assert.fail();
        }
    }
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.recipes.uniqueness.MultiRowUniquenessConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.