Skip to content

added default consistency level for sessions#50

Closed
damoon wants to merge 1 commit into
apache:masterfrom
damoon:master
Closed

added default consistency level for sessions#50
damoon wants to merge 1 commit into
apache:masterfrom
damoon:master

Conversation

@damoon
Copy link
Copy Markdown

@damoon damoon commented Mar 22, 2013

A default consistency level can be set to be used for all new queries created by the Session.
This overwrites the default of ConsistencyLevel.ONE without the need to set it for every query manually.

@mfiguiere
Copy link
Copy Markdown

I +1 the idea to have a default consistency level but I think it'd be more appropriate to have it on the Cluster builder rather than on the Session object as one normally don't need to modify it after startup.

@damoon
Copy link
Copy Markdown
Author

damoon commented Apr 4, 2013

I thought i would be nice to be able to use one Cluster for the application and different Sessions with different CLs for different modules.
This way every modules can depend (in a simple way) on different preconditions and not all of the great performance from tunable consistency gets lost.
Maybe one default level for the Cluster and one level for the Session (and one level for the Statement like now) would be the right way to go.

* A default consistency level can be set for all new queries created by the session.
* A default cossistency level can be set for all new sessions created by the cluster.
* The default consistency level, if not set by setDefaultConsistencyLevel, is ConsistencyLevel.ONE.
@damoon
Copy link
Copy Markdown
Author

damoon commented Apr 4, 2013

i made a rebase, moved the consistency tests out of the session tests and added get/setDefaultConsistencyLevel to the cluster

@damoon
Copy link
Copy Markdown
Author

damoon commented Apr 4, 2013

should the consistency be part of "Configuration getConfiguration()" or only be set when calling "public Cluster build()"?

@pcmanus
Copy link
Copy Markdown

pcmanus commented Apr 4, 2013

My own opinion is that having this global would be enough and having it set once by the builder only should be enough.

We had some though about this and it is very unclear than setting a default consistency at the session level is where you want to put it in general. And I don't want to risk people using 2 different sessions just to have different consistency level, because that would be a bad use of ressources. I can buy that you'd want to set a different global CL though.

To be clear, I do not pretend that setting the CL for every query is fun, but I'm not convinced the session level is the right level of default for that. I think that higher level API (say an object mapper) may be a better place to have meaningful consistency defaults. And while I could be wrong and may change my opinion when we have more experience with the driver, for now, I'd rather keep the default CL as a global config only rather than feature creeping too early.

A part of me also think that the CL is an important part of the query that it's probably not such a bad thing to have it written down with most queries, even if it's a bit verbose.

@devsprint
Copy link
Copy Markdown

Based on the experience with the driver, so far, setting the CL for each query was not such a pain, especially when you are using prepared statements. I'm using different CL for read, write or delete operations, so a default is useful but really not a big deal if is missing.

@mfiguiere mfiguiere closed this Sep 11, 2013
@pcmanus
Copy link
Copy Markdown

pcmanus commented Sep 11, 2013

For info, the 2.0 version of the driver will allow to change the default CL level globally.

Sfurti-yb pushed a commit to yugabyte/cassandra-java-driver that referenced this pull request Dec 8, 2023
Previously, when determining whether a statement should use simple or extended
query styles, only the first line was considered.  Obviously, multiline SQL
statements are reasonable, so this change updates the code to look at all
lines.

[resolves apache#50]

Signed-off-by: Ben Hale <bhale@pivotal.io>
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

Successfully merging this pull request may close these issues.

4 participants