Package org.scale7.cassandra.pelops.pool

Examples of org.scale7.cassandra.pelops.pool.CommonsBackedPool$ConnectionFactory


      return rowKey;
    }

    public static void validateColumn(Column column) {
      if (!column.isSetName())
        throw new ModelException("Column name is null");
      if (!column.isSetValue())
        throw new ModelException("Column value is null");
  }
View Full Code Here


        throw new ModelException("Column value is null");
  }

    public static void validateColumn(CounterColumn column) {
      if (!column.isSetName())
        throw new ModelException("Column name is null");
      if (!column.isSetValue())
        throw new ModelException("Column value is null");
  }
View Full Code Here

      for (Bytes n : names) validateColumnName(n);
  }

    public static void validateColumnName(Bytes name) {
    if (name == null || name.isNull())
      throw new ModelException("Column name is null");
  }
View Full Code Here

       
        try {
            connection = new PooledConnection(nodes[index], keyspace);
            connection.open();
        } catch (Exception e) {
            throw new NoConnectionsAvailableException();
        }

        return connection;
    }
View Full Code Here

            logger.error(
                    "Failed to get a connection within the configured wait time because there are no available nodes. " +
                            "This possibly indicates that either the suspension strategy is too aggressive or that your " +
                            "cluster is in a bad way."
            );
            throw new NoConnectionsAvailableException("Failed to get a connection within the configured max wait time.");
        }

        if (connection == null) {
            logger.error(
                    "Failed to get a connection within the maximum allowed wait time.  " +
                            "Try increasing the either the number of allowed connections or the max wait time."
            );
            throw new NoConnectionsAvailableException("Failed to get a connection within the configured max wait time.");
        }

        logger.debug("Borrowing connection '{}'", connection);
        statistics.connectionsActive.incrementAndGet();
        reportConnectionBorrowed(connection.getNode().getAddress());
View Full Code Here

                logger.debug("Attempting to borrow free connection for node '{}'", node.getAddress());
                // note that if no connections are currently available for this node then the pool will sleep for
                // DEFAULT_WAIT_PERIOD milliseconds
                connection = pool.borrowObject(node.getAddress());
            } catch (IllegalStateException e) {
                throw new PelopsException("The pool has been shutdown", e);
            } catch (Exception e) {
                if (e instanceof NoSuchElementException) {
                    logger.debug("No free connections available for node '{}'.  Trying another node...", node.getAddress());
                } else if (e instanceof TTransportException) {
                    logger.warn(String.format("A TTransportException was thrown while attempting to create a connection to '%s'.  " +
View Full Code Here

        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

TOP

Related Classes of org.scale7.cassandra.pelops.pool.CommonsBackedPool$ConnectionFactory

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.