We've just released version 4.6.0 of the driver. This minor revision includes various new features:
It improves compatibility with the upcoming Cassandra 4:
We're introducing a new built-in utility:
OffsetPager. This allows you to implement offset queries such as "given a page size of 20, fetch page 5".
Cassandra does not support this natively, but it is a very common use case that we often see people struggle with. Our approach is to emulate it on the client side, by restarting from the beginning of the result set every time, and skipping until the requested page is reached. This is inefficient by nature (O(n) in the number of rows skipped), but we believe that, with proper safeguards, it can be an acceptable tradeoff in a lot of cases.
Please
read the javadocs carefully, and make sure you understand the performance implications. The same information is available in the
manual.
We've added a new configuration option: advanced.session-leak.threshold. When the number of active CqlSession instances in the JVM exceeds this threshold, a warning will be logged for every new session. This is intended to quickly detect resource leaks (client applications that create too many sessions and don't close them properly). The default is 4. You can raise it if your application has a legitimate need for more, or set it to 0 if you'd rather disable the feature.
The mapper can now parameterize DAOs by
configuration profile: you write a DAO interface once, and then create multiple instances that will each target a particular profile. This is done with a new
@DaoProfile annotation, similar to
@DaoKeyspace and
@DaoTable. See the
manual for an example.
The driver JARs are now compatible with the Java module system. We've made sure that they can be used as automatic modules in a JPMS application.
Finally, we have a new built-in config loader:
DriverConfigLoader.fromMap(). It manages the configuration entirely in memory, without involving any file (
reference.conf or
application.conf). It does not use Typesafe config at all, the dependency can be excluded. This should appeal to tool developers who embed the driver and already have their own configuration mechanism; the experience is closer to the fully programmatic API of driver 3.
Here is the full changelog:
- [improvement] JAVA-2741: Make keyspace/table metadata impls serializable
- [bug] JAVA-2740: Extend peer validity check to include datacenter, rack and tokens
- [bug] JAVA-2744: Recompute token map when node is added
- [new feature] JAVA-2614: Provide a utility to emulate offset paging on the client side
- [new feature] JAVA-2718: Warn when the number of sessions exceeds a configurable threshold
- [improvement] JAVA-2664: Add a callback to inject the session in listeners
- [bug] JAVA-2698: TupleCodec and UdtCodec give wrong error message when parsing fails
- [improvement] JAVA-2435: Add automatic-module-names to the manifests
- [new feature] JAVA-2054: Add now_in_seconds to protocol v5 query messages
- [bug] JAVA-2711: Fix handling of UDT keys in the mapper
- [improvement] JAVA-2631: Add getIndex() shortcuts to TableMetadata
- [improvement] JAVA-2679: Add port information to QueryTrace and TraceEvent
- [improvement] JAVA-2184: Refactor DescribeIT to improve maintainability
- [new feature] JAVA-2600: Add map-backed config loader
- [new feature] JAVA-2105: Add support for transient replication
- [new feature] JAVA-2670: Provide base class for mapped custom codecs
- [new feature] JAVA-2633: Add execution profile argument to DAO mapper factory methods
- [improvement] JAVA-2667: Add ability to fail the build when integration tests fail
- [bug] JAVA-1861: Add Metadata.getClusterName()
As usual, the driver is available from Maven central:
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.5.0</version>
</dependency>
--
The Java driver team