Package org.scale7.cassandra.pelops

Examples of org.scale7.cassandra.pelops.Selector


        assertTrue("Mutator is not in the expected state", mutator.deleteIfNull);
    }

    @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);
View Full Code Here


        assertEquals("Mutator TTL is not in the expected state", Integer.MAX_VALUE, (int) mutator.ttl);
    }

    @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);
View Full Code Here

        assertEquals("column TTL is not in the expected state", 1234, column.ttl);
    }

    @Test
    public void testNewColumnWithTTLDefaultFromMemberVariable() {
        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"));

        assertEquals("column name is not in the expected state", Bytes.fromUTF8("a").getBytes(), column.name);
View Full Code Here

        assertEquals("column TTL is not in the expected state", Integer.MAX_VALUE, column.ttl);
    }

    @Test
    public void testNewColumnWithTTLNotSet() {
        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"), Mutator.NO_TTL);

        assertEquals("column name is not in the expected state", Bytes.fromUTF8("a").getBytes(), column.name);
View Full Code Here

        assertFalse("column TTL is not in the expected state", column.isSetTtl());
    }

    @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();
    }
View Full Code Here

        {
            if (m.isCounterColumnType())
            {
                try
                {
                    IPooledConnection connection = getConnection();
                    org.apache.cassandra.thrift.Cassandra.Client thriftClient = connection.getAPI();
                    List<KeySlice> ks = thriftClient.get_range_slices(new ColumnParent(m.getTableName()),
                            slicePredicate, Selector.newKeyRange("", "", maxResult), getConsistencyLevel());
                    connection.release();
                    entities = onCounterColumn(m, isRelation, relations, ks);
                }
                catch (InvalidRequestException irex)
                {
                    log.error("Error during executing find, Caused by: .", irex);
View Full Code Here

        Set<String> avoidNodes = null;
    Exception lastException = null;
    int retries = 0;
    do {
      // Get a connection to a Cassandra node
            IPooledConnection conn = null;
            try {
                conn = thrift.getConnectionExcept(avoidNodes);
            } catch (Exception e) {
                // the pool is responsible for blocking and waiting for a connection, so don't retry
                throw operandPolicy.getExceptionTranslator().translate(e);
            }

      try {
        // Execute operation
                // Return result!
        return operation.execute(conn);
      } catch (Exception e) {
                // Should we try again?
                if (e instanceof TimedOutException ||
                    e instanceof TTransportException ||
                    e instanceof UnavailableException) {

                    logger.warn("Operation failed as result of network exception. Connection to node {} is being marked as corrupt " +
                            "(and will probably be be destroyed). Cause of failure is {}", conn.getNode().getAddress(), e);

                    // This connection is "broken" by network timeout or other problem.
                    conn.corrupted();

                    // to avoid create the set for every request create the set here
                    if (avoidNodes == null) avoidNodes = new HashSet<String>(10);
                    avoidNodes.add(conn.getNode().getAddress());

          retries++;
          lastException = e;
        } else if (e instanceof NotFoundException) {
                    // Re-throw application-level exceptions immediately.
          throw operandPolicy.getExceptionTranslator().translate(e);
                } else {
                    // This connection is "broken" by network timeout or other problem.
                    conn.corrupted();

                    // Re-throw application-level exceptions immediately.
          throw operandPolicy.getExceptionTranslator().translate(e);
        }
      } finally {
                conn.release();
            }
    } while (retries < operandPolicy.getMaxOpRetries());

    throw operandPolicy.getExceptionTranslator().translate(lastException);
  }
View Full Code Here

     */
    @Test
    public void testAfterProperties() throws Exception {
        OperandPolicy operandPolicy = new OperandPolicy();
        CommonsBackedPool.Policy policy = new CommonsBackedPool.Policy();
        LeastLoadedNodeSelectionStrategy nodeSelectionStrategy = new LeastLoadedNodeSelectionStrategy();
        NoOpNodeSuspensionStrategy nodeSuspensionStrategy = new NoOpNodeSuspensionStrategy();
        NoOpConnectionValidator connectionValidator = new NoOpConnectionValidator();

        CommonsBackedPoolFactoryBean factoryBean = new CommonsBackedPoolFactoryBean();
        factoryBean.setCluster(AbstractIntegrationTest.cluster);
View Full Code Here

    public void testAfterProperties() throws Exception {
        OperandPolicy operandPolicy = new OperandPolicy();
        CommonsBackedPool.Policy policy = new CommonsBackedPool.Policy();
        LeastLoadedNodeSelectionStrategy nodeSelectionStrategy = new LeastLoadedNodeSelectionStrategy();
        NoOpNodeSuspensionStrategy nodeSuspensionStrategy = new NoOpNodeSuspensionStrategy();
        NoOpConnectionValidator connectionValidator = new NoOpConnectionValidator();

        CommonsBackedPoolFactoryBean factoryBean = new CommonsBackedPoolFactoryBean();
        factoryBean.setCluster(AbstractIntegrationTest.cluster);
        factoryBean.setKeyspace(AbstractIntegrationTest.KEYSPACE);
        factoryBean.setPolicy(policy);
View Full Code Here

    @Test
    public void testAfterProperties() throws Exception {
        OperandPolicy operandPolicy = new OperandPolicy();
        CommonsBackedPool.Policy policy = new CommonsBackedPool.Policy();
        LeastLoadedNodeSelectionStrategy nodeSelectionStrategy = new LeastLoadedNodeSelectionStrategy();
        NoOpNodeSuspensionStrategy nodeSuspensionStrategy = new NoOpNodeSuspensionStrategy();
        NoOpConnectionValidator connectionValidator = new NoOpConnectionValidator();

        CommonsBackedPoolFactoryBean factoryBean = new CommonsBackedPoolFactoryBean();
        factoryBean.setCluster(AbstractIntegrationTest.cluster);
        factoryBean.setKeyspace(AbstractIntegrationTest.KEYSPACE);
View Full Code Here

TOP

Related Classes of org.scale7.cassandra.pelops.Selector

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.