CASSSIDECAR-421: Upgrade Java driver to 4.x#336
CASSSIDECAR-421: Upgrade Java driver to 4.x#336lukasz-antoniak wants to merge 4 commits intoapache:trunkfrom
Conversation
| password: password | ||
| num_connections: 6 | ||
| # local_dc: datacenter1 | ||
| local_dc: datacenter1 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Could not find more appropriate driver exception type.
| { | ||
| sslContextBuilder = SslContextBuilder.forClient() | ||
| .protocols(List.of("TLSv1.2", "TLSv1.3")); | ||
| sslContext = SSLContext.getInstance("TLS"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Still to be analysed.
| } | ||
| } | ||
| catch (IllegalArgumentException | NoHostAvailableException e) | ||
| catch (IllegalArgumentException | AllNodesFailedException e) |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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.
| # OSHI dependencies | ||
| oshiVersion=6.9.0 | ||
| analyticsVersion=0.3.0 | ||
| analyticsVersion=0.4-SNAPSHOT |
There was a problem hiding this comment.
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.
Fixes CASSSIDECAR-421.
Attempt to upgrade Java driver to version 4.x. Discussed non-trivial changes in the comments below.