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

Considered a com.datastax.driver.core.Session instances pool indexed by KeySpace for vertx instances #15

Open
cmuxiaodong opened this issue Feb 4, 2016 · 3 comments

Comments

@cmuxiaodong
Copy link

In the DefaultCassandraSession, it creates the a com.datastax.driver.core.Session instance for a vertx.

From the the API documents: http://docs.datastax.com/en/drivers/java/3.0/ (same for 2.1 and 2.0), The driver's Session instance is a threadsafe and it even recommends "As a given session can only be "logged" into one keyspace at a time (where the "logged" keyspace is the one used by query if the query doesn't explicitely use a fully qualified table name), it can make sense to create one session per keyspace used."

Have you considered the Session pool(or map) for the vertx instances which can retrieved the Session by using the KeySpace? Since the current implements may not fully leverage the Session.

@cmuxiaodong
Copy link
Author

@jtruelove
Copy link

@adrianluisgonzalez what are your thoughts on this? I had been taking a different approach of one session per verticle instance. Based on that link and the javadocs http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Session.html seems like that is probably wrong. I don't know if this has always been the case but 3.0 definitely seems like the advice is one session per keyspace per jvm. Next question then in my mind is, are there any implications on which event loop you marshall cassandra responses back onto? In example you have multiple verticle instances hitting cassandra and every response is marshalled back on the same instance event loop.

@jtruelove
Copy link

Looking at the vertx-cassandra code I think it's fine given the FutureUtils does a getOrCreateContext call, I'll submit an update to the docs to advice people to only use one Session. You could maybe detect if people used the session in the wrong way and maybe through a warning.

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