davsclaus opened a new pull request, #3195: URL: https://github.com/apache/camel-kamelets/pull/3195
Part of #3170: `cassandra-sink` can be used with a Cassandra cluster whose datacenter is not called `datacenter1`. ### The option `datacenter` is an optional string: the name of the local datacenter, the datacenter the nodes in `connectionHost` belong to, as `nodetool status` shows it. - It sets the `datacenter` parameter of the cql endpoint. The driver runs the statements only on the nodes of that datacenter. - Until now the Kamelet always used the cql default, `datacenter1`. With a cluster whose datacenter has another name, the route fails to start with `No node was available to execute the query`, and the driver logs `You specified datacenter1 as the local DC, but some contact points are from a different DC`. With `prepareStatements: false` the route starts, and then each message fails with the same error. `datacenter` deliberately has no `default`. When it is not set, the optional placeholder drops the parameter, so the endpoint URI is exactly today's, and the cql default `datacenter1` applies. A `default: datacenter1` would change nothing at runtime but put a new parameter on every endpoint. The option description, the "Good to know" paragraph and the partial page say how to find the name of the datacenter and what happens when it does not match. The partial page has an example. ### TLS: not added The cql endpoint has no TLS option. TLS can only be turned on with a `CqlSession` bean that the integration builds itself, or through the configuration of the Cassandra driver: an `application.conf` on the classpath, or `datastax-java-driver.advanced.ssl-engine-factory.*` JVM system properties. A Kamelet can set neither. Adding TLS to the Kamelet needs a Camel change first, for example an `sslContextParameters` option, or an option that loads a driver configuration file, on the cql endpoint. "Good to know" and the partial page now say that the Kamelet connects without TLS, so a cluster that accepts only TLS connections refuses it. ### Verification Tested with Camel JBang (4.24.0-SNAPSHOT) against three `cassandra:5` containers: - a datacenter called `dc-east` (`CASSANDRA_DC=dc-east`, `GossipingPropertyFileSnitch`); - a default `datacenter1` installation; - a `datacenter1` installation that accepts only TLS connections (`client_encryption_options.enabled: true`, `optional: false`). Each case sends one row with the INSERT statement of the description. Rows were checked with `cqlsh`. | Case | Result | |---|---| | `dc-east`, option unset, Kamelet from `main` | Fails to start: `NoNodeAvailableException: No node was available to execute the query` | | `dc-east`, option unset, Kamelet from this PR | Fails the same way | | `dc-east`, option unset, `prepareStatements: false` | Starts; the message fails with `NoNodeAvailableException` | | `dc-east`, `datacenter: dc-east` | Row inserted | | `dc-east`, `datacenter: dc-west` (wrong name) | Fails to start: `NoNodeAvailableException` | | `datacenter1`, option unset, Kamelet from `main` | Row inserted | | `datacenter1`, option unset, Kamelet from this PR | Row inserted | | `datacenter1`, `datacenter: datacenter1` | Row inserted | | Endpoint URI, option unset (`camel get endpoint`) | No `datacenter` parameter, the same as today | | Endpoint URI, `datacenter: dc-east` | `...&datacenter=dc-east&...` | | TLS-only cluster, Kamelet as is | Fails to start: `AllNodesFailedException: Could not reach any contact point ... Lost connection to remote peer` | | TLS-only cluster, with the JVM system properties `datastax-java-driver.advanced.ssl-engine-factory.class=DefaultSslEngineFactory` and a trust store | Row inserted; this works without any change to the Kamelet, but cannot be set from it | `./mvnw clean verify -DskipTests` and then `./mvnw clean verify` passed. `verify` does not copy the Kamelet into `library/camel-kamelets` (that runs in the `install` phase), so the copy was refreshed with `./mvnw -pl library/camel-kamelets resources:copy-resources@copy-resource-one`, and `./mvnw clean verify` passed again with it. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
