MartijnVisser commented on code in PR #56:
URL:
https://github.com/apache/flink-connector-cassandra/pull/56#discussion_r4669368868
##########
flink-connector-cassandra/src/test/java/org/apache/flink/streaming/connectors/cassandra/CassandraConnectorITCase.java:
##########
@@ -682,114 +668,4 @@ void testCassandraBatchRowFormat() throws Exception {
List<com.datastax.driver.core.Row> rows = rs.all();
assertThat(rows).hasSameSizeAs(rowCollection);
}
-
- @Test
- void testCassandraScalaTupleAtLeastOnceSinkBuilderDetection() throws
Exception {
- Class<scala.Tuple1<String>> c =
- (Class<scala.Tuple1<String>>) new
scala.Tuple1<>("hello").getClass();
- Seq<TypeInformation<?>> typeInfos =
- JavaConverters.asScalaBufferConverter(
- Collections.<TypeInformation<?>>singletonList(
- BasicTypeInfo.STRING_TYPE_INFO))
- .asScala();
- Seq<String> fieldNames =
-
JavaConverters.asScalaBufferConverter(Collections.singletonList("_1")).asScala();
-
- CaseClassTypeInfo<scala.Tuple1<String>> typeInfo =
- new CaseClassTypeInfo<scala.Tuple1<String>>(c, null,
typeInfos, fieldNames) {
- @Override
- public TypeSerializer<scala.Tuple1<String>>
createSerializer(
- ExecutionConfig config) {
- return null;
- }
- };
-
- StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
- DataStream<scala.Tuple1<String>> input =
- env.fromElements(new
scala.Tuple1<>("hello")).returns(typeInfo);
-
- CassandraSink.CassandraSinkBuilder<scala.Tuple1<String>> sinkBuilder =
- CassandraSink.addSink(input);
-
assertThat(sinkBuilder).isInstanceOf(CassandraSink.CassandraScalaProductSinkBuilder.class);
- }
-
- @Test
- void testCassandraScalaTupleAtLeastSink() throws Exception {
- CassandraScalaProductSink<scala.Tuple3<String, Integer, Integer>> sink
=
- new CassandraScalaProductSink<>(
- injectTableName(INSERT_DATA_QUERY),
- cassandraTestEnvironment.getBuilderForWriting());
-
- List<scala.Tuple3<String, Integer, Integer>> scalaTupleCollection =
new ArrayList<>(20);
- for (int i = 0; i < 20; i++) {
- scalaTupleCollection.add(new
scala.Tuple3<>(UUID.randomUUID().toString(), i, 0));
- }
- try {
- sink.open(new Configuration());
- for (scala.Tuple3<String, Integer, Integer> value :
scalaTupleCollection) {
- sink.invoke(value, SinkContextUtil.forTimestamp(0));
- }
- } finally {
- sink.close();
- }
-
- ResultSet rs =
- cassandraTestEnvironment.executeRequestWithTimeout(
- injectTableName(SELECT_DATA_QUERY));
- List<com.datastax.driver.core.Row> rows = rs.all();
- assertThat(rows).hasSameSizeAs(scalaTupleCollection);
-
- for (com.datastax.driver.core.Row row : rows) {
- scalaTupleCollection.remove(
- new scala.Tuple3<>(
- row.getString(TUPLE_ID_FIELD),
- row.getInt(TUPLE_COUNTER_FIELD),
- row.getInt(TUPLE_BATCHID_FIELD)));
- }
- assertThat(scalaTupleCollection).isEmpty();
- }
-
- @Test
- void testCassandraScalaTuplePartialColumnUpdate() throws Exception {
Review Comment:
Good catch. Ported it to `CassandraTupleSink` with a `Tuple3` as
`testCassandraTuplePartialColumnUpdate`.
##########
flink-connector-cassandra/pom.xml:
##########
@@ -38,16 +38,15 @@ under the License.
<!-- Allow users to pass custom connector versions -->
<properties>
<scala.binary.version>2.12</scala.binary.version>
- <scala-library.version>2.12.7</scala-library.version>
<slf4j.version>1.7.36</slf4j.version>
<junit5.version>5.8.1</junit5.version>
- <assertj.version>3.23.1</assertj.version>
+ <assertj.version>3.27.3</assertj.version>
<archunit.version>1.0.0</archunit.version>
<!-- For dependency convergence we exclude testContainers
commons-compress transitive dependency and keep only flink's.
Don't downgrade testcontainers otherwise the wrong
commons-compress transitive dependency will lead to NoClassDefFound-->
<testcontainers.version>1.21.4</testcontainers.version>
- <mockito.version>3.4.6</mockito.version>
- <byte-buddy.version>1.12.10</byte-buddy.version>
+ <mockito.version>5.19.0</mockito.version>
Review Comment:
Bumped objenesis to 3.4 and JUnit to 5.11.4. That also needed dropping the
`junit-jupiter-api` 5.8.2 and `junit-platform-commons` 1.8.2 convergence pins.
##########
flink-connector-cassandra/src/test/java/org/apache/flink/streaming/connectors/cassandra/CassandraConnectorITCase.java:
##########
@@ -456,6 +449,41 @@ void testCassandraCommitter() throws Exception {
cc1.close();
}
+ @Test
+ void testCassandraTupleWriteAheadSinkInJob() throws Exception {
+ StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+ env.setParallelism(1);
+ env.enableCheckpointing(100);
+ addWriteAheadSink(env);
+ env.execute();
+
+ ResultSet rs =
+ cassandraTestEnvironment.executeRequestWithTimeout(
+ injectTableName(SELECT_DATA_QUERY));
+ assertThat(rs.all()).hasSameSizeAs(collection);
+ }
+
+ @Test
+ void testCassandraTupleWriteAheadSinkRequiresCheckpointing() throws
Exception {
+ StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+ env.setParallelism(1);
+ addWriteAheadSink(env);
+
+ assertThatThrownBy(env::execute)
+ .satisfies(
+ anyCauseMatches(
+ IllegalStateException.class,
+ "The write-ahead log requires checkpointing to
be enabled."));
+ }
+
+ private void addWriteAheadSink(StreamExecutionEnvironment env) throws
Exception {
+ CassandraSink.addSink(env.fromData(collection))
+ .setQuery(injectTableName(INSERT_DATA_QUERY))
+
.setClusterBuilder(cassandraTestEnvironment.getBuilderForWriting())
+ .enableWriteAheadLog()
+ .build();
+ }
Review Comment:
Done, both job-level tests now run for tuples and rows.
##########
pom.xml:
##########
@@ -168,4 +168,28 @@ under the License.
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>java21</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+
<groupId>com.diffplug.spotless</groupId>
+
<artifactId>spotless-maven-plugin</artifactId>
+ <configuration>
+ <!--
google-java-format 1.7 from the parent does not run on Java 21.
+ Same as
the java21 profile in flink-connector-parent 2.0.0. -->
+
<skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+ </profiles>
</project>
Review Comment:
I would prefer to do that in a follow-up, since parent 2.0.0 also moves to
google-java-format 1.24 and Checkstyle 10. I've set `target.java.version` to 11
here in the meantime.
##########
flink-connector-cassandra/pom.xml:
##########
@@ -38,16 +38,15 @@ under the License.
<!-- Allow users to pass custom connector versions -->
<properties>
<scala.binary.version>2.12</scala.binary.version>
Review Comment:
Agreed that 4.0 is the moment to drop it. I'll do that in its own ticket,
since it changes the coordinates users depend on.
##########
flink-connector-cassandra/src/test/java/org/apache/flink/streaming/connectors/cassandra/CassandraConnectorITCase.java:
##########
@@ -289,7 +282,7 @@ protected CassandraTupleWriteAheadSink<Tuple3<String,
Integer, Integer>> createS
return new CassandraTupleWriteAheadSink<>(
injectTableName(INSERT_DATA_QUERY),
TypeExtractor.getForObject(new Tuple3<>("", 0, 0))
- .createSerializer(new ExecutionConfig()),
+ .createSerializer(new SerializerConfigImpl()),
Review Comment:
Good catch, I've fixed it here instead of in a follow-up. The base is on
JUnit 5 now and its harnesses enable checkpointing, so all 19 tests in the
class run and pass.
##########
flink-connector-cassandra/src/main/java/org/apache/flink/streaming/connectors/cassandra/CassandraSink.java:
##########
@@ -223,7 +208,10 @@ public static <IN> CassandraSinkBuilder<IN>
addSink(DataStream<IN> input) {
tupleInput
.getType()
.createSerializer(
-
tupleInput.getExecutionEnvironment().getConfig()));
+ tupleInput
+ .getExecutionEnvironment()
+ .getConfig()
+ .getSerializerConfig()));
Review Comment:
Done.
##########
flink-connector-cassandra/pom.xml:
##########
@@ -341,19 +329,13 @@ under the License.
<version>${byte-buddy.version}</version>
</dependency>
- <!-- For dependency convergence -->
<dependency>
- <groupId>com.esotericsoftware.kryo</groupId>
- <artifactId>kryo</artifactId>
- <version>2.24.0</version>
+ <groupId>net.bytebuddy</groupId>
+ <artifactId>byte-buddy-agent</artifactId>
+ <version>${byte-buddy.version}</version>
</dependency>
- <!-- For dependency convergence -->
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- <version>${scala-library.version}</version>
- </dependency>
+
Review Comment:
Removed all three.
--
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]