[RELEASE] Java driver 4.9.0

43 views
Skip to first unread message

Olivier Michallat

unread,
Sep 1, 2020, 2:11:25 PM9/1/20
to DataStax Java Driver for Apache Cassandra User Mailing List
We've just released version 4.9.0 of the driver. This minor revision brings exciting new features to the mapper:

Counter updates are now supported, via a new @Increment annotation. Given an entity that maps to a counter table, increment methods take the primary key, and one or more parameters that represent the deltas to apply to the corresponding counter columns:

@Entity
public class Votes {
  @PartitionKey private int articleId;
  private long upVotes;
  private long downVotes;
  // ... getters and setters
}

@Increment(entityClass = Votes.class)
void incrementUpVotes(int articleId, long upVotes);



Next, the mapper now supports immutable entities, enabled with the @PropertyStrategy annotation. When an entity is marked as immutable, the mapper will expect an "all columns" constructor instead of setters to populate new instances:

@Entity
@PropertyStrategy(mutable = false)
public class Product {
  @PartitionKey private final UUID productId;
  private final String description;
  public Product(UUID productId, String description) { ... }
  // ... getters, no setters
}


@PropertyStrategy also allows you to switch to a "fluent" accessor style, where getters and setters are named after the property directly, without "get" of "set" prefixes.

We've added language detection, so that the mapper switches to the most appropriate property strategy defaults depending on the context. It currently recognizes Kotlin data classes (immutable, regular getters), Java 14 records (immutable, fluent getters) and Scala case classes (immutable, fluent getters).

Speaking of alternative languages, we have a new set of end-to-end examples that show how to configure the mapper in various environments: Kotlin with a Gradle build, Lombok, Java 14 records, and Scala with an sbt build.

Note that integrating with Scala is a bit more complicated because it does not support annotation processing natively: the mapper cannot operate on Scala sources directly, but it can operate on class files, so the build compiles in multiple passes. It should be possible to use a similar approach with other JVM languages.


In the core driver, we identified an issue with unnecessary data duplication in the token map, and optimized the code to reduce heap usage. The token map is a common hotspot in large clusters, especially with vnodes. As a reminder, we strongly recommend filtering the metadata with the advanced.metadata.schema.refreshed-keyspaces option, to only include the keyspaces that your application is actively querying. We have further optimizations coming up in 4.10, in particular we plan to exclude system keyspaces by default. Follow JAVA-2873 for more details.


Finally, we made it easier to switch the metrics framework. The driver uses DropWizard by default. We added support for Micrometer and MicroProfile in 4.8.0, but that required a bit of custom development. It is now possible with a simple configuration option.


Here's the full changelog:

- [documentation] JAVA-2823: Make Astra more visible in the docs
- [documentation] JAVA-2869: Advise against using 4.5.x-4.6.0 in the upgrade guide
- [documentation] JAVA-2868: Cover reconnect-on-init in the manual
- [improvement] JAVA-2827: Exclude unused Tinkerpop transitive dependencies
- [improvement] JAVA-2827: Remove dependency to Tinkerpop gremlin-driver
- [task] JAVA-2859: Upgrade Tinkerpop to 3.4.8
- [bug] JAVA-2726: Fix Tinkerpop incompatibility with JPMS
- [bug] JAVA-2842: Remove security vulnerabilities introduced by Tinkerpop
- [bug] JAVA-2867: Revisit compressor substitutions
- [improvement] JAVA-2870: Optimize memory usage of token map
- [improvement] JAVA-2855: Allow selection of the metrics framework via the config
- [improvement] JAVA-2864: Revisit mapper processor's messaging
- [new feature] JAVA-2816: Support immutability and fluent accessors in the mapper
- [new feature] JAVA-2721: Add counter support in the mapper
- [bug] JAVA-2863: Reintroduce mapper processor dependency to SLF4J

As usual, the driver is available from Maven central:

<dependency>
  <groupId>com.datastax.oss</groupId>
  <artifactId>java-driver-core</artifactId>
  <version>4.9.0</version>
</dependency>

--
The Java driver team
Reply all
Reply to author
Forward
0 new messages