dev
dev

Reputation: 2979

Connecting Kundera to Cassandra Cluster

Now that I have a Cassandra cluster with multiple nodes, how should I choose a node to connect to from my Java code? Obviously, I can connect to any node, but what's the best way of going about doing that?

For instance, I've been reading up on Kundera and from what I've seen you define a connection like so:

<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_1_0.xsd"
    version="1.0">
    <persistence-unit name="myPersistenceUnit">
        <provider>com.impetus.kundera.ejb.KunderaPersistence</provider>
        <properties>
            <!-- 2nd level cache  -->
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="9160" />
            <property name="kundera.keyspace" value="Keyspace1" />
            <property name="sessionless" value="false" />
            <property name="kundera.client" value="com.impetus.kundera.client.PelopsClient" />
            <property name="kundera.annotations.scan.package" value="com.mypackage" />            
        </properties>
    </persistence-unit>
</persistence>

The problem is that kundera.nodes accepts a single ip address. Is there a way to specify multiple IP addresses so that if one node fails it will try another in my cluster?

Thank you

Upvotes: 1

Views: 420

Answers (1)

vivek mishra
vivek mishra

Reputation: 1162

As a workaround, you may want to try load balancer such as HAProxy to cater such things. Kundera team is working on this feature but till that time you can go ahead with such workarounds.

-Vivek

Upvotes: 1

Related Questions