Package io.debezium.heartbeat
Class HeartbeatImpl
- java.lang.Object
-
- io.debezium.heartbeat.HeartbeatImpl
-
- All Implemented Interfaces:
Heartbeat
- Direct Known Subclasses:
DatabaseHeartbeatImpl
class HeartbeatImpl extends Object implements Heartbeat
Default implementation of Heartbeat
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.debezium.heartbeat.Heartbeat
Heartbeat.OffsetProducer
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intDEFAULT_HEARTBEAT_INTERVALDefault length of interval in which connector generates periodically heartbeat messages.(package private) static StringDEFAULT_HEARTBEAT_TOPICS_PREFIXDefault prefix for names of heartbeat topicsprivate DurationheartbeatIntervalprivate Threads.TimerheartbeatTimeoutprivate Stringkeyprivate static org.apache.kafka.connect.data.SchemaKEY_SCHEMAprivate static org.slf4j.LoggerLOGGERprivate static SchemaNameAdjusterschemaNameAdjusterprivate static StringSERVER_NAME_KEYprivate StringtopicNameprivate static org.apache.kafka.connect.data.SchemaVALUE_SCHEMA-
Fields inherited from interface io.debezium.heartbeat.Heartbeat
DEFAULT_NOOP_HEARTBEAT, HEARTBEAT_INTERVAL, HEARTBEAT_INTERVAL_PROPERTY_NAME, HEARTBEAT_TOPICS_PREFIX
-
-
Constructor Summary
Constructors Constructor Description HeartbeatImpl(Duration heartbeatInterval, String topicName, String key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidforcedBeat(Map<String,?> partition, Map<String,?> offset, BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> consumer)Generates a heartbeat record unconditionalyvoidheartbeat(Map<String,?> partition, Heartbeat.OffsetProducer offsetProducer, BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> consumer)Generates a heartbeat record if defined time has elapsedvoidheartbeat(Map<String,?> partition, Map<String,?> offset, BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> consumer)Generates a heartbeat record if defined time has elapsedprivate org.apache.kafka.connect.source.SourceRecordheartbeatRecord(Map<String,?> sourcePartition, Map<String,?> sourceOffset)Produce an empty record to the heartbeat topic.booleanisEnabled()Whether heartbeats are enabled or not.private org.apache.kafka.connect.data.StructmessageValue()Produce a value struct containing the timestampprivate Threads.TimerresetHeartbeat()private org.apache.kafka.connect.data.StructserverNameKey(String serverName)Produce a key struct based on the server name and KEY_SCHEMA
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
schemaNameAdjuster
private static final SchemaNameAdjuster schemaNameAdjuster
-
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
-
SERVER_NAME_KEY
private static final String SERVER_NAME_KEY
- 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
-
-
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:HeartbeatGenerates a heartbeat record if defined time has elapsed- Specified by:
heartbeatin interfaceHeartbeat- Parameters:
partition- partition for the heartbeat recordoffset- offset for the heartbeat recordconsumer- - 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:HeartbeatGenerates a heartbeat record if defined time has elapsed- Specified by:
heartbeatin interfaceHeartbeat- Parameters:
partition- partition for the heartbeat recordoffsetProducer- lazily calculated offset for the heartbeat recordconsumer- - 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:HeartbeatGenerates a heartbeat record unconditionaly- Specified by:
forcedBeatin interfaceHeartbeat- Parameters:
partition- partition for the heartbeat recordoffset- offset for the heartbeat recordconsumer- - a code to place record among others to be sent into Connect- Throws:
InterruptedException
-
isEnabled
public boolean isEnabled()
Description copied from interface:HeartbeatWhether heartbeats are enabled or not.
-
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.
-
resetHeartbeat
private Threads.Timer resetHeartbeat()
-
-