@Beta public interface DataLink
It contains metadata needed to connect, and might or might not maintain
a physical connection or connections, depending on the connector. The connection
might be an instance of Connection
, or of a driver or client to a
3rd party system etc.
Every connection obtained from a DataLink must be closed. Otherwise, the data link cannot be closed and the connection will leak.
DataLink is supposed to be used in Jet jobs or SQL mappings where the same connection metadata, or even the same connection is to be reused.
DataLink is closely related to Jet connectors (sources and sinks) and
to SqlConnector
s. While the DataLink handles initialization,
maintenance and closing of connections to the external system, the
connections read and write actual data from/into them.
Instances of DataLinks should be obtained by calling
DataLinkService.getAndRetainDataLink(java.lang.String, java.lang.Class<T>)
method.
Conceptually, there are 3 types of sharing of the underlying instance between multiple (concurrent) Jet jobs or SQL queries:
When a DataLink is closed, connections obtained from should continue to be functional, until all connections are returned. Replacing of a DataLink is handled as remove+create.
Implementations of DataLink must provide a constructor with a single argument
of type DataLinkConfig
.
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called by the member when shutting down.
|
DataLinkConfig |
getConfig()
Returns the configuration of this DataLink.
|
String |
getName()
Returns the name of this DataLink as specified in the
DataLinkConfig or the CREATE DATA LINK
command. |
Collection<DataLinkResource> |
listResources()
Returns list of
DataLinkResource s accessible via this DataLink. |
default Map<String,String> |
options()
Returns the properties / options this DataLink was created with.
|
void |
release()
Release a retained data link.
|
void |
retain()
Prevents the data link from being closed.
|
@Nonnull String getName()
DataLinkConfig
or the CREATE DATA LINK
command.@Nonnull Collection<DataLinkResource> listResources()
DataLinkResource
s accessible via this DataLink.
It is not strictly required that the data link lists all resources; a resource can be used even if it is not listed. For example, the list of resources in Oracle database might not include tables available through a database link. In fact, it might list no resources at all, perhaps if the security in the target system prevents reading of such a list.
The returned list contains up-to-date list of resources. Any changes (added or removed resources) must be reflected in subsequent calls to this method.
@Nonnull DataLinkConfig getConfig()
@Nonnull default Map<String,String> options()
void retain()
Note that the DataLink also isn't closed until all shared connections obtained from it are returned. This feature, together with the lock allows the processor to avoid concurrent close while it is using the connection.
IllegalStateException
- fi the data link is already closedvoid release()
retain()
call, otherwise the data link will leak.void destroy()
Copyright © 2023 Hazelcast, Inc.. All rights reserved.