Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to Cassandra Driver 4.x #121

Open
mauriciogeneroso opened this issue May 12, 2022 · 3 comments
Open

Support to Cassandra Driver 4.x #121

mauriciogeneroso opened this issue May 12, 2022 · 3 comments

Comments

@mauriciogeneroso
Copy link

Is it planned to update this library to support Cassandra Java Driver 4?

The latest versions of spring-data-cassandra are using Cassandra Driver 4 that has received a big refactoring, and based on my experience, I worked in a project where we recently update our Cassandra from 3 to 4 and we found many issues with Simulacron.

Since it is officially supported only by Cassandra Java Driver 3, shall it receive an update to support the Cassandra Java Driver version 4?

Thank you.

@adutra
Copy link
Contributor

adutra commented May 27, 2022

Hi @mauriciogeneroso, Simulacron does work with driver 4.x. We even make extensive use of Simulacron in the driver 4.x integration tests suite itself.

The Simulacron server does not depend on any driver, so you can perfectly use it with any compatible driver – all DataStax drivers are compatible. There should be no classpath issues even when running Simulacron embedded.

Simulacron does offer, however, a tiny module called simulacron-driver-3. This module contains only a few utilities to convert to and from driver 3.x and Simulacron similar types, such as ConsistencyLevel. There is no equivalent module for 4.x though. But you don't need to use this module, it's perfectly doable to use Simulacron without it.

Maybe you could tell us exactly what's not working for you? Maybe it's when you upgraded from 3.x and 4.x that you noticed that some Simulacron tests broke? A concrete example would help us asses your problem.

Thanks!

@mauriciogeneroso
Copy link
Author

Hi @adutra , Thank you for replying. I'll look into it to create some concrete examples and come back to you soon. Regards.

@mauriciogeneroso
Copy link
Author

mauriciogeneroso commented Sep 26, 2022

Sorry for taking long to reply. Some ways how we were using simulacron with driver 3 broke when we just updated the cassandra driver to 4.

For example, for cassandra driver 3 we prime batch queries like this:

String batchInserts = "BEGIN BATCH (omitted insert 1); (omitted insert 2); APPLY BATCH;"

BoundCluster simulacronCluster = getSimulacronCluster();
simulacronCluster.prime(when(batchInserts)
     .then(writeTimeout(ConsistencyLevel.LOCAL_QUORUM, 0, 0, BATCH))
);

Once updated the driver to 4, the code above does not work anymore, we needed to update our code to:

List<Statement> statements = List.of(
     new Statement("(omitted insert 1)", new HashMap<>(), new HashMap<>()),
     new Statement("(omitted insert 2)", new HashMap<>(), new HashMap<>())
);

BoundCluster simulacronCluster = getSimulacronCluster();
simulacronCluster.prime(
     when(new Batch(batchInserts),List.of(ConsistencyLevel.LOCAL_QUORUM))
     .then(writeTimeout(ConsistencyLevel.LOCAL_QUORUM, 0, 0, BATCH))
);

For single queries like select ... from ... where ...; we were able to prime using only the string with cassandra driver 3, now using cassandra driver 4 we need to create an instance of com.datastax.oss.simulacron.common.request.Query and specify the parameters and the parameters type otherwise the query doesn't match and don't return what is primed.

There are more, but I'll mention only this difference for now, maybe we need a documentation how to use with driver 3 and how to use with driver 4 because the driver behaves different according the driver version used by the application to send the requests to cassandra. What are you thoughts? @adutra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants