kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a64e85d5a0c65861175012600e39e5b1a3f78536748e58904c802e04ee07b180 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-10-14 15:43 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-10-15 21:26 +02:00 |
| Parents | 7f3ccb3b2b46 |
7 files changed
modified changelog/README.md +1 −0
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | - [improvement] Limit visibility of codec internals (JAVA-932) |
| 16 | 16 | - [improvement] Warn if a custom codec collides with an existing one (JAVA-934) |
| 17 | 17 | - [improvement] Allow typed getters/setters to target any CQL type (JAVA-940) |
| 18 | +- [bug] Fix Cluster.connect with a case-sensitive keyspace (JAVA-950) | |
| 18 | 19 | |
| 19 | 20 | |
| 20 | 21 | ### 3.0.0-alpha3 |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +27 −7
| @@ -26,6 +26,7 @@ | ||
| 26 | 26 | import java.util.concurrent.atomic.AtomicReference; |
| 27 | 27 | |
| 28 | 28 | import com.google.common.annotations.VisibleForTesting; |
| 29 | +import com.google.common.base.Functions; | |
| 29 | 30 | import com.google.common.base.Predicates; |
| 30 | 31 | import com.google.common.base.Strings; |
| 31 | 32 | import com.google.common.collect.*; |
| @@ -35,6 +36,7 @@ | ||
| 35 | 36 | |
| 36 | 37 | import com.datastax.driver.core.exceptions.AuthenticationException; |
| 37 | 38 | import com.datastax.driver.core.exceptions.DriverInternalError; |
| 39 | +import com.datastax.driver.core.exceptions.InvalidQueryException; | |
| 38 | 40 | import com.datastax.driver.core.exceptions.NoHostAvailableException; |
| 39 | 41 | import com.datastax.driver.core.policies.*; |
| 40 | 42 | import com.datastax.driver.core.utils.MoreFutures; |
| @@ -222,7 +224,7 @@ | ||
| 222 | 224 | */ |
| 223 | 225 | public Session newSession() { |
| 224 | 226 | checkNotClosed(manager); |
| 225 | - return manager.newSession(null); | |
| 227 | + return manager.newSession(); | |
| 226 | 228 | } |
| 227 | 229 | |
| 228 | 230 | /** |
| @@ -273,6 +275,7 @@ | ||
| 273 | 275 | * be contacted to set the {@code keyspace}. |
| 274 | 276 | * @throws AuthenticationException if an authentication error occurs while |
| 275 | 277 | * contacting the initial contact points. |
| 278 | + * @throws InvalidQueryException if the keyspace does not exists. | |
| 276 | 279 | * @throws IllegalStateException if the Cluster was closed prior to calling |
| 277 | 280 | * this method. This can occur either directly (through {@link #close()} or |
| 278 | 281 | * {@link #closeAsync()}), or as a result of an error while initializing the |
| @@ -333,11 +336,28 @@ | ||
| 333 | 336 | * {@link #closeAsync()}), or as a result of an error while initializing the |
| 334 | 337 | * Cluster. |
| 335 | 338 | */ |
| 336 | - public ListenableFuture<Session> connectAsync(String keyspace) { | |
| 339 | + public ListenableFuture<Session> connectAsync(final String keyspace) { | |
| 337 | 340 | checkNotClosed(manager); |
| 338 | 341 | init(); |
| 339 | - Session session = manager.newSession(keyspace); | |
| 340 | - return session.initAsync(); | |
| 342 | + final Session session = manager.newSession(); | |
| 343 | + ListenableFuture<Session> sessionInitialized = session.initAsync(); | |
| 344 | + if (keyspace == null) { | |
| 345 | + return sessionInitialized; | |
| 346 | + } else { | |
| 347 | + ListenableFuture<ResultSet> keyspaceSet = Futures.transform(sessionInitialized, new AsyncFunction<Session, ResultSet>() { | |
| 348 | + @Override | |
| 349 | + public ListenableFuture<ResultSet> apply(Session session) throws Exception { | |
| 350 | + return session.executeAsync("USE " + keyspace); | |
| 351 | + } | |
| 352 | + }); | |
| 353 | + Futures.addCallback(keyspaceSet, new MoreFutures.FailureCallback<ResultSet>() { | |
| 354 | + @Override | |
| 355 | + public void onFailure(Throwable t) { | |
| 356 | + session.closeAsync(); | |
| 357 | + } | |
| 358 | + }); | |
| 359 | + return Futures.transform(keyspaceSet, Functions.constant(session)); | |
| 360 | + } | |
| 341 | 361 | } |
| 342 | 362 | |
| 343 | 363 | /** |
| @@ -1500,8 +1520,8 @@ | ||
| 1500 | 1520 | return translated == null ? sa : translated; |
| 1501 | 1521 | } |
| 1502 | 1522 | |
| 1503 | - private Session newSession(String keyspace) { | |
| 1504 | - SessionManager session = new SessionManager(Cluster.this, keyspace); | |
| 1523 | + private Session newSession() { | |
| 1524 | + SessionManager session = new SessionManager(Cluster.this); | |
| 1505 | 1525 | sessions.add(session); |
| 1506 | 1526 | return session; |
| 1507 | 1527 | } |
| @@ -1935,7 +1955,7 @@ | ||
| 1935 | 1955 | |
| 1936 | 1956 | List<ListenableFuture<Boolean>> futures = Lists.newArrayListWithCapacity(sessions.size()); |
| 1937 | 1957 | for (SessionManager s : sessions) |
| 1938 | - futures.add(s.maybeAddPool(host, reusedConnection, false)); | |
| 1958 | + futures.add(s.maybeAddPool(host, reusedConnection)); | |
| 1939 | 1959 | |
| 1940 | 1960 | try { |
| 1941 | 1961 | // Only mark the node up once all session have added their pool (if the load-balancing |
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +6 −15
| @@ -46,14 +46,11 @@ | ||
| 46 | 46 | |
| 47 | 47 | import static io.netty.handler.timeout.IdleState.ALL_IDLE; |
| 48 | 48 | |
| 49 | -import com.datastax.driver.core.exceptions.AuthenticationException; | |
| 50 | -import com.datastax.driver.core.exceptions.DriverException; | |
| 51 | -import com.datastax.driver.core.exceptions.DriverInternalError; | |
| 52 | -import com.datastax.driver.core.exceptions.InvalidQueryException; | |
| 49 | +import com.datastax.driver.core.Responses.Result.SetKeyspace; | |
| 50 | +import com.datastax.driver.core.exceptions.*; | |
| 53 | 51 | import com.datastax.driver.core.utils.MoreFutures; |
| 54 | 52 | |
| 55 | 53 | import static com.datastax.driver.core.Message.Response.Type.ERROR; |
| 56 | -import static com.datastax.driver.core.Message.Response.Type.RESULT; | |
| 57 | 54 | |
| 58 | 55 | // For LoggingHandler |
| 59 | 56 | //import org.jboss.netty.handler.logging.LoggingHandler; |
| @@ -183,7 +180,7 @@ | ||
| 183 | 180 | public ListenableFuture<Void> create(Throwable t) throws Exception { |
| 184 | 181 | SettableFuture<Void> future = SettableFuture.create(); |
| 185 | 182 | // Make sure the connection gets properly closed. |
| 186 | - if (t instanceof ClusterNameMismatchException || t instanceof UnsupportedProtocolVersionException || t instanceof SetKeyspaceException) { | |
| 183 | + if (t instanceof ClusterNameMismatchException || t instanceof UnsupportedProtocolVersionException) { | |
| 187 | 184 | // Just propagate |
| 188 | 185 | closeAsync().force(); |
| 189 | 186 | future.setException(t); |
| @@ -481,19 +478,13 @@ | ||
| 481 | 478 | return Futures.transform(future, new AsyncFunction<Message.Response, Void>() { |
| 482 | 479 | @Override |
| 483 | 480 | public ListenableFuture<Void> apply(Message.Response response) throws Exception { |
| 484 | - if (response.type == RESULT) { | |
| 485 | - Connection.this.keyspace = keyspace; | |
| 481 | + if (response instanceof SetKeyspace) { | |
| 482 | + Connection.this.keyspace = ((SetKeyspace)response).keyspace; | |
| 486 | 483 | return MoreFutures.VOID_SUCCESS; |
| 487 | 484 | } else if (response.type == ERROR) { |
| 488 | 485 | closeAsync().force(); |
| 489 | 486 | Responses.Error error = (Responses.Error)response; |
| 490 | - Exception e = error.asException(address); | |
| 491 | - if (e instanceof InvalidQueryException) { | |
| 492 | - // Most likely means that the keyspace name is wrong. Wrap that in a specific exception, because we want | |
| 493 | - // to treat it specially in case of a Session init. | |
| 494 | - e = new SetKeyspaceException(e); | |
| 495 | - } | |
| 496 | - throw e; | |
| 487 | + throw error.asException(address); | |
| 497 | 488 | } else { |
| 498 | 489 | closeAsync().force(); |
| 499 | 490 | throw new DriverInternalError("Unexpected response while setting keyspace: " + response); |
modified driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java +1 −19
| @@ -105,8 +105,6 @@ | ||
| 105 | 105 | * pool. |
| 106 | 106 | */ |
| 107 | 107 | ListenableFuture<Void> initAsync(Connection reusedConnection) { |
| 108 | - String keyspace = manager.poolsState.keyspace; | |
| 109 | - | |
| 110 | 108 | Executor initExecutor = manager.cluster.manager.configuration.getPoolingOptions().getInitializationExecutor(); |
| 111 | 109 | |
| 112 | 110 | // Create initial core connections |
| @@ -126,7 +124,7 @@ | ||
| 126 | 124 | } |
| 127 | 125 | reusedConnection = null; |
| 128 | 126 | connections.add(connection); |
| 129 | - connectionFutures.add(handleErrors(setKeyspaceAsync(connectionFuture, connection, keyspace), initExecutor)); | |
| 127 | + connectionFutures.add(handleErrors(connectionFuture, initExecutor)); | |
| 130 | 128 | } |
| 131 | 129 | |
| 132 | 130 | ListenableFuture<List<Void>> allConnectionsFuture = Futures.allAsList(connectionFutures); |
| @@ -175,7 +173,6 @@ | ||
| 175 | 173 | // accordingly in SessionManager#maybeAddPool. |
| 176 | 174 | Throwables.propagateIfInstanceOf(t, ClusterNameMismatchException.class); |
| 177 | 175 | Throwables.propagateIfInstanceOf(t, UnsupportedProtocolVersionException.class); |
| 178 | - Throwables.propagateIfInstanceOf(t, SetKeyspaceException.class); | |
| 179 | 176 | |
| 180 | 177 | // We don't want to swallow Errors either as they probably indicate a more serious issue (OOME...) |
| 181 | 178 | Throwables.propagateIfInstanceOf(t, Error.class); |
| @@ -186,17 +183,6 @@ | ||
| 186 | 183 | }, executor); |
| 187 | 184 | } |
| 188 | 185 | |
| 189 | - private ListenableFuture<Void> setKeyspaceAsync(ListenableFuture<Void> initFuture, final Connection connection, final String keyspace) { | |
| 190 | - return (keyspace == null) | |
| 191 | - ? initFuture | |
| 192 | - : Futures.transform(initFuture, new AsyncFunction<Void, Void>() { | |
| 193 | - @Override | |
| 194 | - public ListenableFuture<Void> apply(Void input) throws Exception { | |
| 195 | - return connection.setKeyspaceAsync(keyspace); | |
| 196 | - } | |
| 197 | - }); | |
| 198 | - } | |
| 199 | - | |
| 200 | 186 | // Clean up if we got a fatal error at construction time but still created part of the core connections |
| 201 | 187 | private void forceClose(List<Connection> connections) { |
| 202 | 188 | for (Connection connection : connections) { |
| @@ -687,10 +673,6 @@ | ||
| 687 | 673 | static class PoolState { |
| 688 | 674 | volatile String keyspace; |
| 689 | 675 | |
| 690 | - PoolState(String keyspace) { | |
| 691 | - this.keyspace = keyspace; | |
| 692 | - } | |
| 693 | - | |
| 694 | 676 | void setKeyspace(String keyspace) { |
| 695 | 677 | this.keyspace = keyspace; |
| 696 | 678 | } |
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +6 −11
| @@ -21,9 +21,7 @@ | ||
| 21 | 21 | import java.util.concurrent.*; |
| 22 | 22 | import java.util.concurrent.atomic.AtomicReference; |
| 23 | 23 | |
| 24 | -import com.google.common.base.Function; | |
| 25 | 24 | import com.google.common.base.Functions; |
| 26 | -import com.google.common.base.Throwables; | |
| 27 | 25 | import com.google.common.collect.ImmutableList; |
| 28 | 26 | import com.google.common.collect.Lists; |
| 29 | 27 | import com.google.common.util.concurrent.*; |
| @@ -56,10 +54,10 @@ | ||
| 56 | 54 | private volatile boolean isClosing; |
| 57 | 55 | |
| 58 | 56 | // Package protected, only Cluster should construct that. |
| 59 | - SessionManager(Cluster cluster, String keyspace) { | |
| 57 | + SessionManager(Cluster cluster) { | |
| 60 | 58 | this.cluster = cluster; |
| 61 | 59 | this.pools = new ConcurrentHashMap<Host, HostConnectionPool>(); |
| 62 | - this.poolsState = new HostConnectionPool.PoolState(keyspace); | |
| 60 | + this.poolsState = new HostConnectionPool.PoolState(); | |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | 63 | public Session init() { |
| @@ -113,7 +111,7 @@ | ||
| 113 | 111 | List<ListenableFuture<Boolean>> futures = Lists.newArrayListWithCapacity(hosts.size()); |
| 114 | 112 | for (Host host : hosts) |
| 115 | 113 | if (host.state != Host.State.DOWN) |
| 116 | - futures.add(maybeAddPool(host, null, true)); | |
| 114 | + futures.add(maybeAddPool(host, null)); | |
| 117 | 115 | return Futures.allAsList(futures); |
| 118 | 116 | } |
| 119 | 117 | |
| @@ -332,7 +330,7 @@ | ||
| 332 | 330 | } |
| 333 | 331 | |
| 334 | 332 | // Returns whether there was problem creating the pool |
| 335 | - ListenableFuture<Boolean> maybeAddPool(final Host host, Connection reusedConnection, final boolean failOnKeyspaceError) { | |
| 333 | + ListenableFuture<Boolean> maybeAddPool(final Host host, Connection reusedConnection) { | |
| 336 | 334 | final HostDistance distance = cluster.manager.loadBalancingPolicy().distance(host); |
| 337 | 335 | if (distance == HostDistance.IGNORED) |
| 338 | 336 | return Futures.immediateFuture(true); |
| @@ -365,9 +363,6 @@ | ||
| 365 | 363 | ClusterNameMismatchException e = (ClusterNameMismatchException)t; |
| 366 | 364 | cluster.manager.logClusterNameMismatch(host, e.expectedClusterName, e.actualClusterName); |
| 367 | 365 | cluster.manager.triggerOnDown(host, false); |
| 368 | - } else if ((t instanceof SetKeyspaceException) && failOnKeyspaceError) { | |
| 369 | - future.setException(t.getCause()); | |
| 370 | - return; | |
| 371 | 366 | } else { |
| 372 | 367 | logger.error("Error creating pool to " + host, t); |
| 373 | 368 | } |
| @@ -413,7 +408,7 @@ | ||
| 413 | 408 | |
| 414 | 409 | if (pool == null) { |
| 415 | 410 | if (dist != HostDistance.IGNORED && h.state == Host.State.UP) |
| 416 | - poolCreatedFutures.add(maybeAddPool(h, null, false)); | |
| 411 | + poolCreatedFutures.add(maybeAddPool(h, null)); | |
| 417 | 412 | } else if (dist != pool.hostDistance) { |
| 418 | 413 | if (dist == HostDistance.IGNORED) { |
| 419 | 414 | toRemove.add(h); |
| @@ -447,7 +442,7 @@ | ||
| 447 | 442 | if (pool == null) { |
| 448 | 443 | if (dist != HostDistance.IGNORED && h.state == Host.State.UP) |
| 449 | 444 | try { |
| 450 | - maybeAddPool(h, null, false).get(); | |
| 445 | + maybeAddPool(h, null).get(); | |
| 451 | 446 | } catch (ExecutionException e) { |
| 452 | 447 | // Ignore, maybeAddPool has already handled the error |
| 453 | 448 | } |
deleted driver-core/src/main/java/com/datastax/driver/core/SetKeyspaceException.java +0 −23
| @@ -1,23 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core; | |
| 17 | - | |
| 18 | -@SuppressWarnings("serial") | |
| 19 | -class SetKeyspaceException extends Exception { | |
| 20 | - SetKeyspaceException(Exception cause) { | |
| 21 | - super(cause); | |
| 22 | - } | |
| 23 | -} |
modified driver-core/src/test/java/com/datastax/driver/core/AsyncQueryTest.java +42 −19
| @@ -16,15 +16,13 @@ | ||
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | 18 | import java.util.Collection; |
| 19 | -import java.util.concurrent.ExecutionException; | |
| 20 | -import java.util.concurrent.TimeUnit; | |
| 19 | +import java.util.List; | |
| 20 | +import java.util.concurrent.*; | |
| 21 | 21 | |
| 22 | 22 | import com.google.common.base.Function; |
| 23 | 23 | import com.google.common.collect.Lists; |
| 24 | -import com.google.common.util.concurrent.AsyncFunction; | |
| 25 | -import com.google.common.util.concurrent.Futures; | |
| 26 | -import com.google.common.util.concurrent.ListenableFuture; | |
| 27 | -import com.google.common.util.concurrent.Uninterruptibles; | |
| 24 | +import com.google.common.util.concurrent.*; | |
| 25 | +import org.testng.annotations.DataProvider; | |
| 28 | 26 | import org.testng.annotations.Test; |
| 29 | 27 | |
| 30 | 28 | import static org.assertj.core.api.Assertions.assertThat; |
| @@ -35,12 +33,24 @@ | ||
| 35 | 33 | |
| 36 | 34 | public class AsyncQueryTest extends CCMBridge.PerClassSingleNodeCluster { |
| 37 | 35 | |
| 36 | + @DataProvider(name="keyspace") | |
| 37 | + public static Object[][] keyspace() { | |
| 38 | + return new Object[][]{ { "asyncquerytest" }, { "\"AsyncQueryTest\"" } }; | |
| 39 | + } | |
| 40 | + | |
| 38 | 41 | @Override |
| 39 | 42 | protected Collection<String> getTableDefinitions() { |
| 40 | - return Lists.newArrayList( | |
| 41 | - "create table foo(k int primary key, v int)", | |
| 42 | - "insert into foo (k, v) values (1, 1)" | |
| 43 | - ); | |
| 43 | + List<String> definitions = Lists.newArrayList(); | |
| 44 | + | |
| 45 | + for (Object[] objects : keyspace()) { | |
| 46 | + String keyspace = (String)objects[0]; | |
| 47 | + | |
| 48 | + definitions.add(String.format("create keyspace %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}", keyspace)); | |
| 49 | + definitions.add(String.format("create table %s.foo(k int primary key, v int)", keyspace)); | |
| 50 | + definitions.add(String.format("insert into %s.foo (k, v) values (1, 1)", keyspace)); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return definitions; | |
| 44 | 54 | } |
| 45 | 55 | |
| 46 | 56 | /** |
| @@ -76,27 +86,40 @@ | ||
| 76 | 86 | // Neither cluster2 nor session2 are initialized at this point |
| 77 | 87 | assertThat(cluster2.manager.metadata).isNull(); |
| 78 | 88 | |
| 79 | - ResultSetFuture future = session2.executeAsync(String.format("select v from %s.foo where k = 1", keyspace)); | |
| 89 | + ResultSetFuture future = session2.executeAsync("select release_version from system.local"); | |
| 80 | 90 | Row row = Uninterruptibles.getUninterruptibly(future).one(); |
| 81 | 91 | |
| 82 | - assertThat(row.getInt(0)).isEqualTo(1); | |
| 92 | + assertThat(row.getString(0)).isNotEmpty(); | |
| 83 | 93 | } finally { |
| 84 | 94 | if (cluster2 != null) |
| 85 | 95 | cluster2.close(); |
| 86 | 96 | } |
| 87 | 97 | } |
| 88 | 98 | |
| 89 | - @Test(groups = "short") | |
| 90 | - public void should_chain_query_on_async_session_init() throws Exception { | |
| 91 | - ListenableFuture<Integer> resultFuture = connectAndQuery(this.keyspace); | |
| 99 | + @Test(groups = "short", dataProvider = "keyspace", enabled = false, | |
| 100 | + description = "disabled because the blocking USE call in the current pool implementation makes it deadlock") | |
| 101 | + public void should_chain_query_on_async_session_init_with_same_executor(String keyspace) throws Exception { | |
| 102 | + ListenableFuture<Integer> resultFuture = connectAndQuery(keyspace, MoreExecutors.sameThreadExecutor()); | |
| 92 | 103 | |
| 93 | 104 | Integer result = Uninterruptibles.getUninterruptibly(resultFuture); |
| 94 | 105 | assertThat(result).isEqualTo(1); |
| 95 | 106 | } |
| 96 | 107 | |
| 108 | + @Test(groups = "short", dataProvider = "keyspace") | |
| 109 | + public void should_chain_query_on_async_session_init_with_different_executor(String keyspace) throws Exception { | |
| 110 | + ExecutorService executor = Executors.newFixedThreadPool(1); | |
| 111 | + | |
| 112 | + ListenableFuture<Integer> resultFuture = connectAndQuery(keyspace, executor); | |
| 113 | + | |
| 114 | + Integer result = Uninterruptibles.getUninterruptibly(resultFuture); | |
| 115 | + assertThat(result).isEqualTo(1); | |
| 116 | + | |
| 117 | + executor.shutdownNow(); | |
| 118 | + } | |
| 119 | + | |
| 97 | 120 | @Test(groups = "short") |
| 98 | 121 | public void should_propagate_error_to_chained_query_if_session_init_fails() throws Exception { |
| 99 | - ListenableFuture<Integer> resultFuture = connectAndQuery("wrong_keyspace"); | |
| 122 | + ListenableFuture<Integer> resultFuture = connectAndQuery("wrong_keyspace", MoreExecutors.sameThreadExecutor()); | |
| 100 | 123 | |
| 101 | 124 | try { |
| 102 | 125 | Uninterruptibles.getUninterruptibly(resultFuture); |
| @@ -107,20 +130,20 @@ | ||
| 107 | 130 | } |
| 108 | 131 | } |
| 109 | 132 | |
| 110 | - private ListenableFuture<Integer> connectAndQuery(String keyspace) { | |
| 133 | + private ListenableFuture<Integer> connectAndQuery(String keyspace, Executor executor) { | |
| 111 | 134 | ListenableFuture<Session> sessionFuture = cluster.connectAsync(keyspace); |
| 112 | 135 | ListenableFuture<ResultSet> queryFuture = Futures.transform(sessionFuture, new AsyncFunction<Session, ResultSet>() { |
| 113 | 136 | @Override |
| 114 | 137 | public ListenableFuture<ResultSet> apply(Session session) throws Exception { |
| 115 | 138 | return session.executeAsync("select v from foo where k = 1"); |
| 116 | 139 | } |
| 117 | - }); | |
| 140 | + }, executor); | |
| 118 | 141 | return Futures.transform(queryFuture, new Function<ResultSet, Integer>() { |
| 119 | 142 | @Override |
| 120 | 143 | public Integer apply(ResultSet rs) { |
| 121 | 144 | return rs.one().getInt(0); |
| 122 | 145 | } |
| 123 | - }); | |
| 146 | + }, executor); | |
| 124 | 147 | } |
| 125 | 148 | |
| 126 | 149 | private static HostConnectionPool getPool(Session session) { |