Open jamesxukun opened 10 years ago
@jamesxukun
Can you share further details on how have you set up this connection and pool and how do you use the same ? Also, please take a look at the following to check if it helps :
Chhavi
Thanks for your quick reply.
Here is my persistence.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="cassandra">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.dialect" value="cassandra"/>
<property name="cql.version" value="3.0.0"/>
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory"/>
<!-- other deployment specific parameters should be provided in a separate properties file -->
<property name="kundera.keyspace" value="cls_new"/>
<property name="kundera.nodes" value="localhost"/>
<property name="kundera.port" value="9160"/>
<property name="kundera.username" value="ucontrol"/>
<property name="kundera.password" value="test"/>
<property name="kundera.pool.size.min.idle" value="5" />
<property name="kundera.pool.size.max.active" value="50" />
<property name="kundera.pool.size.max.total" value="100" />
<property name="kundera.ddl.auto.prepare" value="validate"/>
<property name="kundera.client.property" value="kunderaLoadConfig.xml" />
</properties>
</persistence-unit>
</persistence>
And the kunderaLoadConfig.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<clientProperties>
<datastores>
<dataStore>
<name>cassandra</name>
<connection>
<servers>
</servers>
<!-- Load balancing specific configuration -->
<properties>
<property name="loadbalancing.policy" value="roundrobin"></property>
<property name="retry" value="true"></property>
<property name="retry.delay" value="1"></property>
<property name="max.wait" value="3000"></property>
<property name="testonborrow" value="true"></property>
<property name="testwhileidle" value="true"></property>
<property name="testonconnect" value="true"></property>
<property name="testonreturn" value="true"></property>
<property name="failover.policy" value="on.fail.try.one.next.available"></property>
</properties>
</connection>
</dataStore>
</datastores>
</clientProperties>
But, every time, after the cassandra db is restarted, I always get thrift exception, looks like the testonborrow or retry settings don't work.
Properties defined in persistence.xml:
<properties>
<property name="kundera.dialect" value="cassandra"/>
<property name="cql.version" value="3.0.0"/>
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory"/>
<!-- other deployment specific parameters should be provided in a separate properties file -->
<property name="kundera.keyspace" value="cls_new"/>
<property name="kundera.nodes" value="localhost"/>
<property name="kundera.port" value="9160"/>
<property name="kundera.username" value="ucontrol"/>
<property name="kundera.password" value="test"/>
<property name="kundera.pool.size.min.idle" value="5" />
<property name="kundera.pool.size.max.active" value="50" />
<property name="kundera.pool.size.max.total" value="100" />
<property name="kundera.ddl.auto.prepare" value="validate"/>
<property name="kundera.client.property" value="kunderaLoadConfig.xml" />
</properties>
And properties in kunderaLoadConfig.xml:
<properties>
<property name="loadbalancing.policy" value="roundrobin"></property>
<property name="retry" value="true"></property>
<property name="retry.delay" value="1"></property>
<property name="max.wait" value="3000"></property>
<property name="testonborrow" value="true"></property>
<property name="testwhileidle" value="true"></property>
<property name="testonconnect" value="true"></property>
<property name="testonreturn" value="true"></property>
<property name="failover.policy" value="on.fail.try.one.next.available"></property>
</properties>
</connection>
Properties defined in persistence.xml:
property name="kundera.keyspace" value="cls_new"/>
property name="kundera.nodes" value="localhost"/>
property name="kundera.port" value="9160"/>
property name="kundera.username" value="ucontrol"/>
property name="kundera.password" value="test"/>
property name="kundera.pool.size.min.idle" value="5" />
property name="kundera.pool.size.max.active" value="50" />
property name="kundera.pool.size.max.total" value="100" />
property name="kundera.ddl.auto.prepare" value="validate"/>
property name="kundera.client.property" value="kunderaLoadConfig.xml" />
And properties in kunderaLoadConfig.xml: properties> property name="loadbalancing.policy" value="roundrobin"> property name="retry" value="true"> property name="retry.delay" value="1"> property name="max.wait" value="3000"> property name="testonborrow" value="true"> property name="testwhileidle" value="true"> property name="testonconnect" value="true"> property name="testonreturn" value="true"> property name="failover.policy" value="on.fail.try.one.next.available">/property> /properties> /connection>
-->
@jamesxukun
Please try upgrading Kundera to 2.11.1 or to latest version as a fix for same has been added. Please check the following issue for reference #554
Chhavi
Thanks, I will try it. A general question, is the load balancer configuration taken by Thrift client? For me, seems not, how I can confirm that the configuration works as defined?
You can test your configuration testing by obtaining CassandraHostConfiguration as done in
Hope that Helps ! Chhavi
I have a connection pool set up with com.impetus.client.cassandra.thrift.ThriftClientFactory client. After I restart Cassandra database, the connection in the pool was not renewed, so I kept getting following network exception:
Caused by: org.apache.thrift.transport.TTransportException at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
Could you let me know how to solve the issue, I am in 2.11 version.