Class CassandraSink<IN>
- java.lang.Object
-
- org.apache.flink.streaming.connectors.cassandra.CassandraSink<IN>
-
- Type Parameters:
IN
- input type
public class CassandraSink<IN> extends Object
This class wraps different Cassandra sink implementations to provide a common interface for all of them.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CassandraSink.CassandraPojoSinkBuilder<IN>
Builder for aCassandraPojoSink
.static class
CassandraSink.CassandraRowSinkBuilder
Builder for aCassandraRowSink
.static class
CassandraSink.CassandraScalaProductSinkBuilder<IN extends scala.Product>
Builder for aCassandraScalaProductSink
.static class
CassandraSink.CassandraSinkBuilder<IN>
Builder for aCassandraSink
.static class
CassandraSink.CassandraTupleSinkBuilder<IN extends org.apache.flink.api.java.tuple.Tuple>
Builder for aCassandraTupleSink
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <IN> CassandraSink.CassandraSinkBuilder<IN>
addSink(org.apache.flink.streaming.api.datastream.DataStream<IN> input)
Writes a DataStream into a Cassandra database.static <IN> CassandraSink.CassandraSinkBuilder<IN>
addSink(org.apache.flink.streaming.api.scala.DataStream<IN> input)
Writes a DataStream into a Cassandra database.CassandraSink<IN>
disableChaining()
Turns off chaining for this operator so thread co-location will not be used as an optimization.CassandraSink<IN>
name(String name)
Sets the name of this sink.CassandraSink<IN>
setParallelism(int parallelism)
Sets the parallelism for this sink.CassandraSink<IN>
setUidHash(String uidHash)
Sets an user provided hash for this operator.CassandraSink<IN>
slotSharingGroup(String slotSharingGroup)
Sets the slot sharing group of this operation.CassandraSink<IN>
uid(String uid)
Sets an ID for this operator.
-
-
-
Method Detail
-
name
public CassandraSink<IN> name(String name)
Sets the name of this sink. This name is used by the visualization and logging during runtime.- Returns:
- The named sink.
-
uid
@PublicEvolving public CassandraSink<IN> uid(String uid)
Sets an ID for this operator.The specified ID is used to assign the same operator ID across job submissions (for example when starting a job from a savepoint).
Important: this ID needs to be unique per transformation and job. Otherwise, job submission will fail.
- Parameters:
uid
- The unique user-specified ID of this transformation.- Returns:
- The operator with the specified ID.
-
setUidHash
@PublicEvolving public CassandraSink<IN> setUidHash(String uidHash)
Sets an user provided hash for this operator. This will be used AS IS the create the JobVertexID.The user provided hash is an alternative to the generated hashes, that is considered when identifying an operator through the default hash mechanics fails (e.g. because of changes between Flink versions).
Important: this should be used as a workaround or for trouble shooting. The provided hash needs to be unique per transformation and job. Otherwise, job submission will fail. Furthermore, you cannot assign user-specified hash to intermediate nodes in an operator chain and trying so will let your job fail.
A use case for this is in migration between Flink versions or changing the jobs in a way that changes the automatically generated hashes. In this case, providing the previous hashes directly through this method (e.g. obtained from old logs) can help to reestablish a lost mapping from states to their target operator.
- Parameters:
uidHash
- The user provided hash for this operator. This will become the JobVertexID, which is shown in the logs and web ui.- Returns:
- The operator with the user provided hash.
-
setParallelism
public CassandraSink<IN> setParallelism(int parallelism)
Sets the parallelism for this sink. The degree must be higher than zero.- Parameters:
parallelism
- The parallelism for this sink.- Returns:
- The sink with set parallelism.
-
disableChaining
public CassandraSink<IN> disableChaining()
Turns off chaining for this operator so thread co-location will not be used as an optimization.Chaining can be turned off for the whole job by
StreamExecutionEnvironment.disableOperatorChaining()
however it is not advised for performance considerations.- Returns:
- The sink with chaining disabled
-
slotSharingGroup
public CassandraSink<IN> slotSharingGroup(String slotSharingGroup)
Sets the slot sharing group of this operation. Parallel instances of operations that are in the same slot sharing group will be co-located in the same TaskManager slot, if possible.Operations inherit the slot sharing group of input operations if all input operations are in the same slot sharing group and no slot sharing group was explicitly specified.
Initially an operation is in the default slot sharing group. An operation can be put into the default group explicitly by setting the slot sharing group to
"default"
.- Parameters:
slotSharingGroup
- The slot sharing group name.
-
addSink
public static <IN> CassandraSink.CassandraSinkBuilder<IN> addSink(org.apache.flink.streaming.api.scala.DataStream<IN> input)
Writes a DataStream into a Cassandra database.- Type Parameters:
IN
- input type- Parameters:
input
- input DataStream- Returns:
- CassandraSinkBuilder, to further configure the sink
-
addSink
public static <IN> CassandraSink.CassandraSinkBuilder<IN> addSink(org.apache.flink.streaming.api.datastream.DataStream<IN> input)
Writes a DataStream into a Cassandra database.- Type Parameters:
IN
- input type- Parameters:
input
- input DataStream- Returns:
- CassandraSinkBuilder, to further configure the sink
-
-