Elffuss BraidHub

kikocis/java-driver public

JAVA-1120: Skip schema refresh debouncer when checking for agreement as a result of schema change made by client

This commit contains substantial contributions by Andrew Tolbert (@tolbertam).

This commit removes nonDebouncingQueryOptions from tests that no longer require it.
Changeset7b731983d1f2c51713805d8595600416ac4b5b6a6ab3978f7531df14f0778664
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-05-12 10:38 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2016-07-08 09:06 -07:00
Parents7518b703ac63

Browse the files at this changeset

8 files changed

modified changelog/README.md +1 −0
@@ -19,6 +19,7 @@
1919 - [bug] JAVA-1160: Fix NPE in VersionNumber.getPreReleaseLabels().
2020 - [improvement] JAVA-1126: Handle schema changes in Mapper.
2121 - [bug] JAVA-1193: Refresh token and replica metadata synchronously when schema is altered.
22+- [bug] JAVA-1120: Skip schema refresh debouncer when checking for agreement as a result of schema change made by client.
2223
2324
2425 ### 3.0.2
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +9 −1
@@ -2266,7 +2266,15 @@
22662266 if (!schemaInAgreement)
22672267 logger.warn("No schema agreement from live replicas after {} s. The schema may not be up to date on some nodes.", configuration.getProtocolOptions().getMaxSchemaAgreementWaitSeconds());
22682268
2269- ListenableFuture<Void> schemaReady = refreshSchema ? submitSchemaRefresh(targetType, targetKeyspace, targetName, targetSignature) : MoreFutures.VOID_SUCCESS;
2269+ ListenableFuture<Void> schemaReady;
2270+ if (refreshSchema) {
2271+ schemaReady = submitSchemaRefresh(targetType, targetKeyspace, targetName, targetSignature);
2272+ // JAVA-1120: skip debouncing delay and force immediate delivery
2273+ if (!schemaReady.isDone())
2274+ schemaRefreshRequestDebouncer.scheduleImmediateDelivery();
2275+ } else {
2276+ schemaReady = MoreFutures.VOID_SUCCESS;
2277+ }
22702278 final boolean finalSchemaInAgreement = schemaInAgreement;
22712279 schemaReady.addListener(new Runnable() {
22722280 @Override
modified driver-core/src/main/java/com/datastax/driver/core/EventDebouncer.java +1 −1
@@ -164,7 +164,7 @@
164164 return entry.future;
165165 }
166166
167- private void scheduleImmediateDelivery() {
167+ void scheduleImmediateDelivery() {
168168 cancelDelayedDelivery();
169169
170170 while (state == State.RUNNING) {
modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +4 −4
@@ -42,7 +42,8 @@
4242 import static com.datastax.driver.core.Assertions.fail;
4343 import static com.datastax.driver.core.FakeHost.Behavior.THROWING_CONNECT_TIMEOUTS;
4444 import static com.datastax.driver.core.HostDistance.LOCAL;
45-import static com.datastax.driver.core.TestUtils.*;
45+import static com.datastax.driver.core.TestUtils.ipOfNode;
46+import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
4647 import static org.mockito.Mockito.*;
4748
4849 public class ClusterInitTest {
@@ -107,7 +108,6 @@
107108 .withReconnectionPolicy(reconnectionPolicy)
108109 .withPoolingOptions(poolingOptions)
109110 .withProtocolVersion(TestUtils.getDesiredProtocolVersion())
110- .withQueryOptions(nonDebouncingQueryOptions())
111111 .build();
112112 cluster.connect();
113113
@@ -228,7 +228,7 @@
228228 ScassandraCluster scassandraCluster = ScassandraCluster.builder()
229229 .withIpPrefix(TestUtils.IP_PREFIX)
230230 .withNodes(5)
231- // For node 2, report an older version which uses protocol v1.
231+ // For node 2, report an older version which uses protocol v1.
232232 .forcePeerInfo(1, 2, "release_version", "1.2.19")
233233 .build();
234234 Cluster cluster = Cluster.builder()
@@ -262,7 +262,7 @@
262262 PrimingClient.builder()
263263 .withHost(ipOfNode(1))
264264 .withPort(scassandra.getAdminPort())
265- .build();
265+ .build();
266266
267267 List<Map<String, ?>> rows = Lists.newArrayListWithCapacity(5);
268268
modified driver-core/src/test/java/com/datastax/driver/core/HostMetadataIntegrationTest.java +0 −2
@@ -24,7 +24,6 @@
2424 import static com.datastax.driver.core.Assertions.assertThat;
2525 import static com.datastax.driver.core.CCMAccess.Workload.solr;
2626 import static com.datastax.driver.core.CCMAccess.Workload.spark;
27-import static com.datastax.driver.core.TestUtils.nonDebouncingQueryOptions;
2827 import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
2928
3029 public class HostMetadataIntegrationTest {
@@ -58,7 +57,6 @@
5857 Cluster cluster = Cluster.builder()
5958 .addContactPoints(ccm.addressOfNode(1).getAddress())
6059 .withPort(ccm.getBinaryPort())
61- .withQueryOptions(nonDebouncingQueryOptions())
6260 .build();
6361 try {
6462 cluster.connect();
modified driver-core/src/test/java/com/datastax/driver/core/SchemaRefreshDebouncerTest.java +4 −1
@@ -17,7 +17,6 @@
1717
1818 import org.mockito.ArgumentCaptor;
1919 import org.testng.SkipException;
20-import org.testng.annotations.AfterMethod;
2120 import org.testng.annotations.BeforeMethod;
2221 import org.testng.annotations.Test;
2322
@@ -249,6 +248,8 @@
249248 String prefix = TestUtils.generateIdentifier("ks_");
250249 for (int i = 0; i < 3; i++) {
251250 session().execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, prefix + i, 1));
251+ // check that the metadata is immediately up-to-date for the client that issued the DDL statement
252+ assertThat(cluster().getMetadata().getKeyspace(prefix + i)).isNotNull();
252253 }
253254
254255 verify(listener, timeout(DEBOUNCE_TIME * 3).times(3)).onKeyspaceAdded(any(KeyspaceMetadata.class));
@@ -275,6 +276,8 @@
275276 String prefix = TestUtils.generateIdentifier("ks_");
276277 for (int i = 0; i < 5; i++) {
277278 session().execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, prefix + i, 1));
279+ // check that the metadata is immediately up-to-date for the client that issued the DDL statement
280+ assertThat(cluster().getMetadata().getKeyspace(prefix + i)).isNotNull();
278281 }
279282
280283 // Event should be processed immediately as we hit our threshold.
modified driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java +1 −2
@@ -61,8 +61,7 @@
6161 return Cluster.builder()
6262 .addContactPoints(getContactPoints().get(0))
6363 .withPort(ccm().getBinaryPort())
64- .withLoadBalancingPolicy(lbp)
65- .withQueryOptions(TestUtils.nonDebouncingQueryOptions());
64+ .withLoadBalancingPolicy(lbp);
6665 }
6766
6867 @Override
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperAsyncTest.java +1 −1
@@ -71,7 +71,7 @@
7171 // create a second cluster to perform everything asynchronously,
7272 // including session initialization
7373 Cluster cluster2 = register(
74- createClusterBuilderNoDebouncing()
74+ createClusterBuilder()
7575 .addContactPoints(getContactPoints())
7676 .withPort(ccm().getBinaryPort())
7777 .build());