Class MongoSinkTask

  • All Implemented Interfaces:
    org.apache.kafka.connect.connector.Task

    public class MongoSinkTask
    extends org.apache.kafka.connect.sink.SinkTask
    • Field Summary

      • Fields inherited from class org.apache.kafka.connect.sink.SinkTask

        context, TOPICS_CONFIG, TOPICS_REGEX_CONFIG
    • Constructor Summary

      Constructors 
      Constructor Description
      MongoSinkTask()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void flush​(java.util.Map<org.apache.kafka.common.TopicPartition,​org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets)
      Flush all records that have been put(Collection) for the specified topic-partitions.
      void put​(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord> records)
      Put the records in the sink.
      void start​(java.util.Map<java.lang.String,​java.lang.String> props)
      Start the Task.
      void stop()
      Perform any cleanup to stop this task.
      java.lang.String version()  
      • Methods inherited from class org.apache.kafka.connect.sink.SinkTask

        close, initialize, onPartitionsAssigned, onPartitionsRevoked, open, preCommit
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MongoSinkTask

        public MongoSinkTask()
    • Method Detail

      • version

        public java.lang.String version()
      • start

        public void start​(java.util.Map<java.lang.String,​java.lang.String> props)
        Start the Task. This should handle any configuration parsing and one-time setup of the task.
        Specified by:
        start in interface org.apache.kafka.connect.connector.Task
        Specified by:
        start in class org.apache.kafka.connect.sink.SinkTask
        Parameters:
        props - initial configuration
      • put

        public void put​(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord> records)
        Put the records in the sink. Usually this should send the records to the sink asynchronously and immediately return. If this operation fails, the SinkTask may throw a RetriableException to indicate that the framework should attempt to retry the same call again. Other exceptions will cause the task to be stopped immediately. SinkTaskContext.timeout(long) can be used to set the maximum time before the batch will be retried.
        Specified by:
        put in class org.apache.kafka.connect.sink.SinkTask
        Parameters:
        records - the set of records to send
      • flush

        public void flush​(java.util.Map<org.apache.kafka.common.TopicPartition,​org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets)
        Flush all records that have been put(Collection) for the specified topic-partitions.
        Overrides:
        flush in class org.apache.kafka.connect.sink.SinkTask
        Parameters:
        currentOffsets - the current offset state as of the last call to put(Collection)}, provided for convenience but could also be determined by tracking all offsets included in the SinkRecords passed to put(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord>).
      • stop

        public void stop()
        Perform any cleanup to stop this task. In SinkTasks, this method is invoked only once outstanding calls to other methods have completed (e.g., put(Collection) has returned) and a final flush(Map) and offset commit has completed. Implementations of this method should only need to perform final cleanup operations, such as closing network connections to the sink system.
        Specified by:
        stop in interface org.apache.kafka.connect.connector.Task
        Specified by:
        stop in class org.apache.kafka.connect.sink.SinkTask