Class HeartbeatImpl

    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • DEFAULT_HEARTBEAT_INTERVAL

        static final int DEFAULT_HEARTBEAT_INTERVAL
        Default length of interval in which connector generates periodically heartbeat messages. A size of 0 disables heartbeat.
        See Also:
        Constant Field Values
      • DEFAULT_HEARTBEAT_TOPICS_PREFIX

        static final String DEFAULT_HEARTBEAT_TOPICS_PREFIX
        Default prefix for names of heartbeat topics
        See Also:
        Constant Field Values
      • KEY_SCHEMA

        private static final org.apache.kafka.connect.data.Schema KEY_SCHEMA
      • VALUE_SCHEMA

        private static final org.apache.kafka.connect.data.Schema VALUE_SCHEMA
      • topicName

        private final String topicName
      • heartbeatInterval

        private final Duration heartbeatInterval
      • key

        private final String key
      • heartbeatTimeout

        private volatile Threads.Timer heartbeatTimeout
    • Constructor Detail

    • Method Detail

      • heartbeat

        public void heartbeat​(Map<String,​?> partition,
                              Map<String,​?> offset,
                              BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> consumer)
                       throws InterruptedException
        Description copied from interface: Heartbeat
        Generates a heartbeat record if defined time has elapsed
        Specified by:
        heartbeat in interface Heartbeat
        Parameters:
        partition - partition for the heartbeat record
        offset - offset for the heartbeat record
        consumer - - a code to place record among others to be sent into Connect
        Throws:
        InterruptedException
      • heartbeat

        public void heartbeat​(Map<String,​?> partition,
                              Heartbeat.OffsetProducer offsetProducer,
                              BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> consumer)
                       throws InterruptedException
        Description copied from interface: Heartbeat
        Generates a heartbeat record if defined time has elapsed
        Specified by:
        heartbeat in interface Heartbeat
        Parameters:
        partition - partition for the heartbeat record
        offsetProducer - lazily calculated offset for the heartbeat record
        consumer - - a code to place record among others to be sent into Connect
        Throws:
        InterruptedException
      • forcedBeat

        public void forcedBeat​(Map<String,​?> partition,
                               Map<String,​?> offset,
                               BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> consumer)
                        throws InterruptedException
        Description copied from interface: Heartbeat
        Generates a heartbeat record unconditionaly
        Specified by:
        forcedBeat in interface Heartbeat
        Parameters:
        partition - partition for the heartbeat record
        offset - offset for the heartbeat record
        consumer - - a code to place record among others to be sent into Connect
        Throws:
        InterruptedException
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: Heartbeat
        Whether heartbeats are enabled or not.
        Specified by:
        isEnabled in interface Heartbeat
      • serverNameKey

        private org.apache.kafka.connect.data.Struct serverNameKey​(String serverName)
        Produce a key struct based on the server name and KEY_SCHEMA
      • messageValue

        private org.apache.kafka.connect.data.Struct messageValue()
        Produce a value struct containing the timestamp
      • heartbeatRecord

        private org.apache.kafka.connect.source.SourceRecord heartbeatRecord​(Map<String,​?> sourcePartition,
                                                                             Map<String,​?> sourceOffset)
        Produce an empty record to the heartbeat topic.