kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 21d6322ff3f2c25aefffbfe03e11b99287e6f8ad4a1213fdc00d5f9b890188c3 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-06-22 17:26 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-06-22 17:26 +02:00 |
| Parents | c5629210f894 |
2 files changed
modified changelog/README.md +2 −0
| @@ -15,6 +15,8 @@ | ||
| 15 | 15 | - [improvement] Create values() function for Insert builder using List (JAVA-225) |
| 16 | 16 | - [improvement] Warn when ReplicationStrategy encounters invalid |
| 17 | 17 | replication factors (JAVA-702) |
| 18 | +- [improvement] Add PoolingOptions method to set both core and max | |
| 19 | + connections (JAVA-662). | |
| 18 | 20 | |
| 19 | 21 | Merged from 2.0.10_fixes branch: |
| 20 | 22 |
modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java +24 −0
| @@ -230,6 +230,30 @@ | ||
| 230 | 230 | return this; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | + /** | |
| 234 | + * Sets the core and maximum number of connections per host in one call. | |
| 235 | + * <p> | |
| 236 | + * This is a convenience method that is equivalent to calling {@link #setCoreConnectionsPerHost(HostDistance, int)} | |
| 237 | + * and {@link #setMaxConnectionsPerHost(HostDistance, int)}. | |
| 238 | + * | |
| 239 | + * @param distance the {@code HostDistance} for which to set these threshold. | |
| 240 | + * @param core the core number of connections. | |
| 241 | + * @param max the max number of connections. | |
| 242 | + * @return this {@code PoolingOptions}. | |
| 243 | + * | |
| 244 | + * @throws IllegalArgumentException if {@code distance == HostDistance.IGNORED}, | |
| 245 | + * or if {@code core} > {@code max}. | |
| 246 | + */ | |
| 247 | + public synchronized PoolingOptions setConnectionsPerHost(HostDistance distance, int core, int max) { | |
| 248 | + if (distance == HostDistance.IGNORED) | |
| 249 | + throw new IllegalArgumentException("Cannot set connections per host for " + distance + " hosts"); | |
| 250 | + | |
| 251 | + checkConnectionsPerHostOrder(core, max, distance); | |
| 252 | + coreConnections[distance.ordinal()] = core; | |
| 253 | + maxConnections[distance.ordinal()] = max; | |
| 254 | + return this; | |
| 255 | + } | |
| 256 | + | |
| 233 | 257 | /** |
| 234 | 258 | * Returns the timeout before an idle connection is removed. |
| 235 | 259 | * |