Skip to content

CASSSIDECAR-421: Upgrade Java driver to 4.x#336

Draft
lukasz-antoniak wants to merge 4 commits intoapache:trunkfrom
lukasz-antoniak:CASSSIDECAR-421
Draft

CASSSIDECAR-421: Upgrade Java driver to 4.x#336
lukasz-antoniak wants to merge 4 commits intoapache:trunkfrom
lukasz-antoniak:CASSSIDECAR-421

Conversation

@lukasz-antoniak
Copy link
Copy Markdown
Member

Fixes CASSSIDECAR-421.

Attempt to upgrade Java driver to version 4.x. Discussed non-trivial changes in the comments below.

Comment thread conf/sidecar.yaml
password: password
num_connections: 6
# local_dc: datacenter1
local_dc: datacenter1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local_dc becomes a mandatory field. Java driver will not establish connectivity with the cluster unless local data centre is known. Default behaviour of 4.x version.

.withAuthProvider(new PlainTextAuthProvider("cassandra", "cassandra"))
// tests can create a lot of these Cluster objects, to avoid creating HWTs and
// event thread pools for each we have the override
.withNettyOptions(nettyOptions)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible to pass instance of Netty options, which are shared across multiple driver instances. Had to remove SharedExecutorNettyOptions, but tests run fine locally, so not sure if it is still needed.

else
{
throw new DriverInternalError("Unexpected exception thrown", cause);
throw new DriverExecutionException(cause);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not find more appropriate driver exception type.

{
sslContextBuilder = SslContextBuilder.forClient()
.protocols(List.of("TLSv1.2", "TLSv1.3"));
sslContext = SSLContext.getInstance("TLS");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing any TLS version enabled in JVM configuration. To explicitly hardcode support for only TLS 1.2 and 1.3 versions, we would need to change it on socket level with: sslSocket.setEnabledProtocols(new String[] {"TLSv1.2", "TLSv1.3"});. This requires implementing custom driver SslEngineFactory. Left it like this for now.

// of preventing the driver from trying to reconnect to them
// if we miss the `onUp` event, so we need to schedule reconnects
// for these hosts explicitly unless we have active connections.
driverUtils.startPeriodicReconnectionAttempt(cluster, host);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still to be analysed.

@lukasz-antoniak lukasz-antoniak marked this pull request as draft April 16, 2026 07:50
}
}
catch (IllegalArgumentException | NoHostAvailableException e)
catch (IllegalArgumentException | AllNodesFailedException e)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoNodeAvailableException is subclass of AllNodesFailedException.

.protocols(sslConfiguration.secureTransportProtocols());
// TODO: If we wish to explicitly limit allowed SSL protocols,
// we need to implement custom DefaultSslEngineFactory and use SSLEngine.setEnabledProtocols().
SSLContext sslContext = SSLContext.getInstance("TLS");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sslConfiguration.secureTransportProtocols() references to SSL configuration for Sidecar's HTTP endpoint. Is it intentional to apply it to driver configuration also?

List<RestoreJob> result = new ArrayList<>();
for (Row row : resultSet)
{
if (resultSet.getAvailableWithoutFetching() == 100 && !resultSet.isFullyFetched())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-fetching was removed. Documentation:

ResultSet behaves much like its 3.x counterpart, except that background pre-fetching (fetchMoreResults) was deliberately removed, in order to keep this interface simple and intuitive. If you were using synchronous iterations with background pre-fetching, you should now switch to fully asynchronous iterations (see below).

Since, we are fetching here restores that happened on given day, I was not sure if refactoring to fully async make s sense.

Comment thread gradle.properties
# OSHI dependencies
oshiVersion=6.9.0
analyticsVersion=0.3.0
analyticsVersion=0.4-SNAPSHOT
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary increment to test Analytics and Sidecar locally. Due to shared interface of CQLSessionProvider (which references driver 3.x API that changed), both projects have to be upgraded together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant