Package org.scale7.cassandra.pelops

Examples of org.scale7.cassandra.pelops.Selector


        Assert.notNull(getCluster(), "The cluster property is required");
        Assert.notNull(getKeyspace(), "The keyspace property is required");

        logger.info("Initializing Pelops pool keyspace {} for nodes {}", getKeyspace(), Arrays.toString(getCluster().getNodes()));

        this.thriftPool = new CommonsBackedPool(
                getCluster(), getKeyspace(), getPolicy(), getOperandPolicy(), getNodeSelectionStrategy(),
                getNodeSuspensionStrategy(), getConnectionValidator()
        );
    }
View Full Code Here


   * @param poolName        A name used to reference the pool e.g. "MainDatabase" or "LucandraIndexes"
   * @param cluster        The Cassandra cluster that network connections will be made to
   * @param keyspace        The keyspace in the Cassandra cluster against which pool operations will apply
   */
  public static void addPool(String poolName, Cluster cluster, String keyspace) {
        IThriftPool pool = new CommonsBackedPool(cluster, keyspace);
    addPool(poolName, pool);
  }
View Full Code Here

     * @param keyspace        The keyspace in the Cassandra cluster against which pool operations will apply
     * @param policy                The configuration used by the pool
     * @param operandPolicy         The configuration used by the {@link org.scale7.cassandra.pelops.Operand}
     */
  public static void addPool(String poolName, Cluster cluster, String keyspace, CommonsBackedPool.Policy policy, OperandPolicy operandPolicy) {
        IThriftPool pool = new CommonsBackedPool(cluster, keyspace, policy, operandPolicy);
    addPool(poolName, pool);
  }
View Full Code Here

        assertNull("The factory should not have created the pool at this point", factoryBean.getObject());

        try {
            factoryBean.afterPropertiesSet();

            CommonsBackedPool pool = (CommonsBackedPool) factoryBean.getObject();
            assertNotNull("The factory didn't initialize the pool", pool);
            assertNotNull("The factory didn't initialize a default operand policy instance", pool.getOperandPolicy());
            assertNotNull("The factory didn't initialize a default pool config instance", pool.getPolicy());
            assertNotNull("The factory didn't initialize a default node selection policy instance", pool.getNodeSelectionStrategy());
            assertNotNull("The factory didn't initialize a default node suspension policy instance", pool.getNodeSuspensionStrategy());
            assertNotNull("The factory didn't initialize a default connection validator policy instance", pool.getConnectionValidator());
        } finally {
            factoryBean.destroy();
        }
    }
View Full Code Here

        assertNull("The factory should not have created the pool at this point", factoryBean.getObject());

        try {
            factoryBean.afterPropertiesSet();

            CommonsBackedPool pool = (CommonsBackedPool) factoryBean.getObject();
            assertNotNull("The factory didn't initialize the pool", pool);
            assertTrue("The factory didn't use the provided operand policy instance", operandPolicy == pool.getOperandPolicy());
            assertTrue("The factory didn't use the provided config instance", policy == pool.getPolicy());
            assertTrue("The factory didn't use the provided config instance", cluster == pool.getCluster());
            assertTrue("The factory didn't use the provided node selection instance", nodeSelectionStrategy == pool.getNodeSelectionStrategy());
            assertTrue("The factory didn't use the provided node suspension instance", nodeSuspensionStrategy == pool.getNodeSuspensionStrategy());
            assertTrue("The factory didn't use the provided connection validator instance", connectionValidator == pool.getConnectionValidator());
        } finally {
            factoryBean.destroy();
        }
    }
View Full Code Here

                {
                    logger.info("Initializing connection pool for keyspace {}, host {},port {}.", keyspace,
                            cassandraHost.getHost(), cassandraHost.getPort());
                }

                Policy policy = PelopsUtils.getPoolConfigPolicy(cassandraHost);

                // Add pool with specified policy. null means default operand
                // policy.
                Pelops.addPool(poolName, cluster, keyspace, policy, null);
                hostPools.put(cassandraHost, Pelops.getDbConnPool(poolName));
View Full Code Here

            keyspace = (String) props.get(PersistenceProperties.KUNDERA_KEYSPACE);
        }
        String poolName = PelopsUtils.generatePoolName(cassandraHost.getHost(), cassandraHost.getPort(), keyspace);
        Cluster cluster = new Cluster(cassandraHost.getHost(), new IConnection.Config(cassandraHost.getPort(), true,
                -1, PelopsUtils.getAuthenticationRequest(cassandraHost.getUser(), cassandraHost.getPassword())), false);
        Policy policy = PelopsUtils.getPoolConfigPolicy(cassandraHost);
        try
        {
            Pelops.addPool(poolName, cluster, keyspace, policy, null);
            hostPools.put(cassandraHost, Pelops.getDbConnPool(poolName));
            return true;
View Full Code Here

         */
        private final class ShufflingCompare implements Comparator<Object>
        {
            public int compare(Object o1, Object o2)
            {
                Policy policy1 = ((CommonsBackedPool) ((IThriftPool) o1)).getPolicy();
                Policy policy2 = ((CommonsBackedPool) ((IThriftPool) o2)).getPolicy();

                int activeConnections1 = ((CommonsBackedPool) ((IThriftPool) o1)).getConnectionsActive();
                int activeConnections2 = ((CommonsBackedPool) ((IThriftPool) o2)).getConnectionsActive();

                return (policy1.getMaxActivePerNode() - activeConnections1)
                        - (policy2.getMaxActivePerNode() - activeConnections2);
            }
View Full Code Here

     * @param puProperties
     * @return the pool config policy
     */
    public static Policy getPoolConfigPolicy(com.impetus.client.cassandra.service.CassandraHost cassandraHost)
    {
        Policy policy = new Policy();
        if (cassandraHost.getMaxActive() > 0)
        {
            policy.setMaxActivePerNode(cassandraHost.getMaxActive());
        }
        if (cassandraHost.getMaxIdle() > 0)
        {
            policy.setMaxIdlePerNode(cassandraHost.getMaxIdle());
        }
        if (cassandraHost.getMinIdle() > 0)
        {
            policy.setMinIdlePerNode(cassandraHost.getMinIdle());
        }
        if (cassandraHost.getMaxTotal() > 0)
        {
            policy.setMaxTotal(cassandraHost.getMaxTotal());
        }
        return policy;
    }
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

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.