Examples of ThriftClient


Examples of com.impetus.client.cassandra.thrift.ThriftClient

    private void testINClause()
    {
        if (USE_CQL)
        {
            Map<String, Client> clientMap = (Map<String, Client>) entityManager.getDelegate();
            ThriftClient tc = (ThriftClient) clientMap.get(SEC_IDX_CASSANDRA_TEST);
            tc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);

            Query findQuery;
            List<PersonCassandra> allPersons;
            findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN :idList");
            List<String> idList = new ArrayList<String>();
            idList.add("1");
            idList.add("2");
            idList.add("3");

            findQuery.setParameter("idList", idList);
            allPersons = findQuery.getResultList();
            Assert.assertNotNull(allPersons);
            Assert.assertEquals(3, allPersons.size());

            findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN ?1");
            findQuery.setParameter(1, idList);
            allPersons = findQuery.getResultList();
            Assert.assertNotNull(allPersons);
            Assert.assertEquals(3, allPersons.size());

            entityManager.close();

            entityManager = emf.createEntityManager();

            findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN :idList");
            findQuery.setParameter("idList", new ArrayList<String>());
            allPersons = findQuery.getResultList();
            Assert.assertNotNull(allPersons);
            Assert.assertTrue(allPersons.isEmpty());

            findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.personId IN ('1', '2')");
            allPersons = findQuery.getResultList();
            Assert.assertNotNull(allPersons);
            Assert.assertEquals(2, allPersons.size());

            entityManager.close();

            try
            {
                entityManager = emf.createEntityManager();
                findQuery = entityManager.createQuery("Select p from PersonCassandra p where p.age IN (10 , 20)");
                allPersons = findQuery.getResultList();
                Assert.fail();
            }
            catch (Exception e)
            {
                Assert.assertEquals(
                        "javax.persistence.PersistenceException: com.impetus.kundera.KunderaException: InvalidRequestException(why:IN predicates on non-primary-key columns (AGE) is not yet supported)",
                        e.getMessage());
            }

            tc.setCqlVersion(CassandraConstants.CQL_VERSION_2_0);
        }
        else
        {
            Query findQuery;
            List<PersonCassandra> allPersons;
View Full Code Here

Examples of com.impetus.client.cassandra.thrift.ThriftClient

    }

    private void testCountResult()
    {
        Map<String, Client> clientMap = (Map<String, Client>) entityManager.getDelegate();
        ThriftClient tc = (ThriftClient) clientMap.get(SEC_IDX_CASSANDRA_TEST);
        tc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
        CQLTranslator translator = new CQLTranslator();

        String query = "select count(*) from "
                + translator.ensureCase(new StringBuilder(), "PERSONCASSANDRA", false).toString();
        Query q = entityManager.createNativeQuery(query, PersonCassandra.class);
        List noOfRows = q.getResultList();

        if (USE_CQL)
        {
            Assert.assertEquals(new Long(4),
                    PropertyAccessorHelper.getObject(Long.class, ((Column) noOfRows.get(0)).getValue()));
        }
        else
        {
            Assert.assertEquals(new Long(3),
                    PropertyAccessorHelper.getObject(Long.class, ((Column) noOfRows.get(0)).getValue()));
        }
        Assert.assertEquals("count",
                PropertyAccessorHelper.getObject(String.class, ((Column) noOfRows.get(0)).getName()));

        entityManager.clear();
        q = entityManager.createNamedQuery("q");
        noOfRows = q.getResultList();
        if (USE_CQL)
        {
            Assert.assertEquals(4, noOfRows.size());
        }
        else
        {
            Assert.assertEquals(3, noOfRows.size());
        }
        tc.setCqlVersion(CassandraConstants.CQL_VERSION_2_0);
    }
View Full Code Here

Examples of com.impetus.client.cassandra.thrift.ThriftClient

        String useNativeSql = "USE \"" + schema + "\"";
        EntityManager em = emf.createEntityManager();

        Map<String, Client> clientMap = (Map<String, Client>) em.getDelegate();
        ThriftClient pc = (ThriftClient) clientMap.get("cassandra");
        pc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);

        Query q = em.createNativeQuery(useNativeSql, CassandraEntity.class);
        q.executeUpdate();
        // create column family
        String colFamilySql = "CREATE COLUMNFAMILY users (key varchar PRIMARY KEY,full_name varchar, birth_date int,state varchar)";
View Full Code Here

Examples of com.impetus.client.cassandra.thrift.ThriftClient

        String batchOps = "BEGIN BATCH INSERT INTO CassandraBatchEntity (user_name, password, name) VALUES ('user2', 'ch@ngem3b', 'second user') UPDATE CassandraBatchEntity SET password = 'ps22dhds' WHERE user_name = 'user2' INSERT INTO CassandraBatchEntity (user_name, password) VALUES ('user3', 'ch@ngem3c') DELETE name FROM CassandraBatchEntity WHERE user_name = 'user2' INSERT INTO CassandraBatchEntity (user_name, password, name) VALUES ('user4', 'ch@ngem3c', 'Andrew') APPLY BATCH";

        EntityManager em = emf.createEntityManager();

        Map<String, Client> clientMap = (Map<String, Client>) em.getDelegate();
        ThriftClient pc = (ThriftClient) clientMap.get("cassandra");
        pc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);

        Query q = em.createNativeQuery(useNativeSql);
        // q.getResultList();
        q.executeUpdate();

        pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
        q = em.createNativeQuery(createColumnFamily, CassandraBatchEntity.class);
        // q.getResultList();
        q.executeUpdate();

        pc.setConsistencyLevel(ConsistencyLevel.QUORUM);
        q = em.createNativeQuery(batchOps, CassandraBatchEntity.class);
        // q.getResultList();
        q.executeUpdate();

        q = em.createNativeQuery("select * from CassandraBatchEntity", CassandraBatchEntity.class);
View Full Code Here

Examples of org.apache.cassandra.stress.util.ThriftClient

            try
            {

                SimpleClient sclient = null;
                ThriftClient tclient = null;
                JavaDriverClient jclient = null;

                switch (settings.mode.api)
                {
                    case JAVA_DRIVER_NATIVE:
View Full Code Here

Examples of org.apache.cassandra.stress.util.ThriftClient

                if (queryStatements == null)
                {
                    try
                    {
                        JavaDriverClient jclient = settings.getJavaDriverClient();
                        ThriftClient tclient = settings.getThriftClient();
                        Map<String, PreparedStatement> stmts = new HashMap<>();
                        Map<String, Integer> tids = new HashMap<>();
                        for (Map.Entry<String, String> e : queries.entrySet())
                        {
                            stmts.put(e.getKey().toLowerCase(), jclient.prepare(e.getValue()));
                            tids.put(e.getKey().toLowerCase(), tclient.prepare_cql3_query(e.getValue(), Compression.NONE));
                        }
                        thriftQueryIds = tids;
                        queryStatements = stmts;
                    }
                    catch (TException e)
View Full Code Here

Examples of org.apache.cassandra.stress.util.ThriftClient

            try
            {

                SimpleClient sclient = null;
                ThriftClient tclient = null;
                JavaDriverClient jclient = null;

                switch (settings.mode.api)
                {
                    case JAVA_DRIVER_NATIVE:
View Full Code Here

Examples of org.apache.cassandra.stress.util.ThriftClient

            try
            {

                SimpleClient sclient = null;
                ThriftClient tclient = null;
                JavaDriverClient jclient = null;

                switch (settings.mode.api)
                {
                    case JAVA_DRIVER_NATIVE:
View Full Code Here

Examples of org.apache.cassandra.stress.util.ThriftClient

            try
            {

                SimpleClient sclient = null;
                ThriftClient tclient = null;
                JavaDriverClient jclient = null;

                switch (settings.mode.api)
                {
                    case JAVA_DRIVER_NATIVE:
View Full Code Here

Examples of org.apache.cassandra.stress.util.ThriftClient

                if (queryStatements == null)
                {
                    try
                    {
                        JavaDriverClient jclient = settings.getJavaDriverClient();
                        ThriftClient tclient = settings.getThriftClient();
                        Map<String, PreparedStatement> stmts = new HashMap<>();
                        Map<String, Integer> tids = new HashMap<>();
                        Map<String, SchemaQuery.ArgSelect> args = new HashMap<>();
                        for (Map.Entry<String, StressYaml.QueryDef> e : queries.entrySet())
                        {
                            stmts.put(e.getKey().toLowerCase(), jclient.prepare(e.getValue().cql));
                            tids.put(e.getKey().toLowerCase(), tclient.prepare_cql3_query(e.getValue().cql, Compression.NONE));
                            args.put(e.getKey().toLowerCase(), e.getValue().fields == null
                                                                     ? SchemaQuery.ArgSelect.MULTIROW
                                                                     : SchemaQuery.ArgSelect.valueOf(e.getValue().fields.toUpperCase()));
                        }
                        thriftQueryIds = tids;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.