Search in sources :

Example 6 with Cluster

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

the class Pelops method addPool.

/**
	 * Add a new Thrift connection pool for a specific cluster and keyspace. The name given to the pool is later used
	 * when creating operands such as <code>Mutator</code> and <code>Selector</code>.
	 * @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
     * @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);
}
Also used : IThriftPool(org.scale7.cassandra.pelops.pool.IThriftPool) CommonsBackedPool(org.scale7.cassandra.pelops.pool.CommonsBackedPool)

Example 7 with Cluster

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

the class CommonsBackedPoolFactoryBean method afterPropertiesSet.

/**
     * Initializes the Pelops pool.
     * @throws Exception if an error occurs
     */
@Override
public void afterPropertiesSet() throws Exception {
    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());
}
Also used : CommonsBackedPool(org.scale7.cassandra.pelops.pool.CommonsBackedPool)

Aggregations

CommonsBackedPool (org.scale7.cassandra.pelops.pool.CommonsBackedPool)4 Test (org.junit.Test)2 OperandPolicy (org.scale7.cassandra.pelops.OperandPolicy)2 IThriftPool (org.scale7.cassandra.pelops.pool.IThriftPool)2 AbstractIntegrationTest (org.scale7.cassandra.pelops.support.AbstractIntegrationTest)2 SocketException (java.net.SocketException)1 HashMap (java.util.HashMap)1 NoSuchElementException (java.util.NoSuchElementException)1 CfDef (org.apache.cassandra.thrift.CfDef)1 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)1 KsDef (org.apache.cassandra.thrift.KsDef)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1 Cluster (org.scale7.cassandra.pelops.Cluster)1 ColumnFamilyManager (org.scale7.cassandra.pelops.ColumnFamilyManager)1 IConnection (org.scale7.cassandra.pelops.IConnection)1 KeyspaceManager (org.scale7.cassandra.pelops.KeyspaceManager)1 NoConnectionsAvailableException (org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException)1 PelopsException (org.scale7.cassandra.pelops.exceptions.PelopsException)1 LeastLoadedNodeSelectionStrategy (org.scale7.cassandra.pelops.pool.LeastLoadedNodeSelectionStrategy)1