kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a2d8e1d5ec51d44ef6da4b631a58793a7a7142ff11f7fd38f3d8935929649d3d |
|---|---|
| Author | Alexandre Dutra <adutra@users.noreply.github.com> · 2016-06-29 20:04 +02:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-06-29 11:04 -07:00 |
| Parents | 3fbb08c92aab |
7 files changed
modified changelog/README.md +1 −0
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | - [bug] JAVA-1139: ConnectionException.getMessage() throws NPE if address is null. |
| 14 | 14 | - [bug] JAVA-1202: Handle null rpc_address when checking schema agreement. |
| 15 | 15 | - [improvement] JAVA-1198: Document that BoundStatement is not thread-safe. |
| 16 | +- [improvement] JAVA-1200: Upgrade LZ4 to 1.3.0. | |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | ### 3.0.2 |
modified driver-tests/osgi/pom.xml +17 −1
| @@ -34,6 +34,7 @@ | ||
| 34 | 34 | <felix.version>4.6.0</felix.version> |
| 35 | 35 | <!-- more recent version require JDK7+ --> |
| 36 | 36 | <pax-exam.version>3.6.0</pax-exam.version> |
| 37 | + <url.version>2.4.0</url.version> | |
| 37 | 38 | <logback.version>1.1.3</logback.version> |
| 38 | 39 | <test.groups>none</test.groups> |
| 39 | 40 | <!-- |
| @@ -71,6 +72,12 @@ | ||
| 71 | 72 | <version>${felix.version}</version> |
| 72 | 73 | </dependency> |
| 73 | 74 | |
| 75 | + <dependency> | |
| 76 | + <groupId>org.slf4j</groupId> | |
| 77 | + <artifactId>slf4j-api</artifactId> | |
| 78 | + <version>1.7.5</version> | |
| 79 | + </dependency> | |
| 80 | + | |
| 74 | 81 | <dependency> |
| 75 | 82 | <groupId>com.datastax.cassandra</groupId> |
| 76 | 83 | <artifactId>cassandra-driver-core</artifactId> |
| @@ -95,7 +102,7 @@ | ||
| 95 | 102 | |
| 96 | 103 | <dependency> |
| 97 | 104 | <groupId>org.ops4j.pax.exam</groupId> |
| 98 | - <artifactId>pax-exam-container-native</artifactId> | |
| 105 | + <artifactId>pax-exam-container-forked</artifactId> | |
| 99 | 106 | <version>${pax-exam.version}</version> |
| 100 | 107 | <scope>test</scope> |
| 101 | 108 | </dependency> |
| @@ -107,6 +114,13 @@ | ||
| 107 | 114 | <scope>test</scope> |
| 108 | 115 | </dependency> |
| 109 | 116 | |
| 117 | + <dependency> | |
| 118 | + <groupId>org.ops4j.pax.url</groupId> | |
| 119 | + <artifactId>pax-url-reference</artifactId> | |
| 120 | + <version>${url.version}</version> | |
| 121 | + <scope>test</scope> | |
| 122 | + </dependency> | |
| 123 | + | |
| 110 | 124 | <dependency> |
| 111 | 125 | <groupId>javax.transaction</groupId> |
| 112 | 126 | <artifactId>jta</artifactId> |
| @@ -146,12 +160,14 @@ | ||
| 146 | 160 | <groupId>ch.qos.logback</groupId> |
| 147 | 161 | <artifactId>logback-classic</artifactId> |
| 148 | 162 | <version>${logback.version}</version> |
| 163 | + <scope>test</scope> | |
| 149 | 164 | </dependency> |
| 150 | 165 | |
| 151 | 166 | <dependency> |
| 152 | 167 | <groupId>ch.qos.logback</groupId> |
| 153 | 168 | <artifactId>logback-core</artifactId> |
| 154 | 169 | <version>${logback.version}</version> |
| 170 | + <scope>test</scope> | |
| 155 | 171 | </dependency> |
| 156 | 172 | |
| 157 | 173 | </dependencies> |
modified driver-tests/osgi/src/main/java/com/datastax/driver/osgi/impl/Activator.java +39 −7
| @@ -15,42 +15,73 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.osgi.impl; |
| 17 | 17 | |
| 18 | -import com.datastax.driver.core.Cluster; | |
| 19 | -import com.datastax.driver.core.CodecRegistry; | |
| 20 | -import com.datastax.driver.core.Metadata; | |
| 21 | -import com.datastax.driver.core.Session; | |
| 18 | +import com.datastax.driver.core.*; | |
| 22 | 19 | import com.datastax.driver.core.exceptions.InvalidQueryException; |
| 20 | +import com.datastax.driver.core.policies.PercentileSpeculativeExecutionPolicy; | |
| 23 | 21 | import com.datastax.driver.extras.codecs.date.SimpleTimestampCodec; |
| 24 | 22 | import com.datastax.driver.osgi.api.MailboxService; |
| 25 | 23 | import org.osgi.framework.BundleActivator; |
| 26 | 24 | import org.osgi.framework.BundleContext; |
| 25 | +import org.slf4j.Logger; | |
| 26 | +import org.slf4j.LoggerFactory; | |
| 27 | 27 | |
| 28 | 28 | import java.util.Hashtable; |
| 29 | 29 | |
| 30 | +import static com.datastax.driver.core.ProtocolOptions.Compression.LZ4; | |
| 30 | 31 | import static com.datastax.driver.osgi.api.MailboxMessage.TABLE; |
| 31 | 32 | |
| 32 | 33 | public class Activator implements BundleActivator { |
| 33 | 34 | |
| 35 | + private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class); | |
| 36 | + | |
| 34 | 37 | private Cluster cluster; |
| 35 | 38 | |
| 36 | 39 | @Override |
| 37 | 40 | public void start(BundleContext context) throws Exception { |
| 41 | + | |
| 42 | + VersionNumber ver = VersionNumber.parse(context.getProperty("cassandra.version")); | |
| 43 | + LOGGER.info("C* version: {}", ver); | |
| 44 | + | |
| 38 | 45 | String contactPointsStr = context.getProperty("cassandra.contactpoints"); |
| 39 | 46 | if (contactPointsStr == null) { |
| 40 | 47 | contactPointsStr = "127.0.0.1"; |
| 41 | 48 | } |
| 49 | + LOGGER.info("Contact points: {}", contactPointsStr); | |
| 42 | 50 | String[] contactPoints = contactPointsStr.split(","); |
| 43 | 51 | |
| 44 | 52 | String keyspace = context.getProperty("cassandra.keyspace"); |
| 45 | 53 | if (keyspace == null) { |
| 46 | 54 | keyspace = "mailbox"; |
| 47 | 55 | } |
| 56 | + LOGGER.info("Keyspace: {}", keyspace); | |
| 48 | 57 | keyspace = Metadata.quote(keyspace); |
| 49 | 58 | |
| 50 | - cluster = Cluster.builder() | |
| 59 | + Cluster.Builder builder = Cluster.builder() | |
| 51 | 60 | .addContactPoints(contactPoints) |
| 52 | - .withCodecRegistry(new CodecRegistry().register(SimpleTimestampCodec.instance)) | |
| 53 | - .build(); | |
| 61 | + .withCodecRegistry(new CodecRegistry().register(SimpleTimestampCodec.instance)); | |
| 62 | + | |
| 63 | + String compression = context.getProperty("cassandra.compression"); | |
| 64 | + if (compression != null) { | |
| 65 | + if (ver.getMajor() < 2 && compression.equals(LZ4.name())) { | |
| 66 | + LOGGER.warn("Requested LZ4 compression but C* version is not compatible, disabling"); | |
| 67 | + } else { | |
| 68 | + LOGGER.info("Compression: {}", compression); | |
| 69 | + builder.withCompression(ProtocolOptions.Compression.valueOf(compression)); | |
| 70 | + } | |
| 71 | + } else { | |
| 72 | + LOGGER.info("Compression: NONE"); | |
| 73 | + } | |
| 74 | + | |
| 75 | + String usePercentileSpeculativeExecutionPolicy = context.getProperty("cassandra.usePercentileSpeculativeExecutionPolicy"); | |
| 76 | + if ("true".equals(usePercentileSpeculativeExecutionPolicy)) { | |
| 77 | + PerHostPercentileTracker perHostPercentileTracker = PerHostPercentileTracker.builderWithHighestTrackableLatencyMillis(15000).build(); | |
| 78 | + builder.withSpeculativeExecutionPolicy(new PercentileSpeculativeExecutionPolicy(perHostPercentileTracker, 99, 1)); | |
| 79 | + LOGGER.info("Use PercentileSpeculativeExecutionPolicy: YES"); | |
| 80 | + } else { | |
| 81 | + LOGGER.info("Use PercentileSpeculativeExecutionPolicy: NO"); | |
| 82 | + } | |
| 83 | + | |
| 84 | + cluster = builder.build(); | |
| 54 | 85 | |
| 55 | 86 | Session session; |
| 56 | 87 | try { |
| @@ -73,6 +104,7 @@ | ||
| 73 | 104 | mailbox.init(); |
| 74 | 105 | |
| 75 | 106 | context.registerService(MailboxService.class.getName(), mailbox, new Hashtable<String, String>()); |
| 107 | + LOGGER.info("Mailbox Service successfully initialized"); | |
| 76 | 108 | } |
| 77 | 109 | |
| 78 | 110 | @Override |
modified driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java +17 −0
| @@ -15,6 +15,8 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.osgi; |
| 17 | 17 | |
| 18 | +import com.datastax.driver.core.CCMBridge; | |
| 19 | +import com.datastax.driver.core.ProtocolOptions; | |
| 18 | 20 | import com.datastax.driver.core.TestUtils; |
| 19 | 21 | import org.ops4j.pax.exam.Option; |
| 20 | 22 | import org.ops4j.pax.exam.options.CompositeOption; |
| @@ -48,6 +50,19 @@ | ||
| 48 | 50 | return mavenBundle("com.google.guava", "guava", "16.0.1"); |
| 49 | 51 | } |
| 50 | 52 | |
| 53 | + public static CompositeOption lz4Bundle() { | |
| 54 | + return new CompositeOption() { | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public Option[] getOptions() { | |
| 58 | + return options( | |
| 59 | + systemProperty("cassandra.compression").value(ProtocolOptions.Compression.LZ4.name()), | |
| 60 | + mavenBundle("net.jpountz.lz4", "lz4", "1.3.0") | |
| 61 | + ); | |
| 62 | + } | |
| 63 | + }; | |
| 64 | + } | |
| 65 | + | |
| 51 | 66 | public static CompositeOption nettyBundles() { |
| 52 | 67 | final String nettyVersion = "4.0.33.Final"; |
| 53 | 68 | return new CompositeOption() { |
| @@ -78,12 +93,14 @@ | ||
| 78 | 93 | // Delegate javax.security.cert to the parent classloader. javax.security.cert.X509Certificate is used in |
| 79 | 94 | // io.netty.util.internal.EmptyArrays, but not directly by the driver. |
| 80 | 95 | bootDelegationPackage("javax.security.cert"), |
| 96 | + systemProperty("cassandra.version").value(CCMBridge.getCassandraVersion()), | |
| 81 | 97 | systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1), |
| 82 | 98 | systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"), |
| 83 | 99 | mavenBundle("org.slf4j", "slf4j-api", "1.7.5"), |
| 84 | 100 | mavenBundle("ch.qos.logback", "logback-classic", "1.1.3"), |
| 85 | 101 | mavenBundle("ch.qos.logback", "logback-core", "1.1.3"), |
| 86 | 102 | mavenBundle("io.dropwizard.metrics", "metrics-core", "3.1.2"), |
| 103 | + mavenBundle("org.testng", "testng", "6.8.8"), | |
| 87 | 104 | systemPackages("org.testng", "org.junit", "org.junit.runner", "org.junit.runner.manipulation", |
| 88 | 105 | "org.junit.runner.notification", "com.jcabi.manifests") |
| 89 | 106 | ); |
added driver-tests/osgi/src/test/java/com/datastax/driver/osgi/MailboxServiceLZ4IT.java +58 −0
| @@ -0,0 +1,58 @@ | ||
| 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.osgi; | |
| 17 | + | |
| 18 | +import com.datastax.driver.osgi.api.MailboxException; | |
| 19 | +import org.ops4j.pax.exam.Configuration; | |
| 20 | +import org.ops4j.pax.exam.Option; | |
| 21 | +import org.ops4j.pax.exam.testng.listener.PaxExam; | |
| 22 | +import org.testng.annotations.Listeners; | |
| 23 | +import org.testng.annotations.Test; | |
| 24 | + | |
| 25 | +import static com.datastax.driver.osgi.BundleOptions.*; | |
| 26 | +import static org.ops4j.pax.exam.CoreOptions.options; | |
| 27 | + | |
| 28 | +@Listeners({CCMBridgeListener.class, PaxExam.class}) | |
| 29 | +public class MailboxServiceLZ4IT extends MailboxServiceTests { | |
| 30 | + | |
| 31 | + @Configuration | |
| 32 | + public Option[] lz4Config() { | |
| 33 | + return options( | |
| 34 | + defaultOptions(), | |
| 35 | + lz4Bundle(), | |
| 36 | + nettyBundles(), | |
| 37 | + guavaBundle(), | |
| 38 | + extrasBundle(), | |
| 39 | + mappingBundle(), | |
| 40 | + driverBundle(), | |
| 41 | + mailboxBundle() | |
| 42 | + ); | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Exercises a 'mailbox' service provided by an OSGi bundle that depends on the driver with | |
| 47 | + * LZ4 compression activated. | |
| 48 | + * | |
| 49 | + * @test_category packaging | |
| 50 | + * @expected_result Can create, retrieve and delete data using the mailbox service. | |
| 51 | + * @jira_ticket JAVA-1200 | |
| 52 | + * @since 3.1.0 | |
| 53 | + */ | |
| 54 | + @Test(groups = "short") | |
| 55 | + public void test_lz4() throws MailboxException { | |
| 56 | + checkService(); | |
| 57 | + } | |
| 58 | +} |
modified manual/compression/README.md +1 −1
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | <dependency> |
| 28 | 28 | <groupId>net.jpountz.lz4</groupId> |
| 29 | 29 | <artifactId>lz4</artifactId> |
| 30 | - <version>1.2.0</version> | |
| 30 | + <version>1.3.0</version> | |
| 31 | 31 | </dependency> |
| 32 | 32 | ``` |
| 33 | 33 |
modified pom.xml +1 −1
| @@ -54,7 +54,7 @@ | ||
| 54 | 54 | <netty.version>4.0.37.Final</netty.version> |
| 55 | 55 | <metrics.version>3.1.2</metrics.version> |
| 56 | 56 | <snappy.version>1.0.5</snappy.version> |
| 57 | - <lz4.version>1.2.0</lz4.version> | |
| 57 | + <lz4.version>1.3.0</lz4.version> | |
| 58 | 58 | <hdr.version>2.1.4</hdr.version> |
| 59 | 59 | <!-- driver-extras module --> |
| 60 | 60 | <jackson.version>2.6.3</jackson.version> |