Class CassandraSinkBase<IN,​V>

  • Type Parameters:
    IN - Type of the elements emitted by this sink
    All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.RichFunction, org.apache.flink.streaming.api.checkpoint.CheckpointedFunction, org.apache.flink.streaming.api.functions.sink.SinkFunction<IN>
    Direct Known Subclasses:
    AbstractCassandraTupleSink, CassandraPojoSink

    public abstract class CassandraSinkBase<IN,​V>
    extends org.apache.flink.streaming.api.functions.sink.RichSinkFunction<IN>
    implements org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
    CassandraSinkBase is the common abstract class of CassandraPojoSink and CassandraTupleSink.

    In case of experiencing the following error: Error while sending value. com.datastax.driver.core.exceptions.WriteTimeoutException: Cassandra timeout during write query at consistency LOCAL_ONE (1 replica were required but only 0 acknowledged the write),

    it is recommended to increase the Cassandra write timeout to adapt to your workload in your Cassandra cluster so that such timeout errors do not happen. For that you need to raise write_request_timeout_in_ms conf parameter in your cassandra.yml. Indeed, This exception means that Cassandra coordinator node (internal Cassandra) waited too long for an internal replication (replication to another node and did not ack the write. It is not recommended to lower the replication factor in your Cassandra cluster because it is mandatory that you do not loose data in case of a Cassandra cluster failure. Waiting for a single replica for write acknowledge is the minimum level for this guarantee in Cassandra.}

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.flink.streaming.api.functions.sink.SinkFunction

        org.apache.flink.streaming.api.functions.sink.SinkFunction.Context
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.datastax.driver.core.Cluster cluster  
      protected org.slf4j.Logger log  
      protected com.datastax.driver.core.Session session  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected com.datastax.driver.core.Session createSession()  
      void initializeState​(org.apache.flink.runtime.state.FunctionInitializationContext context)  
      void invoke​(IN value)  
      void open​(org.apache.flink.configuration.Configuration configuration)  
      abstract com.google.common.util.concurrent.ListenableFuture<V> send​(IN value)  
      void snapshotState​(org.apache.flink.runtime.state.FunctionSnapshotContext ctx)  
      • Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction

        getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
      • Methods inherited from interface org.apache.flink.streaming.api.functions.sink.SinkFunction

        finish, invoke, writeWatermark
    • Field Detail

      • log

        protected final org.slf4j.Logger log
      • cluster

        protected transient com.datastax.driver.core.Cluster cluster
      • session

        protected transient com.datastax.driver.core.Session session
    • Method Detail

      • open

        public void open​(org.apache.flink.configuration.Configuration configuration)
        Specified by:
        open in interface org.apache.flink.api.common.functions.RichFunction
        Overrides:
        open in class org.apache.flink.api.common.functions.AbstractRichFunction
      • close

        public void close()
                   throws Exception
        Specified by:
        close in interface org.apache.flink.api.common.functions.RichFunction
        Overrides:
        close in class org.apache.flink.api.common.functions.AbstractRichFunction
        Throws:
        Exception
      • initializeState

        public void initializeState​(org.apache.flink.runtime.state.FunctionInitializationContext context)
                             throws Exception
        Specified by:
        initializeState in interface org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
        Throws:
        Exception
      • snapshotState

        public void snapshotState​(org.apache.flink.runtime.state.FunctionSnapshotContext ctx)
                           throws Exception
        Specified by:
        snapshotState in interface org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
        Throws:
        Exception
      • invoke

        public void invoke​(IN value)
                    throws Exception
        Specified by:
        invoke in interface org.apache.flink.streaming.api.functions.sink.SinkFunction<IN>
        Throws:
        Exception
      • createSession

        protected com.datastax.driver.core.Session createSession()
      • send

        public abstract com.google.common.util.concurrent.ListenableFuture<V> send​(IN value)