Kundera multiple node support
Hi, Is there any posibility to set multiple node for Kundera? It's a important feature for us, because we plan to use Cassandra + Kundera on production level and balancing is very critical. Currently we have a workarounds but most preffered way to have native support from Kundera. Thanks!
cassandra 1.1.5 kundera 2.4
Kundera 2.5 will be releasing in coming week. Work on load balancer and multiple node support is planned for future releases and still in very early stages.
Sincerely, -Vivek
Thanks for your quick response. Will be wait for any updates!
Thanks. We will try to push it on priority. Till then, if other workarounds works for you and in case of any issues regarding Kundera for moving into production. Please feel free to raise issues for quick support!
Cheers, -Vivek
+1
@eld0 can you provide details on your workaround?
You may try using HAProxy as a workaround.
-Vivek
Can you detail further? I mean, I write a row to a different host, based on the selected load-balancing algorithm and then the machine replicates to other nodes?
Can I have a cluster but use it in Kundera as a single node?
Not really. You can use as a load balancer and say you a cassandra cluster of 3 nodes. Replication would be handled by Cassandra conifgurations itself(based on selected strategy and replication factor). Configure Kundera with ip where HAProxy is installed and rest it will route to your cassandra nodes. You can find multiple tutorials for such things. Here is one of them: http://blog.rimuhosting.com/2011/07/05/easy-web-serve-load-balancing-with-haproxy/
Hope it helps.
-Vivek
I use HAProxy a lot and know how it works, both for HTTP servers and TCP and I think you just basically said almost the same I assumed. But clarifying:
-
We have two configurations, Kundera and each node configuration, right?
-
If yes, Kundera configuration should map a single host (an IP/hostname with HAProxy) or should it have the information about all the nodes, replication, etc.?
-
The host to which HAProxy delivers the request will replicate as configured locally (in the node), right?
Ok.
- We have two configurations, Kundera and each node configuration, right?
Yes - If yes, Kundera configuration should map a single host (an IP/hostname with HAProxy) or should it have the information about all the nodes, replication, etc.? `` Should map to single host.
3) The host to which HAProxy delivers the request will replicate as configured locally (in the node), right?
``
Yes
-Vivek
Thanks @mevivs. Your help has been truly valuable to me!
Hi, Do you have any news about this enhancement? When you plan to release it?
AFAIK, this is in the works and should be included in 2.6.
Hi, we also are very intrested in this - could you please clarify if this still goes to 2.6 which is in 8 days?
Yes. This will be released in 2.6. I will post an update once this is checked-in in current trunk.
-Vivek
Multiple node support has been added in Kundera for Cassandra. Please refer https://github.com/impetus-opensource/Kundera/wiki/Using-multiple-node-support-and-load-balancing-policy-in-Kundera for more details.
Will be releasing with 2.6
-Vivek
Great news! I'll check that. Big thanks!
I am trying out the multiple node support. I have a 2 node cassandra cluster.
Datacenter: datacenter1
Address Rack Status State Load Owns Token 0 192.168.1.8 rack1 Up Normal 63.14 KB 50.00% -9223372036854775808 192.168.1.6 rack1 Up Normal 96.22 KB 50.00% 0
If both of the nodes in the cluster are up then writes and reads using Kundera succeed, however if I shut one of the nodes down then writes fail with the following exception.
08:21:25,215 INFO KunderaPersistence:55 - Loading Core
08:21:25,218 INFO CoreLoader:41 - Loading Kundera Core Metdata ...
08:21:25,221 INFO KunderaPersistence:104 - Loading Application MetaData and Initializing Client(s) For Persistence Unit(s) cassandra_pu
08:21:25,226 INFO PersistenceUnitConfiguration:75 - Loading Metadata from persistence.xml ...
08:21:25,303 INFO PersistenceUnitConfiguration:95 - Finishing persistence unit metadata configuration ...
08:21:25,304 INFO MetamodelConfiguration:162 - No class to scan for persistence unit cassandra_pu. Entities will be loaded from classpath/ context-path
08:21:25,382 INFO ClientMetadataBuilder:34 - Loading client factory for persistence unit cassandra_pu
08:21:25,383 INFO ClientResolver:73 - Initializing client factory for: cassandra_pu
08:21:25,393 INFO ClientResolver:136 - Finishing factory initialization
08:21:25,393 INFO SchemaConfiguration:106 - Configuring schema export for : cassandra_pu
08:21:25,617 WARN CassandraPropertyReader:158 - No data store configuration found, returning null.
08:21:25,617 WARN CassandraPropertyReader:251 - No column family schema found, returning null.
08:21:25,628 ERROR CassandraSchemaManager:397 - Error while opening socket for host { }, Caused by: .
org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.initiateClient(CassandraSchemaManager.java:390)
at com.impetus.kundera.configure.schema.api.AbstractSchemaManager.exportSchema(AbstractSchemaManager.java:110)
at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.exportSchema(CassandraSchemaManager.java:147)
at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConfiguration.java:159)
at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactoryMetadata(ClientMetadataBuilder.java:45)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClientFactories(EntityManagerFactoryImpl.java:352)
at com.impetus.kundera.persistence.EntityManagerFactoryImpl.
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 38 more
08:21:32,916 INFO GenericClientFactory:102 - Loading client metadata for persistence unit : cassandra_pu
08:21:32,916 INFO GenericClientFactory:106 - Initializing client for persistence unit : cassandra_pu
08:21:32,918 WARN CassandraPropertyReader:158 - No data store configuration found, returning null.
08:21:32,919 WARN CassandraPropertyReader:268 - No connection properties found, returning none.
08:21:32,920 INFO GenericClientFactory:327 - Using default load balancer {} . ROUNDROBIN
08:21:32,921 WARN CassandraPropertyReader:158 - No data store configuration found, returning null.
08:21:32,936 WARN CassandraPropertyReader:158 - No data store configuration found, returning null.
08:21:32,936 WARN CassandraPropertyReader:268 - No connection properties found, returning none.
08:21:32,952 INFO GenericClientFactory:110 - Constructing pool for persistence unit : cassandra_pu
08:21:32,952 INFO PelopsClientFactory:89 - Creating pool
08:21:32,958 INFO Cluster:162 - Dynamic node discovery is disabled, using [192.168.1.6] as a static list of nodes
08:21:32,958 INFO PelopsClientFactory:119 - Initializing connection pool for keyspace grid, host 192.168.1.6,port 9160.
08:21:32,966 INFO CommonsBackedPool:121 - Initialising pool configuration policy: Config{maxActivePerNode=20, maxTotal=-1, maxIdlePerNode=10, minIdlePerNode=10, maxWaitForConnection=4000, testConnectionsWhileIdle=true, timeBetweenScheduledMaintenanceTaskRunsMillis=60000, nodeDownSuspensionMillis=10000}
08:21:32,966 INFO CommonsBackedPool:124 - Initialising pool node selection strategy: org.scale7.cassandra.pelops.pool.LeastLoadedNodeSelectionStrategy@626bd9e0
08:21:32,967 INFO CommonsBackedPool:127 - Initialising pool node suspension strategy: org.scale7.cassandra.pelops.pool.NoOpNodeSuspensionStrategy@451710be
08:21:32,967 INFO CommonsBackedPool:130 - Initialising pool connection validator: org.scale7.cassandra.pelops.pool.DescribeVersionConnectionValidator@2c6c5356
08:21:32,975 INFO CommonsBackedPool:146 - Pre-initialising connections for nodes: [192.168.1.6:9160]
08:21:32,975 INFO CommonsBackedPool:423 - Adding node '192.168.1.6' to the pool...
08:21:33,013 INFO CommonsBackedPool:71 - Registering MBean 'com.scale7.cassandra.pelops.pool:type=PooledNode-grid-192.168.1.6'...
08:21:33,017 INFO CommonsBackedPool:168 - Running maintenance tasks during initialization...
08:21:33,017 INFO CommonsBackedPool:176 - Configuring scheduled tasks to run every 60000 milliseconds
08:21:33,019 INFO CommonsBackedPool:161 - Registering MBean 'com.scale7.cassandra.pelops.pool:type=Pool-grid'...
08:21:33,020 INFO Pelops:72 - Pelops adds new pool 192.168.1.6:9160:grid
08:21:33,022 INFO Cluster:162 - Dynamic node discovery is disabled, using [192.168.1.8] as a static list of nodes
08:21:33,022 INFO PelopsClientFactory:119 - Initializing connection pool for keyspace grid, host 192.168.1.8,port 9160.
08:21:33,022 INFO CommonsBackedPool:121 - Initialising pool configuration policy: Config{maxActivePerNode=20, maxTotal=-1, maxIdlePerNode=10, minIdlePerNode=10, maxWaitForConnection=4000, testConnectionsWhileIdle=true, timeBetweenScheduledMaintenanceTaskRunsMillis=60000, nodeDownSuspensionMillis=10000}
08:21:33,022 INFO CommonsBackedPool:124 - Initialising pool node selection strategy: org.scale7.cassandra.pelops.pool.LeastLoadedNodeSelectionStrategy@3987f9f1
08:21:33,022 INFO CommonsBackedPool:127 - Initialising pool node suspension strategy: org.scale7.cassandra.pelops.pool.NoOpNodeSuspensionStrategy@e2a5ab9
08:21:33,022 INFO CommonsBackedPool:130 - Initialising pool connection validator: org.scale7.cassandra.pelops.pool.DescribeVersionConnectionValidator@7eaa2ef2
08:21:33,022 INFO CommonsBackedPool:146 - Pre-initialising connections for nodes: [192.168.1.8:9160]
08:21:33,023 INFO CommonsBackedPool:423 - Adding node '192.168.1.8' to the pool...
08:21:33,023 INFO CommonsBackedPool:71 - Registering MBean 'com.scale7.cassandra.pelops.pool:type=PooledNode-grid-192.168.1.8'...
08:21:33,284 INFO CommonsBackedPool:168 - Running maintenance tasks during initialization...
08:21:33,299 INFO CommonsBackedPool:176 - Configuring scheduled tasks to run every 60000 milliseconds
08:21:33,299 WARN CommonsBackedPool:157 - MBean 'com.scale7.cassandra.pelops.pool:type=Pool-grid' is already registered, removing...
08:21:33,299 INFO CommonsBackedPool:161 - Registering MBean 'com.scale7.cassandra.pelops.pool:type=Pool-grid'...
08:21:33,300 INFO Pelops:72 - Pelops adds new pool 192.168.1.8:9160:grid
08:21:33,311 INFO EntityManagerImpl:987 - Returning client instance for:cassandra_pu
08:21:33,311 INFO PelopsClientFactory:151 - Initializing pelops client for persistence unit cassandra_pu
08:21:33,325 WARN CassandraPropertyReader:158 - No data store configuration found, returning null.
08:21:33,349 WARN CommonsBackedPool:334 - A TTransportException was thrown while attempting to create a connection to '192.168.1.6'. This node will be suspended for 10000ms. Trying another node...
08:21:37,386 ERROR CommonsBackedPool:351 - Failed to get a connection within the configured wait time because there are no available nodes. This possibly indicates that either the suspension strategy is too aggressive or that your cluster is in a bad way.
com.impetus.kundera.KunderaException: org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException: Failed to get a connection within the configured max wait time.
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:176)
Caused by: org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException: Failed to get a connection within the configured max wait time.
at org.scale7.cassandra.pelops.pool.CommonsBackedPool.getConnectionExcept(CommonsBackedPool.java:356)
at org.scale7.cassandra.pelops.pool.CommonsBackedPool.getConnection(CommonsBackedPool.java:289)
at com.impetus.client.cassandra.pelops.PelopsClientFactory.getConnection(PelopsClientFactory.java:260)
at com.impetus.client.cassandra.pelops.PelopsClient.getConection(PelopsClient.java:845)
at com.impetus.client.cassandra.pelops.PelopsClient.getConection(PelopsClient.java:90)
at com.impetus.client.cassandra.CassandraClientBase.getRawClient(CassandraClientBase.java:1627)
at com.impetus.client.cassandra.pelops.PelopsClient.onPersist(PelopsClient.java:453)
at com.impetus.kundera.client.ClientBase.persist(ClientBase.java:85)
at com.impetus.kundera.lifecycle.states.ManagedState.handleFlush(ManagedState.java:182)
at com.impetus.kundera.graph.Node.flush(Node.java:523)
at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:444)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:156)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:170)
Below is my configuration for persistence.xml and KunderaLoadConfig.xml
Please let me know if I am doing something wrong.


Last reported issue is related to Pelops only. Reason is underlying Pelops API does not provide a way to test connection until you really execute a call with thrift and not sure whether they will plan to implement this as well.
I suggest to use, ThriftClientFactory in place of PelopsClientFactory in persistence.xml.
The issue was that Kundera DDL was creating a keyspace with SimpleStrategy. This needs to change to expose these settings via the persistence.xml
Once I changed the keyspace to Network Topology Strategy the connection pooling worked.
Hi We too are planning to use Kundera+Cassandra for our production.Looks like this feature has been made available recently.A sample project with the required configurations will be of immense help to us here. We are planning to use a 6 node Cassandra ring with the same port. I see in the configuration file there is a property "//<//property name="kundera.pool.size.max.active" value="33"></property//> //" . It will be really helpful if we can get advise on the optimal values for the connection pooling.