kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 639e297e18468656e84b29661b49d7c43838c0efa64d861b34d1016be3b71144 |
|---|---|
| Author | Sylvain Lebresne <sylvain@datastax.com> · 2014-01-16 15:51 +01:00 |
| Committer | Sylvain Lebresne <sylvain@datastax.com> · 2014-01-16 15:51 +01:00 |
| Parents | 839d1c3411b4 |
2 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | ------ |
| 6 | 6 | |
| 7 | 7 | - [improvement] Make most main objects interface to facilitate testing/mocking (JAVA-195) |
| 8 | +- [improvement] Avoid preparing a statement multiple time per host with multiple sessions | |
| 8 | 9 | - [bug] Fix potential thread leaks when shutting down Metrics (JAVA-232) |
| 9 | 10 | - [bug] Fix potential NPE in HostConnectionPool (JAVA-231) |
| 10 | 11 |
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +3 −1
| @@ -146,6 +146,8 @@ | ||
| 146 | 146 | PreparedStatement stmt = PreparedStatement.fromMessage(pmsg, cluster.getMetadata(), query, poolsState.keyspace); |
| 147 | 147 | cluster.manager.addPrepared(stmt); |
| 148 | 148 | try { |
| 149 | + // All Sessions are connected to the same nodes so it's enough to prepare only the nodes of this session. | |
| 150 | + // If that changes, we'll have to make sure this propagate to other sessions too. | |
| 149 | 151 | prepare(stmt.getQueryString(), future.getAddress()); |
| 150 | 152 | } catch (InterruptedException e) { |
| 151 | 153 | Thread.currentThread().interrupt(); |
| @@ -298,7 +300,7 @@ | ||
| 298 | 300 | new RequestHandler(this, callback, query).sendRequest(); |
| 299 | 301 | } |
| 300 | 302 | |
| 301 | - void prepare(String query, InetAddress toExclude) throws InterruptedException { | |
| 303 | + private void prepare(String query, InetAddress toExclude) throws InterruptedException { | |
| 302 | 304 | for (Map.Entry<Host, HostConnectionPool> entry : pools.entrySet()) { |
| 303 | 305 | if (entry.getKey().getAddress().equals(toExclude)) |
| 304 | 306 | continue; |