Elffuss BraidHub

kikocis/java-driver public

Add PoolingOptions method to set both core and max connections (JAVA-662)
Changeset21d6322ff3f2c25aefffbfe03e11b99287e6f8ad4a1213fdc00d5f9b890188c3
Authorolim7t <omichallat+github@gmail.com> · 2015-06-22 17:26 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-06-22 17:26 +02:00
Parentsc5629210f894

Browse the files at this changeset

2 files changed

modified changelog/README.md +2 −0
@@ -15,6 +15,8 @@
1515 - [improvement] Create values() function for Insert builder using List (JAVA-225)
1616 - [improvement] Warn when ReplicationStrategy encounters invalid
1717 replication factors (JAVA-702)
18+- [improvement] Add PoolingOptions method to set both core and max
19+ connections (JAVA-662).
1820
1921 Merged from 2.0.10_fixes branch:
2022
modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java +24 −0
@@ -230,6 +230,30 @@
230230 return this;
231231 }
232232
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+
233257 /**
234258 * Returns the timeout before an idle connection is removed.
235259 *