kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | d4c4ae736c90213f720bc0df07e262065c103dac86af28bcb655723dfdc72115 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2015-04-09 14:35 +02:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2015-04-09 14:35 +02:00 |
| Parents | 0507613e1433, 5a733475be34 |
5 files changed
modified driver-core/CHANGELOG.rst +1 −1
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | - [new feature] Add getObject to BoundStatement and Row (JAVA-584) |
| 23 | 23 | - [improvement] Improve connection pool resizing algorithm (JAVA-419) |
| 24 | 24 | - [bug] Fix race condition between pool expansion and shutdown (JAVA-599) |
| 25 | -- [improvement] Upgrade Netty to 4.0.26 (JAVA-622) | |
| 25 | +- [improvement] Upgrade Netty to 4.0.27 (JAVA-622) | |
| 26 | 26 | - [improvement] Coalesce frames before flushing them to the connection |
| 27 | 27 | (JAVA-562) |
| 28 | 28 | - [improvement] Rename threads to indicate that they are for the driver |
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +1 −1
| @@ -110,12 +110,12 @@ | ||
| 110 | 110 | try { |
| 111 | 111 | // Wait until the connection attempt succeeds or fails. |
| 112 | 112 | this.channel = future.awaitUninterruptibly().channel(); |
| 113 | + this.factory.allChannels.add(this.channel); | |
| 113 | 114 | if (!future.isSuccess()) { |
| 114 | 115 | if (logger.isDebugEnabled()) |
| 115 | 116 | logger.debug(String.format("%s Error connecting to %s%s", this, address, extractMessage(future.cause()))); |
| 116 | 117 | throw defunct(new TransportException(address, "Cannot connect", future.cause())); |
| 117 | 118 | } |
| 118 | - this.factory.allChannels.add(this.channel); | |
| 119 | 119 | channel.closeFuture().addListener(new ChannelCloseListener()); |
| 120 | 120 | } finally { |
| 121 | 121 | writer.decrementAndGet(); |
modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +37 −16
| @@ -15,30 +15,26 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import java.net.InetAddress; | |
| 19 | -import java.util.List; | |
| 20 | -import java.util.concurrent.TimeUnit; | |
| 21 | - | |
| 18 | +import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 19 | +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; | |
| 20 | +import com.datastax.driver.core.querybuilder.Insert; | |
| 21 | +import com.datastax.driver.core.utils.UUIDs; | |
| 22 | 22 | import com.google.common.collect.Lists; |
| 23 | -import org.mockito.Mockito; | |
| 24 | 23 | import org.slf4j.Logger; |
| 25 | 24 | import org.slf4j.LoggerFactory; |
| 26 | 25 | import org.testng.annotations.Test; |
| 27 | 26 | |
| 28 | -import static org.assertj.core.api.Assertions.assertThat; | |
| 29 | -import static org.assertj.core.api.Assertions.fail; | |
| 30 | -import static org.mockito.Mockito.atMost; | |
| 31 | -import static org.mockito.Mockito.spy; | |
| 32 | -import static org.mockito.Mockito.times; | |
| 33 | -import static org.mockito.Mockito.verify; | |
| 34 | - | |
| 35 | -import com.datastax.driver.core.policies.ConstantReconnectionPolicy; | |
| 36 | -import com.datastax.driver.core.querybuilder.Insert; | |
| 37 | -import com.datastax.driver.core.utils.UUIDs; | |
| 27 | +import java.net.InetAddress; | |
| 28 | +import java.net.InetSocketAddress; | |
| 29 | +import java.util.Collections; | |
| 30 | +import java.util.List; | |
| 31 | +import java.util.concurrent.TimeUnit; | |
| 32 | +import java.util.concurrent.TimeoutException; | |
| 38 | 33 | |
| 39 | 34 | import static com.datastax.driver.core.FakeHost.Behavior.THROWING_CONNECT_TIMEOUTS; |
| 40 | - | |
| 41 | 35 | import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto; |
| 36 | +import static org.assertj.core.api.Assertions.fail; | |
| 37 | +import static org.mockito.Mockito.*; | |
| 42 | 38 | |
| 43 | 39 | public class ClusterInitTest { |
| 44 | 40 | private static final Logger logger = LoggerFactory.getLogger(ClusterInitTest.class); |
| @@ -110,6 +106,31 @@ | ||
| 110 | 106 | } |
| 111 | 107 | } |
| 112 | 108 | |
| 109 | + /** | |
| 110 | + * <p> | |
| 111 | + * Validates that a Cluster that was never able to successfully establish connection a session can be closed | |
| 112 | + * properly. | |
| 113 | + * | |
| 114 | + * @test_category connection | |
| 115 | + * @expected_result Cluster closes within 1 second. | |
| 116 | + */ | |
| 117 | + @Test(groups="unit") | |
| 118 | + public void should_be_able_to_close_cluster_that_never_successfully_connected() throws Exception { | |
| 119 | + Cluster cluster = Cluster.builder() | |
| 120 | + .addContactPointsWithPorts(Collections.singleton(new InetSocketAddress("127.0.0.1", 65534))) | |
| 121 | + .build(); | |
| 122 | + try { | |
| 123 | + cluster.connect(); | |
| 124 | + fail("Should not have been able to connect."); | |
| 125 | + } catch(NoHostAvailableException e) {} // Expected. | |
| 126 | + CloseFuture closeFuture = cluster.closeAsync(); | |
| 127 | + try { | |
| 128 | + closeFuture.get(1, TimeUnit.SECONDS); | |
| 129 | + } catch(TimeoutException e) { | |
| 130 | + fail("Close Future did not complete quickly."); | |
| 131 | + } | |
| 132 | + } | |
| 133 | + | |
| 113 | 134 | private void fakePeerRowsInNode1() { |
| 114 | 135 | Cluster cluster = null; |
| 115 | 136 | try { |
modified driver-examples/osgi/src/test/java/com/datastax/driver/osgi/MailboxServiceIT.java +1 −1
| @@ -58,7 +58,7 @@ | ||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | private CompositeOption nettyBundles() { |
| 61 | - final String nettyVersion = "4.0.26.Final"; | |
| 61 | + final String nettyVersion = "4.0.27.Final"; | |
| 62 | 62 | return new CompositeOption() { |
| 63 | 63 | |
| 64 | 64 | @Override public Option[] getOptions() { |
modified pom.xml +1 −1
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | Check with the spark-cassandra-connector team before upgrading this. |
| 52 | 52 | --> |
| 53 | 53 | <guava.version>14.0.1</guava.version> |
| 54 | - <netty.version>4.0.26.Final</netty.version> | |
| 54 | + <netty.version>4.0.27.Final</netty.version> | |
| 55 | 55 | <metrics.version>3.0.2</metrics.version> |
| 56 | 56 | <snappy.version>1.0.5</snappy.version> |
| 57 | 57 | <lz4.version>1.2.0</lz4.version> |