Package org.scale7.cassandra.pelops

Examples of org.scale7.cassandra.pelops.ClusterUnitTest


        if (logger.isInfoEnabled())
        {
            // logger.info("Initializing pelops client for persistence unit {}",
            // persistenceUnit);
        }
        IThriftPool pool = getPoolUsingPolicy();
        return new PelopsClient(indexManager, reader, this, persistenceUnit, externalProperties, pool, kunderaMetadata,
                timestampGenerator);
    }
View Full Code Here


        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    IPooledConnection getConnection(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            success = true;
            if (iThriftPool != null)
            {
                Node[] nodes = ((CommonsBackedPool) iThriftPool).getCluster().getNodes();
                String host = nodes[0].getAddress();
                int thriftPort = ((CommonsBackedPool) iThriftPool).getCluster().getConnectionConfig().getThriftPort();
                CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                        nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig()
                                .getThriftPort());
                if (cassandraHost.isTestOnBorrow())
                {
                    if (cassandraHost.isTestOnBorrow() && CassandraUtilities.verifyConnection(host, thriftPort))
                    {
                        // logger.info("Returning connection of {} :{} .",
                        // nodes[0].getAddress(), thriftPort);
                        return iThriftPool.getConnection();
                    }
                    removePool(iThriftPool);
                }
                else
                {
                    // logger.info("Returning connection of {} :{} .",
                    // nodes[0].getAddress(), thriftPort);
                    return iThriftPool.getConnection();
                }
                removePool(iThriftPool);
            }
            success = false;
            iThriftPool = getPoolUsingPolicy();
View Full Code Here

        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    Mutator getMutator(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            success = true;
            if (iThriftPool != null)
            {
                Node[] nodes = ((CommonsBackedPool) iThriftPool).getCluster().getNodes();
                String host = nodes[0].getAddress();
                int thriftPort = ((CommonsBackedPool) iThriftPool).getCluster().getConnectionConfig().getThriftPort();
                CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                        nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig()
                                .getThriftPort());
                if (cassandraHost.isTestOnBorrow())
                {
                    if (cassandraHost.isTestOnBorrow() && CassandraUtilities.verifyConnection(host, thriftPort))
                    {
                        // logger.info("Returning mutator of {} :{} .",
                        // nodes[0].getAddress(), thriftPort);
                        return Pelops.createMutator(PelopsUtils.getPoolName(iThriftPool));
                    }
                    removePool(iThriftPool);
                }
                else
                {
                    return iThriftPool.createMutator();
                }
            }
            success = false;
            iThriftPool = getPoolUsingPolicy();
        }
View Full Code Here

        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    Selector getSelector(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            if (iThriftPool != null)
            {
View Full Code Here

        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    RowDeletor getRowDeletor(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            if (iThriftPool != null)
            {
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

     *
     * @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 (pool != null) // avoid null pointers
            pool.shutdown();
    }
View Full Code Here

                .setSubcomparator_type(CFDEF_COMPARATOR_BYTES)));
  }

    @Test
    public void testConstructorDeleteIfNullState() {
        IThriftPool pool = Mockito.mock(IThriftPool.class);
        Mutator mutator = new Mutator(pool, System.currentTimeMillis(), true);
        assertTrue("Mutator is not in the expected state", mutator.deleteIfNull);
    }
View Full Code Here

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

TOP

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

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.