Supporting catalog targets¶
A catalog target describes a specific piece of third party technology that an integration connector is exchanging metadata with.
Why catalog targets change the way connectors are built¶
Originally, the technology that an integration connector worked with was identified by the endpoint in the connector's own connection. A connection describes one endpoint, so a connector instance could work with exactly one database, one file directory, or one Kafka broker. If you had three databases to catalog, you configured and deployed three instances of the connector, each with its own connection, its own credentials and its own entry in the integration daemon's configuration.
With catalog targets, the connector's connection only needs to identify the connector implementation. The technology to work with is attached to the connector's IntegrationConnector metadata element using a CatalogTarget relationship that points at the asset describing the technology.
The integration connector is linked to the asset for the database it is to catalog. The asset's own connection - including any embedded secrets store connector - is used to create the connector that calls the database.
This has a big effect on operations:
- The connector is deployed once - typically by loading a content pack into the metadata access store at start up - and it then runs in an integration group.
- When someone wants a new database catalogued, they attach the database's asset to the connector with a CatalogTarget relationship. No configuration change, no restart.
- Connection details, including credentials, are defined once on the asset and reused by every connector, survey action service and governance action service that works with that resource.
- Each catalog target can carry its own configuration properties, templates, metadata collection name, connection name, permitted synchronization and delete method, so one running connector can treat each of its targets differently.
It also changes the way the connector is built. The per-resource logic that used to live in the connector's refresh() method moves into a catalog target processor.
The shape of a catalog target connector¶
flowchart TD
subgraph one["Integration daemon thread"]
A["`**MyIntegrationConnector**
_extends DynamicIntegrationConnectorBase_
start(), refresh(), disconnect()`"]
end
A -->|"getNewRequestedCatalogTargetSkeleton()"| B["`**MyCatalogTargetProcessor**
_extends CatalogTargetProcessorBase_
catalog target: *sales database*`"]
A --> C["`**MyCatalogTargetProcessor**
catalog target: *finance database*`"]
A --> D["`**MyCatalogTargetProcessor**
catalog target: *HR database*`"]
There are two classes to write (plus the connector provider):
| Class | Extends | Responsibility |
|---|---|---|
| The integration connector | DynamicIntegrationConnectorBase |
Extract any connector-wide configuration in start(), and act as a factory that creates a processor for each catalog target. |
| The catalog target processor | CatalogTargetProcessorBase |
All the work for one piece of third party technology: validate the target, call the technology, and maintain the open metadata for it. |
The base class does the rest. On each refresh() it:
- Retrieves the current list of CatalogTarget relationships attached to the connector's element. Only the header and properties of each target element are retrieved at this point - the rest of the element's graph is read on demand by the processor (see below).
- For each new one, creates a digital resource connector for the target asset (if the target is an asset with a connection), calls your
getNewRequestedCatalogTargetSkeleton()method to create the processor, overlays the configuration properties, defaults the permitted synchronization to the connector's value, starts the resource connector and callsstart()on the processor. - For each one whose relationship has changed (its version is different from the last refresh), disconnects the old resource connector and creates a new processor from the new values.
- Calls
refresh()on every processor, catching and logging exceptions so that one failing target does not stop the others. Any target element read on demand during the previous refresh is discarded first, so each refresh works from current metadata. - Registers an open metadata event listener (once the first refresh is complete) if the connector implements
OpenMetadataEventListenerand its permitted synchronization isTO_THIRD_PARTYorBOTH_DIRECTIONS, and passes each event to any processor that implementsOpenMetadataEventListener.
These steps are implemented by the RequestedCatalogTargetsManager , available to your connector as the catalogTargetsManager variable.
Catalog targets in a cohort of integration daemons
The IntegrationConnector element is usually shipped in a content pack, so every integration daemon running the same connector asks for the catalog targets of the same element. If their metadata access stores are in the same cohort, each daemon would see every other daemon's catalog targets too. A connector can call catalogTargetsManager.setLocalMetadataCollectionId() with the metadata collection id of its own metadata access store; the manager then only processes the CatalogTarget relationships whose home metadata collection matches, and logs the targets it leaves to other daemons. Until the identifier is supplied, nothing is filtered. The OMAG Server Platform Catalog Connector is an example.
Writing the integration connector¶
The connector extends DynamicIntegrationConnectorBase and implements a single abstract method: getNewRequestedCatalogTargetSkeleton(). Here is the complete implementation of the Kafka Topic Integration Connector :
public class KafkaTopicIntegrationConnector extends DynamicIntegrationConnectorBase
{
/**
* Create a new catalog target processor (typically inherits from CatalogTargetProcessorBase).
*
* @param retrievedCatalogTarget details of the open metadata elements describing the catalog target
* @param catalogTargetContext specialized context for this catalog target
* @param connectorToTarget connector to access the target resource
* @return new processor based on the catalog target information
*/
@Override
public RequestedCatalogTarget getNewRequestedCatalogTargetSkeleton(CatalogTarget retrievedCatalogTarget,
CatalogTargetContext catalogTargetContext,
Connector connectorToTarget)
{
return new KafkaTopicCatalogTargetProcessor(retrievedCatalogTarget,
catalogTargetContext,
connectorToTarget,
connectorName,
auditLog);
}
}
Notice that there is no start(), refresh() or disconnect() method. They are only needed if the connector has work of its own to do. For example, the PostgreSQL Server Integration Connector overrides start() to read the default database include/exclude lists from its own connection:
@Override
public void start() throws ConnectorCheckedException, UserNotAuthorizedException
{
super.start();
defaultExcludeDatabases = super.getArrayConfigurationProperty(PostgresConfigurationProperty.EXCLUDE_DATABASE_LIST.getName(),
connectionBean.getConfigurationProperties(),
Collections.singletonList("postgres"));
:
}
Always call the superclass method
super.start() creates the catalog targets manager, super.refresh() drives the catalog target processors, and super.disconnect() releases their resource connectors. If you override any of these methods without calling the superclass version, your catalog targets are never processed.
Writing the catalog target processor¶
The processor extends CatalogTargetProcessorBase , which in turn extends RequestedCatalogTarget and CatalogTarget. This means the properties of the catalog target are available directly on this:
| Method | Description |
|---|---|
getCatalogTargetName() |
The name given to this target by the person who attached it. Use it in audit log messages so operators can tell the targets apart. |
getCatalogTargetElementHeader() |
The header (GUID, type, classifications, versions) of the element at the other end of the CatalogTarget relationship. It was retrieved with the catalog target, so it costs nothing - use it when the identity of the element is all you need. |
getCatalogTargetElement() |
The OpenMetadataRootElement for the target element read in full, with its related elements to the default graph depth. It is read from open metadata the first time it is requested in a refresh and then cached for the rest of that refresh. |
getCatalogTargetElement(GetOptions) |
The target element read with the supplied options - for example, a graph query depth of 1 and only the SupportedSoftwareCapability relationships. For a target with a large schema this is much cheaper than a full read. |
getConnectorToTarget() |
The digital resource connector created from the target asset's connection, already started. It is null if the target is not an asset, or has no connection. |
getConfigurationProperties() |
The connector's own configuration properties, overlaid with the configuration properties from the CatalogTarget relationship. The relationship's values win. |
getTemplates() |
Map of template name to template GUID for templated cataloguing. |
getPermittedSynchronization() |
The direction metadata is allowed to flow for this target. Defaults to the connector's setting. |
getMetadataCollectionQualifiedName() |
The qualified name of the metadata collection that owns the metadata created for this target, if it overrides the connector's value. |
getConnectionName() |
The qualified name of a connection to use for the resource, if it is not the connection of the target asset. |
getDeleteMethod() |
The delete method policy for this target. |
getRelationshipGUID() |
Unique identifier of the CatalogTarget relationship itself - useful if the connector needs to update it. |
integrationContext |
The CatalogTargetContext for this target. It is already set up with the correct metadata source and permitted synchronization. |
The start method¶
start() is called once, when the catalog target is first seen. This is where to validate the target and extract the values that do not change between refreshes. From the Kafka Topic Catalog Target Processor :
@Override
public void start() throws UserNotAuthorizedException, ConnectorCheckedException
{
super.start();
final String methodName = "start";
integrationContext.validateIsActive(methodName);
if ((super.connectorToTarget != null) &&
(super.connectorToTarget.getConnection() != null) &&
(super.connectorToTarget.getConnection().getEndpoint() != null) &&
(super.connectorToTarget.getConnection().getEndpoint().getNetworkAddress() != null))
{
hostIdentifier = super.getHostIdentifier(super.connectorToTarget.getConnection().getEndpoint().getNetworkAddress());
portNumber = super.getPortNumber(super.connectorToTarget.getConnection().getEndpoint().getNetworkAddress());
templateGUID = this.getTemplateGUID();
}
else
{
super.throwMissingConnectionInfo(OpenMetadataProperty.NETWORK_ADDRESS.name, methodName);
}
/*
* Read the target element with just its supported software capabilities attached.
*/
OpenMetadataRootElement catalogTargetElement = this.getCatalogTargetElementWithCapabilities();
if (propertyHelper.isTypeOf(catalogTargetElement.getElementHeader(), OpenMetadataType.SOFTWARE_SERVER.typeName))
{
eventBrokerGUID = this.getEventBrokerGUID(catalogTargetElement);
}
else if (propertyHelper.isTypeOf(catalogTargetElement.getElementHeader(), OpenMetadataType.EVENT_BROKER.typeName))
{
eventBrokerGUID = catalogTargetElement.getElementHeader().getGUID();
}
else
{
super.throwWrongTypeOfCatalogTarget(Arrays.asList(OpenMetadataType.SOFTWARE_SERVER.typeName,
OpenMetadataType.EVENT_BROKER.typeName).toString(),
methodName);
}
:
}
The private getCatalogTargetElementWithCapabilities() method builds a GetOptions from integrationContext.getClassificationExplorerClient().getGetOptions(), sets the graph query depth to 1 and restricts the relationships to SupportedSoftwareCapability, then calls getCatalogTargetElement(getOptions).
CatalogTargetProcessorBase supplies a family of helper methods for this validation work, so that all connectors report the same problems in the same way:
throwWrongTypeOfCatalogTarget()- the element on the end of the relationship is not a type this connector can process.throwWrongTypeOfResourceConnector()- the asset's connection created a connector of an unexpected class.throwMissingConnectionInfo()- the connection is missing a value the connector needs, such as the network address.throwMissingPropertyValue()andthrowBadBeanClass()- the target element does not have the properties the connector expects.
It also supplies methods to extract typed values from the combined configuration properties - getStringConfigurationProperty(), getBooleanConfigurationProperty(), getIntConfigurationProperty(), getLongConfigurationProperty(), getDateConfigurationProperty(), getArrayConfigurationProperty() and getSuppliedPlaceholderProperties() - along with getHostIdentifier() and getPortNumber() for splitting a network address.
The refresh method¶
refresh() does the metadata exchange for this one target. Because the base class calls it inside a try/catch, an exception thrown here takes only this target out of action for this pass, not the whole connector. This example is from the PostgreSQL Server Catalog Target Processor :
@Override
public void refresh() throws ConnectorCheckedException
{
final String methodName = "refresh";
if (propertyHelper.isTypeOf(this.getCatalogTargetElementHeader(),
PostgresDeployedImplementationType.POSTGRESQL_SERVER.getAssociatedTypeName()))
{
JDBCResourceConnector assetConnector = null;
try
{
/*
* Only the server's properties and its supported software capabilities are used.
*/
GetOptions serverGetOptions = integrationContext.getClassificationExplorerClient().getGetOptions();
serverGetOptions.setGraphQueryDepth(1);
serverGetOptions.setIncludeOnlyRelationships(List.of(OpenMetadataType.SUPPORTED_SOFTWARE_CAPABILITY_RELATIONSHIP.typeName));
String databaseServerGUID = this.getCatalogTargetElementHeader().getGUID();
OpenMetadataRootElement databaseManager = this.getDatabaseManager(databaseServerGUID, this.getCatalogTargetElement(serverGetOptions));
Connector connector = integrationContext.getConnectedAssetContext().getConnectorForAsset(databaseServerGUID, auditLog);
assetConnector = (JDBCResourceConnector)connector;
assetConnector.start();
catalogDatabases(databaseServerGUID,
databaseManager,
this.getTemplates(),
this.getConfigurationProperties(),
assetConnector);
}
catch (Exception exception)
{
logExceptionRecord(methodName,
PostgresAuditCode.UNEXPECTED_EXCEPTION.getMessageDefinition(connectorName,
exception.getClass().getName(),
methodName,
exception.getMessage()),
exception);
}
finally
{
this.releaseAssetConnector(assetConnector, methodName);
}
}
else
{
super.throwWrongTypeOfCatalogTarget(PostgresDeployedImplementationType.POSTGRESQL_SERVER.getAssociatedTypeName(),
methodName);
}
}
Release any connector you create yourself
The resource connector returned by getConnectorToTarget() is managed by the base class - do not disconnect it. However, if refresh() creates its own connector (as the PostgreSQL example does, to pick up a fresh database session each pass) it must release it on both the success and the failure path. Otherwise each failed refresh leaks the connector and the connections it holds.
The disconnect method¶
disconnect() is called when the CatalogTarget relationship is removed, or when the connector shuts down. Free up any resources that this processor holds. The resource connector supplied by the base class is disconnected for you.
Processing events for a catalog target¶
If the catalog target processor implements OpenMetadataEventListener , it is passed each event from the open metadata ecosystem.
For this to happen, the integration connector must also implement OpenMetadataEventListener - this is the signal that the connector is interested in open metadata events. DynamicIntegrationConnectorBase provides the processEvent() implementation that fans the event out to the processors, and registers the listener at the end of the first refresh(). The delay is deliberate: it avoids a flood of events caused by the connector's own initial synchronization. The listener is only registered if the permitted synchronization allows metadata to flow to the third party technology.
public class MyIntegrationConnector extends DynamicIntegrationConnectorBase implements OpenMetadataEventListener
{
// processEvent() is inherited from DynamicIntegrationConnectorBase
}
public class MyCatalogTargetProcessor extends CatalogTargetProcessorBase implements OpenMetadataEventListener
{
@Override
public void processEvent(OpenMetadataOutTopicEvent event)
{
// called for each open metadata event, for this catalog target
}
}
The base class only passes events on when a refresh is not running, so your processEvent() method does not have to test integrationContext.noRefreshInProgress() itself.
Events from the third party technology are handled differently: register the listener in the processor's constructor or start() method. The OpenLineage Event Receiver Catalog Target Processor has an Open Metadata Topic Connector as its target resource connector, and registers a listener with it:
public OpenLineageEventReceiverCatalogTargetProcessor(CatalogTarget template,
CatalogTargetContext catalogTargetContext,
Connector connectorToTarget,
String connectorName,
AuditLog auditLog,
OpenMetadataTopicListener listener) throws ConnectorCheckedException,
UserNotAuthorizedException
{
super(template, catalogTargetContext, connectorToTarget, connectorName, auditLog);
if (super.getConnectorToTarget() instanceof OpenMetadataTopicConnector topicConnector)
{
this.registerTopicConnector(topicConnector, listener);
}
}
The registerTopicConnector() method calls topicConnector.registerListener(listener), logs the topic's network address, and starts the topic connector if it is not already active. The listener is the integration connector itself, which implements OpenMetadataTopicListener. Its refresh() method does nothing, because all of its work is event-driven.
Being notified when the catalog targets change¶
An integration connector that needs to know when its catalog targets are added, changed or removed can implement CatalogTargetChangeListener and register it with the catalog targets manager:
catalogTargetsManager.registerCatalogTargetChangeListener(this);
The interface has newCatalogTarget(), updatedCatalogTarget() and removedCatalogTarget() methods. Most connectors do not need this, since the processor's own start() and disconnect() methods cover the same events.
Declaring the supported catalog target types¶
The connector provider declares which types of element this connector accepts as a catalog target. This information is published in open metadata so that the tools people use to attach catalog targets can offer the right choices, and so that they can be validated. See defining the catalog target types.
Naming the metadata source¶
Each catalog target can name the metadata collection for the metadata created from it - the metadataCollectionQualifiedName property on the CatalogTarget relationship. If it is not set, the value from the connector's RegisteredIntegrationConnector relationship is used. IntegrationContext.getCatalogTargetContext() looks up (or creates) the MetadataCollection asset and builds the processor's CatalogTargetContext with it, so metadata from the sales database and metadata from the finance database can be held in separate metadata collections, even though a single connector instance created both. The external source metadata provenance that results prevents other tools from changing the metadata that this connector maintains.
CatalogTargetProcessorBase also provides setUpMetadataSource() and setUpSoftwareCapability(), used by connectors that catalog a server. setUpMetadataSource() looks for an InventoryCatalog software capability on the target server, creating it if necessary along with a MetadataCollection asset, and stores the result in the metadataCollectionGUID and metadataCollectionName variables. setUpSoftwareCapability() does the same for any named software capability type and returns its GUID.
Migrating an existing connector¶
To convert a connector that predates catalog targets:
- Change the superclass from
IntegrationConnectorBase(or one of the oldXXXIntegratorConnectorclasses) toDynamicIntegrationConnectorBase. - Create a new class extending
CatalogTargetProcessorBaseand move the body ofrefresh()into it, along with any instance variables it uses. - Move the parts of
start()that relate to a specific resource into the processor'sstart()method. Anything that reads the connector's own configuration stays behind. - Implement
getNewRequestedCatalogTargetSkeleton()on the connector to return an instance of the new processor. - Replace
getContext()with theintegrationContextvariable, andconnectionPropertieswithconnectionBean. Inside the processor,integrationContextis the target'sCatalogTargetContext. - Replace direct use of the endpoint from the connector's connection with
getConnectorToTarget(), or with the network address from the target asset's connection. - Declare the supported catalog target types in the connector provider.
Code examples
- Kafka Topic Integration Connector - the smallest complete example.
- PostgreSQL Server Integration Connector - configuration properties, templates and a resource connector.
- Unity Catalog Server Sync Connector - two-way synchronization using the integration iterators.
- OpenLineage Event Receiver Integration Connector - event-driven catalog targets.
Further information
- Catalog target concept page.
- Integration group - how connectors and their catalog targets are described in open metadata.
- Self-registering integration connectors - connectors that find and attach their own catalog targets.
Raise an issue or comment below