GitHub user ctamisier opened a pull request:
https://github.com/apache/flink/pull/5964
[FLINK-8655] [Cassandra Connector] add keyspace in cassandra sink builder
## What is the purpose of the change
This PR is an alternative to https://github.com/apache/flink/pull/5538.
## Brief change log
A discussion started on https://github.com/apache/flink/pull/5538 that i'm
quoting here:
> What about using the Configuration that is provided in
RichFunction.open(Configuration parameters) for the
CassandraSinkBase.open(Configuration configuration) {...} implementation ?
>
> I saw in old docs that Configuration can be used in the open(...) method
but today (1.4+) it might not be a good practice anymore.
>
> What about adding keyspace attribute in CassandraPojoSink and
CassandraSinkBuilder (throwing exception when not using a
CassandraPojoSinkBuilder for the moment).
> And create a new Configuration() with this keyspace in CassandraPojoSink.
> And finally do a cluster.connect(keyspace);
>
> I've done this here if you can have a look.
> I've updated CassandraConnectorITCase with a new test.
> I would like to run CassandraPojoSinkExample.main() to cover the
CassandraSink.addSink() mechanism, but it doesn't work for me (even on flink
master branch).
>
> Can this be a candidate for a PR, I am new to flink so it might break the
flink good practice principles...
> Let me know!
The reply from zentol (Chesnay) (**I will check this point**):
> We would have to pass the keyspace via the constructor as the
Configuration approach doesn't work for streaming.
>
> Generally speaking it isn't a problem to set the keyspace when creating
the connection. But I would like to know what happens if a POJO comes along
that explicitly sets the keyspace; is it ignored, respected or will it cause an
exception?
## Verifying this change
This change added tests and can be verified as follows:
- `testCassandraPojoNoAnnotatedKeyspaceAtLeastOnceSink()` in
`CassandraConnectorITCase.java`
- Need to run CassandraPojoSinkExample.main() to cover the
CassandraSink.addSink() mechanism, but it doesn't work for me (even on flink
master branch, **I will investigate**)
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): **no**
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: **no**
- The serializers: **don't know**
- The runtime per-record code paths (performance sensitive): **don't
know**
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Yarn/Mesos, ZooKeeper: **no**
- The S3 file system connector: **no**
## Documentation
- Does this pull request introduce a new feature? **yes**
- If yes, how is the feature documented? **JavaDocs**
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ctamisier/flink pojo-keyspace
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/5964.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #5964
----
commit 1ed3518a5f80c5e6bbbf70ab0b3c3d20b60f2e2f
Author: Clément Tamisier <clement.tamisier@...>
Date: 2018-05-06T15:04:18Z
[FLINK-8655] add keyspace in cassandra sink builder
----
---