2
votes

I have an application which uses Kundera to generate tables from objects. I want to change Cassandra Replication factor. I use EntityManagerFactory separately to interact with the database for initializing, persisting records, etc.

I know we can create a separate kundera-cassandra.xml file and mention the replication factor. However, this throws an error for me and says keyspace doesn't exist. Also, I don't want to do this.

I want to change replication factor using EntityManagerFactory instead and somehow it doesn't work.

Here is my initialize function:

props.put(KUNDERA_NODES_KEY, host);
props.put(KUNDERA_PORT_KEY, String.valueOf(port));
props.put(KUNDERA_KEYSPACE_KEY, databaseName);    
props.put(CassandraConstants.CQL_VERSION,CassandraConstants.CQL_VERSION_3_);
props.put("replication_factor", 2);
entityManagerFactory = Persistence.createEntityManagerFactory(
                                            DataServiceConfiguration.KUNDERA_PERSISTENCE_UNIT, props);

LOG.info("DataServiceImpl initialized with Properties: " + props);

Note: I have tried setting the replication factor value as String as well and also have tried using CassandraConstants. Please let me know what am I doing incorrectly?

1

1 Answers

0
votes

This is not possible with the current code. I have added a fix for this in github (track issue #1005).

This fix will be available from next Kundera release or you can build code from source to use it ASAP.

-Karthik