kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 6ec239cc86dc43436b68736285d02e0b8ec18c72e86ed3a69e69e1cf68cf5fb4 |
|---|---|
| Author | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-18 16:32 +01:00 |
| Committer | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-18 16:32 +01:00 |
| Parents | c628d3c56e18 |
3 files changed
modified driver-core/CHANGELOG.rst +2 −1
| @@ -4,9 +4,10 @@ | ||
| 4 | 4 | 1.0.6: |
| 5 | 5 | ------ |
| 6 | 6 | |
| 7 | +- [new] Added Session#prepareAsync calls (JAVA-224) | |
| 8 | +- [new] Added Cluster#getLoggedKeyspace (JAVA-249) | |
| 7 | 9 | - [improvement] Make most main objects interface to facilitate testing/mocking (JAVA-195) |
| 8 | 10 | - [improvement] Avoid preparing a statement multiple time per host with multiple sessions |
| 9 | -- [improvement] Adds Session#prepareAsync calls (JAVA-224) | |
| 10 | 11 | - [bug] Fix potential thread leaks when shutting down Metrics (JAVA-232) |
| 11 | 12 | - [bug] Fix potential NPE in HostConnectionPool (JAVA-231) |
| 12 | 13 | - [bug] Make sure connections are returned to the right pools (JAVA-255) |
modified driver-core/src/main/java/com/datastax/driver/core/Session.java +11 −0
| @@ -36,6 +36,17 @@ | ||
| 36 | 36 | */ |
| 37 | 37 | public interface Session { |
| 38 | 38 | |
| 39 | + /** | |
| 40 | + * The keyspace to which this Session is currently logged in, if any. | |
| 41 | + * <p> | |
| 42 | + * This correspond to the name passed to {@link Cluster#connect(String)}, or to the | |
| 43 | + * last keyspace logged into through a "USE" CQL query if one was used. | |
| 44 | + * | |
| 45 | + * @return the name of the keyspace to which this Session is currently | |
| 46 | + * logged in, or {@code null} if the session is logged to no keyspace. | |
| 47 | + */ | |
| 48 | + public String getLoggedKeyspace(); | |
| 49 | + | |
| 39 | 50 | /** |
| 40 | 51 | * Executes the provided query. |
| 41 | 52 | * |
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +5 −1
| @@ -67,6 +67,10 @@ | ||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | + public String getLoggedKeyspace() { | |
| 71 | + return poolsState.keyspace; | |
| 72 | + } | |
| 73 | + | |
| 70 | 74 | public ResultSet execute(String query) { |
| 71 | 75 | return execute(new SimpleStatement(query)); |
| 72 | 76 | } |
| @@ -299,7 +303,7 @@ | ||
| 299 | 303 | long timeout = configuration().getSocketOptions().getConnectTimeoutMillis(); |
| 300 | 304 | try { |
| 301 | 305 | Future<?> future = executeQuery(new QueryMessage("use " + keyspace, ConsistencyLevel.DEFAULT_CASSANDRA_CL), Query.DEFAULT); |
| 302 | - // Note: using the connection timeout is perfectly correct, we should probably change that someday | |
| 306 | + // Note: using the connection timeout isn't perfectly correct, we should probably change that someday | |
| 303 | 307 | Uninterruptibles.getUninterruptibly(future, timeout, TimeUnit.MILLISECONDS); |
| 304 | 308 | } catch (TimeoutException e) { |
| 305 | 309 | throw new DriverInternalError(String.format("No responses after %d milliseconds while setting current keyspace. This should not happen, unless you have setup a very low connection timeout.", timeout)); |