Record Class ConnectorContext
- Record Components:
connectorLogicalName- the logical name of the connector, typically used for identificationconnectorName- the actual name of the connector typetaskId- the unique identifier for the connector task, defaults to "0" if not specifiedconfig- the configuration object containing connector settings, may be null when created from headers
This record encapsulates connector identification details including the logical name, connector name, task ID, and configuration. It provides factory methods to create instances from different sources such as configuration objects and message headers.
- Author:
- Mario Fiore Vitale
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe field for theconfigrecord component.private final StringThe field for theconnectorLogicalNamerecord component.private final StringThe field for theconnectorNamerecord component.private static final Stringprivate static final org.slf4j.Loggerprivate final UUIDThe field for therunIdrecord component.private final StringThe field for thetaskIdrecord component.private final StringThe field for theversionrecord component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconfig()Returns the value of theconfigrecord component.Returns the value of theconnectorLogicalNamerecord component.Returns the value of theconnectorNamerecord component.final booleanIndicates whether some other object is "equal to" this one.static ConnectorContextCreates a ConnectorContext instance from a configuration object and connector type name.static ConnectorContextfrom(org.apache.kafka.connect.header.Headers headers) Creates a ConnectorContext instance from Kafka message headers.final inthashCode()Returns a hash code value for this object.runId()Returns the value of therunIdrecord component.taskId()Returns the value of thetaskIdrecord component.Generates a unique emitter key for this connector context.final StringtoString()Returns a string representation of this record class.version()Returns the value of theversionrecord component.
-
Field Details
-
connectorLogicalName
The field for theconnectorLogicalNamerecord component. -
connectorName
The field for theconnectorNamerecord component. -
taskId
The field for thetaskIdrecord component. -
version
The field for theversionrecord component. -
runId
The field for therunIdrecord component. -
config
The field for theconfigrecord component. -
LOGGER
private static final org.slf4j.Logger LOGGER -
KEY_FORMAT
- See Also:
-
-
Constructor Details
-
ConnectorContext
public ConnectorContext(String connectorLogicalName, String connectorName, String taskId, String version, UUID runId, Map<String, String> config) Creates an instance of aConnectorContextrecord class.- Parameters:
connectorLogicalName- the value for theconnectorLogicalNamerecord componentconnectorName- the value for theconnectorNamerecord componenttaskId- the value for thetaskIdrecord componentversion- the value for theversionrecord componentrunId- the value for therunIdrecord componentconfig- the value for theconfigrecord component
-
-
Method Details
-
from
public static ConnectorContext from(Map<String, String> configuration, String connectorTypeName, UUID runId) Creates a ConnectorContext instance from a configuration object and connector type name.This factory method extracts the topic prefix and task ID from the provided configuration. If no task ID is found in the configuration, it defaults to "0".
- Parameters:
configuration- the configuration object containing connector settingsconnectorTypeName- the name of the connector typerunId-- Returns:
- a new ConnectorContext instance populated with configuration values
-
from
Creates a ConnectorContext instance from Kafka message headers.This factory method extracts Debezium-specific context headers to populate the connector context. It filters headers that start with the Debezium context header prefix and maps them for easy access. Note that the configuration parameter will be null when using this method.
Warning: This method logs a warning indicating that the OpenLineage SMT cannot retrieve required Debezium headers.
- Parameters:
headers- the Kafka message headers containing connector context information- Returns:
- a new ConnectorContext instance with data extracted from headers, with config set to null
-
toEmitterKey
Generates a unique emitter key for this connector context.The emitter key is formatted as "{connectorLogicalName}:{taskId}" and can be used to uniquely identify this connector instance for emitting events.
- Returns:
- a formatted string combining the connector logical name and task ID
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
connectorLogicalName
Returns the value of theconnectorLogicalNamerecord component.- Returns:
- the value of the
connectorLogicalNamerecord component
-
connectorName
Returns the value of theconnectorNamerecord component.- Returns:
- the value of the
connectorNamerecord component
-
taskId
Returns the value of thetaskIdrecord component.- Returns:
- the value of the
taskIdrecord component
-
version
Returns the value of theversionrecord component.- Returns:
- the value of the
versionrecord component
-
runId
Returns the value of therunIdrecord component.- Returns:
- the value of the
runIdrecord component
-
config
Returns the value of theconfigrecord component.- Returns:
- the value of the
configrecord component
-