I am doing a PoC to connect Cassandra from my java8 application code.
I am using apache Cassandra with java8
To start with I looked and started with
https://github.com/lankydan/datastax-java-driver
Trying to connect my Cassandra cluster
when i download and try to connect the same to my C* cluster I am getting Caused by: java.net.UnknownHostException: 10.24.78.22,10.24.78.108,10.24.79.173
Updated **CassandraConfig**
.addContactPoints(host)
I updated **application.properties** file
cassandra.host=10.24.78.22,10.24.78.108,10.24.79.173
cassandra.cluster.name=My_Cluster
cassandra.port=9042
cassandra.keyspace=rrr_xxx
So what need to be fixed, and how to fix this issue?
the .addContactPoints function accepts an array of the strings, inet addresses, hosts, etc., while you're passing a one string with multiple addresses inside. You need somehow convert this string into array, or pass only one address.
if you already modifying the code, then it should be simply changed to
.addContactPoints(host.split(","))
Related
I am new to Janusgraph. We have janusgraph setup with cassandra as backend.
We are using ConfiguredGraphFactory to dynamically create graphs at runtime. But when trying to open the created graph using ConfiguredGraphFactory.open("graphName") getting the below error
com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at com.datastax.oss.driver.api.core.DriverTimeoutException.copy(DriverTimeoutException.java:34)
at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(CompletableFutures.java:149)
at com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor.process(CqlRequestSyncProcessor.java:53)
at com.datastax.oss.driver.internal.core.cql.CqlRequestSyncProcessor.process(CqlRequestSyncProcessor.java:30)
at com.datastax.oss.driver.internal.core.session.DefaultSession.execute(DefaultSession.java:230)
at com.datastax.oss.driver.api.core.cql.SyncCqlSession.execute(SyncCqlSession.java:54)
We are using single cassandra node and not a cluster. If we are not using ConfiguredGraphFactory we are able to connect to cassandra & it is not a network/wrong port issue.
Any Help would be appreciated.
JanusGraph uses the Java driver to connect to Cassandra. This error comes from the driver and indicates that the nodes didn't respond:
com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
The DriverTimeoutException is different from a read or write timeout. It gets thrown when a request from the driver timed out because it didn't get a response from the Cassandra nodes after 2 seconds (PT2S).
You'll need to check if there's a network route between the JanusGraph server and the Cassandra nodes. One thing to check for is that a firewall is not blocking access to the CQL client port on the C* nodes (default is 9042). Cheers!
Since upgrading to Cassandra Java driver v4.x, we keep seeing the following messages in the client app logs:
[s1] Unknown peer xxx, excluding from schema agreement check
FWIW, xxx seems like a UUID, not an IP.
We are connecting to Azure Cosmos DB using the Cassandra Java driver v4.6.1. The message seems to be emanating from SchemaAgreementChecker, but it's pretty useless because it doesn't suggest any way to fix the supposed problem. After digging into the code, I think the problem is that the following query returns a new host_id each time it's executed.
SELECT host_id, schema_version FROM system.peers;
SchemaAgreementChecker.java#L143
It seems the driver is trying to match up the host_id received from peer gossip with the nodes received from InternalDriverContext. I'm not a Cassandra or Azure admin, so I'm not sure what the implication of this is, but given that this warning wasn't shown before, there's some assumption made in the code that isn't holding up.
Any ideas on what could be done here to get rid of this message?
This is a problem with Azure Cosmos DB which isn't a full implementation of Apache Cassandra but provides an CQL-like API.
The SchemaAgreementChecker.java class was added in Java driver 4.0 (JAVA-1638) and it seems like Azure Cosmos DB isn't fully compliant so try using Java driver 3.x and it should work. Cheers!
Cassandra use consistent hash to manage data, and after we use Cassandra driver to connect the cluster, the node we connect to may query from other nodes in the cluster to get the result. But for my current situation, I'm doing some testing for my algorithm, I want to give a certain tokenRange and query the data in the tokenRange and on a certain node, if some data in the tokenRange isn't in this node, I don't want the node query other node to get the result. Is it possible and how to achieve it?
I find Cassandra Python driver: force using a single node but this solution only provide the client's connection pool connect to a certain node, the node will still query other nodes.
Use the WhiteListRoundRobinPolicy and CL.ONE like linked in other question.
You can also extend the Statement to include a host and a custom load balancing policy to send the request to the host in the wrapper. Extend a policy and override make_query_plan, something like (untested just scratch, consider following pseudo code)
class StatementSingleHostRouting(DCAwareRoundRobinPolicy):
def make_query_plan(self, working_keyspace=None, query=None):
if query.host:
return [query.host]
return DCAwareRoundRobinPolicy.make_query_plan(self, working_keyspace, query)
If that host doesn't own the data it will still query other replicas though.
I added nodes to a cluster which initialy used the wrong network interface as listen_adress. I fixed it by changeing the listen_address to the correct IP. The cluster is running well with that configuration but clients trying to connect to that cluster still receive the wrong IPs as Metadata from cluster. Is there any way to refresh metadata of a cluster whithout decommissioning the nodes and setting up new ones again?
First of all, you may try to follow this advice: http://www.datastax.com/documentation/cassandra/2.1/cassandra/operations/ops_gossip_purge.html
You will need to restart the entire cluster on a rolling basis - one node at a time
If this does not work, try this on each node:
USE system;
SELECT * FROM peers;
Then delete bad records from the peers and restart the node, then go to the next node and do it again.
I might be misunderstanding something here, as it's not clear to me how I should connect to a Cassandra cluster. I have a Cassandra 1.2.1 cluster of 5 nodes managed by Priam, on AWS. i would like to use Astyanax to connect to this cluster by using a code similar to the code bellow:
conPool = new ConnectionPoolConfigurationImpl(getConecPoolName()) .setMaxConnsPerHost(CONNECTION_POOL_SIZE_PER_HOST).setSeeds(MY_IP_SEEDS)
.setMaxOperationsPerConnection(100) // 10000
What should I use as MY_IP_SEEDS? Should I use the IPs of all my nodes split by comma? Or should I use the IP of just 1 machine (the seed machine)? If I use the ip of just one machine, I am worried about overloading this machine with too many requests.
I know Priam has the "get_seeds" REST api (https://github.com/Netflix/Priam/wiki/REST-API) that for each node returns a list of IPs and I also know there is one seed per RAC. However, I am not sure what would happen if the seed node gets down... I would need to connect to others when trying to make new connections, right?
Seed nodes are only for finding the way into the cluster on node startup - no overload problems.
Of course one of the nodes must be reachable and up in the cluster to get the new one up and running.
So the best way is to update the seed list from Priam before starting the node. Priam should be behind an automatically updated DNS entry.
If you're highest availability you should regularly store the current list of seeds from Priam and store them in a mirrored fashion just as you store your puppet or chef config to be able to get nodes up even when Priam isn't reachable.