datastax-java-driver

How to set a timeout and throttling rate for a large user defined aggregate query

笑着哭i 提交于 2019-11-29 15:28:34
I'm trying to run a user defined aggregate query to periodically roll up some values in a large table. I'm only trying to aggregate one partition at a time, but each partition can have lots of rows. Once I get past a certain number of rows in a partition, the query starts to fail with a timeout error since it seems to be using a fixed timeout value. But I'm in no hurry for the aggregate query to return results, and I'd like the coordinator node to take its time and aggregate all the rows without timing out. I'd also like to throttle the rate at which it pages through the results so that it

“All host(s) tried for query failed” Error

不打扰是莪最后的温柔 提交于 2019-11-29 14:06:45
问题 My Java code is as follows: import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Metadata; import com.datastax.driver.core.Session; public class CustomerController { public void execute() { Cluster cluster = Cluster.builder() .addContactPoints("172.16.11.126", "172.16.11.130") .withPort(9042) .build(); Session session = cluster.connect(); String command = "drop keyspace if exists bookstore"; session.execute(command); cluster.close(); } } When I run the code, I get the

What is the best way to get backpressure for Cassandra Writes?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 03:42:06
问题 I have a service that consumes messages off of a queue at a rate that I control. I do some processing and then attempt to write to a Cassandra cluster via the Datastax Java client. I have setup my Cassandra cluster with maxRequestsPerConnection and maxConnectionsPerHost . However, in testing I have found that when I have reached maxConnectionsPerHost and maxRequestsPerConnection calls to session.executeAsync don't block. What I am doing right now is using a new Semaphore(maxConnectionsPerHost

Passing parameter to Cassandra CQL query using DataStax client

旧时模样 提交于 2019-11-29 01:50:12
I am using datastax as a client for connecting to cassandra. I have successfully connected to cassandra cluster/keyspace/column families through Java. I am trying, firing some queries on cassandra column family thriugh java. For me it is working for simple queries like ResultSet results = session.execute("select * from demodb.customer where id = 1"); Now I want to take id parameter from user and pass it to session.execute(); statement. How should I go about it? Here is a code example of inserting data about an image using a prepared statements. PreparedStatement statement = getSession()

Prepared Statement with collection in IN clause in Datastax Cassandra CQL driver

落爺英雄遲暮 提交于 2019-11-29 01:39:32
I am trying to run the following query SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ? I bind Java list of Long's as a parameter and I get an exception SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')' (ResultSetFuture.java:242) If I try to use (?) it expects single Long item to be bound, but I need a collection Is there an error in my syntax? Tested in Cassandra 2.1.3, the following code snippet works: PreparedStatement prepared = session.prepare("SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ?;"); List<Long> edgeIds = Arrays.asList(1L, 2L, 3L); session

Cassandra: How to insert a new wide row with good performance using CQL

亡梦爱人 提交于 2019-11-28 20:55:33
I am evaluating cassandra. I am using the datastax driver and CQL. I would like to store some data with the following internal structure, where the names are different for each update. +-------+-------+-------+-------+-------+-------+ | | name1 | name2 | name3 | ... | nameN | | time +-------+-------+-------+-------+-------+ | | val1 | val2 | val3 | ... | valN | +-------+-------+-------+-------|-------+-------+ So time should be the column key, and name should be the row key. The CQL statement I use to create this table is: CREATE TABLE IF NOT EXISTS test.wide ( time varchar, name varchar,

How to set a timeout and throttling rate for a large user defined aggregate query

天涯浪子 提交于 2019-11-28 09:26:24
问题 I'm trying to run a user defined aggregate query to periodically roll up some values in a large table. I'm only trying to aggregate one partition at a time, but each partition can have lots of rows. Once I get past a certain number of rows in a partition, the query starts to fail with a timeout error since it seems to be using a fixed timeout value. But I'm in no hurry for the aggregate query to return results, and I'd like the coordinator node to take its time and aggregate all the rows

Error while connecting to Cassandra using Java Driver for Apache Cassandra 1.0 from com.example.cassandra

我与影子孤独终老i 提交于 2019-11-28 08:08:21
While connecting to Cassandra client using java driver for Cannsandra by DataStax, it is throwing following error.. Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1]) Please suggest... Thanks! My java code is like this: package com.example.cassandra; import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Host; import com.datastax.driver.core.Metadata; public class SimpleClient { private Cluster cluster; public void connect(String node){ cluster = Cluster.builder().addContactPoint

Passing parameter to Cassandra CQL query using DataStax client

ε祈祈猫儿з 提交于 2019-11-27 16:13:52
问题 I am using datastax as a client for connecting to cassandra. I have successfully connected to cassandra cluster/keyspace/column families through Java. I am trying, firing some queries on cassandra column family thriugh java. For me it is working for simple queries like ResultSet results = session.execute("select * from demodb.customer where id = 1"); Now I want to take id parameter from user and pass it to session.execute(); statement. How should I go about it? 回答1: Here is a code example of

Prepared Statement with collection in IN clause in Datastax Cassandra CQL driver

我的未来我决定 提交于 2019-11-27 16:03:47
问题 I am trying to run the following query SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ? I bind Java list of Long's as a parameter and I get an exception SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')' (ResultSetFuture.java:242) If I try to use (?) it expects single Long item to be bound, but I need a collection Is there an error in my syntax? 回答1: Tested in Cassandra 2.1.3, the following code snippet works: PreparedStatement prepared = session.prepare("SELECT edge_id