Search in sources :

Example 6 with IThriftPool

use of org.scale7.cassandra.pelops.pool.IThriftPool in project scale7-pelops by s7.

the class Pelops method removePool.

/**
     * Removes and shuts down a  previously added Thrift connection pool.
     *
     * @param poolName A name used to reference the pool e.g. "MainDatabase" or "LucandraIndexes"
     */
public static void removePool(String poolName) {
    logger.info("Pelops removes pool {}", poolName);
    IThriftPool pool = poolMap.remove(poolName);
    if (// avoid null pointers
    pool != null)
        pool.shutdown();
}
Also used : IThriftPool(org.scale7.cassandra.pelops.pool.IThriftPool)

Example 7 with IThriftPool

use of org.scale7.cassandra.pelops.pool.IThriftPool in project scale7-pelops by s7.

the class MutatorIntegrationTest method testConstructorArgs.

@Test
public void testConstructorArgs() {
    IThriftPool pool = Mockito.mock(IThriftPool.class);
    Mutator mutator = new Mutator(pool, Long.MAX_VALUE, true, Integer.MAX_VALUE);
    assertEquals("Mutator timestamp is not in the expected state", Long.MAX_VALUE, mutator.timestamp);
    assertTrue("Mutator deleteIfNull is not in the expected state", mutator.deleteIfNull);
    assertEquals("Mutator TTL is not in the expected state", Integer.MAX_VALUE, (int) mutator.ttl);
}
Also used : IThriftPool(org.scale7.cassandra.pelops.pool.IThriftPool) Test(org.junit.Test) AbstractIntegrationTest(org.scale7.cassandra.pelops.support.AbstractIntegrationTest)

Example 8 with IThriftPool

use of org.scale7.cassandra.pelops.pool.IThriftPool in project scale7-pelops by s7.

the class MutatorIntegrationTest method testWriteColumnsWithDeleteIfNullFromConstructor.

@Test
public void testWriteColumnsWithDeleteIfNullFromConstructor() throws Exception {
    IThriftPool pool = new DebuggingPool(getCluster(), KEYSPACE, new OperandPolicy(3, true));
    Bytes rowKey = Bytes.fromLong(Long.MAX_VALUE);
    Bytes colName1 = Bytes.fromInt(1);
    Bytes colName2 = Bytes.fromInt(2);
    Mutator mutator = pool.createMutator();
    assertTrue("Mutator is not in a valid state for this test", mutator.deleteIfNull);
    List<Column> columns = mutator.newColumnList(mutator.newColumn(colName1, (Bytes) null), mutator.newColumn(colName2, Bytes.fromInt(1)));
    mutator.writeColumns(CF, rowKey, columns);
    // make sure there is at least one deletion
    boolean isOneDeletion = false;
    for (Mutation mutation : mutator.getMutationList(CF, rowKey)) {
        if (mutation.isSetDeletion()) {
            isOneDeletion = true;
            break;
        }
    }
    assertTrue("There should be one deletion", isOneDeletion);
    pool.shutdown();
}
Also used : Column(org.apache.cassandra.thrift.Column) IThriftPool(org.scale7.cassandra.pelops.pool.IThriftPool) Mutation(org.apache.cassandra.thrift.Mutation) DebuggingPool(org.scale7.cassandra.pelops.pool.DebuggingPool) Test(org.junit.Test) AbstractIntegrationTest(org.scale7.cassandra.pelops.support.AbstractIntegrationTest)

Example 9 with IThriftPool

use of org.scale7.cassandra.pelops.pool.IThriftPool in project scale7-pelops by s7.

the class MutatorIntegrationTest method testConstructorDeleteIfNullFromPolicyState.

@Test
public void testConstructorDeleteIfNullFromPolicyState() {
    OperandPolicy policy = new OperandPolicy();
    policy.setDeleteIfNull(true);
    IThriftPool pool = Mockito.mock(IThriftPool.class);
    Mockito.when(pool.getOperandPolicy()).thenReturn(policy);
    Mutator mutator = new Mutator(pool);
    assertTrue("Mutator is not in the expected state", mutator.deleteIfNull);
}
Also used : IThriftPool(org.scale7.cassandra.pelops.pool.IThriftPool) Test(org.junit.Test) AbstractIntegrationTest(org.scale7.cassandra.pelops.support.AbstractIntegrationTest)

Example 10 with IThriftPool

use of org.scale7.cassandra.pelops.pool.IThriftPool in project scale7-pelops by s7.

the class MutatorIntegrationTest method testNewColumnWithTTL.

@Test
public void testNewColumnWithTTL() {
    IThriftPool pool = Mockito.mock(IThriftPool.class);
    Mutator mutator = new Mutator(pool, Long.MAX_VALUE, true, Integer.MAX_VALUE);
    Column column = mutator.newColumn(Bytes.fromUTF8("a"), Bytes.fromUTF8("b"), 1234);
    assertEquals("column name is not in the expected state", Bytes.fromUTF8("a").getBytes(), column.name);
    assertEquals("column value is not in the expected state", Bytes.fromUTF8("b").getBytes(), column.value);
    assertEquals("column TTL is not in the expected state", 1234, column.ttl);
}
Also used : Column(org.apache.cassandra.thrift.Column) IThriftPool(org.scale7.cassandra.pelops.pool.IThriftPool) Test(org.junit.Test) AbstractIntegrationTest(org.scale7.cassandra.pelops.support.AbstractIntegrationTest)

Aggregations

IThriftPool (org.scale7.cassandra.pelops.pool.IThriftPool)11 Test (org.junit.Test)7 AbstractIntegrationTest (org.scale7.cassandra.pelops.support.AbstractIntegrationTest)7 Column (org.apache.cassandra.thrift.Column)4 CommonsBackedPool (org.scale7.cassandra.pelops.pool.CommonsBackedPool)2 Mutation (org.apache.cassandra.thrift.Mutation)1 DebuggingPool (org.scale7.cassandra.pelops.pool.DebuggingPool)1