@Extensible @SynchronizationServerExtension(appliesToLocalContent=false, appliesToSynchronizedContent=true) public abstract class JDBCSyncDestination extends java.lang.Object implements UnboundIDExtension, Configurable, ExampleUsageProvider
fetchEntry(TransactionContext, Entry,
SyncOperation)
method will
always be called once prior to any of the other methods in this class.
In several places a TransactionContext
is provided, which allows
controlled access to the target database. By default, methods in this class
are always provided with a fresh connection (i.e. a new transaction), and the
Data Sync Server will always commit or rollback the transaction
automatically, depending on how the method returns. If a method call returns
successfully, then the transaction will be committed. If an exception is
thrown, then the transaction will be rolled back. In rare situations, it
might be necessary for an implementation to perform its own commit or
rollback of transactions by calling methods on TransactionContext
.
Several of these methods throw SQLException
, which should be used in
the case of any database access error. For other types of errors, runtime
exceptions may be used (IllegalStateException, NullPointerException, etc.).
The Data Sync Server will automatically retry operations that fail,
up to a configurable amount of attempts. The exception to this rule is if a
SQLException is thrown with a SQL state string beginning with "08"; this
indicates a connection error, and in this case the operation is retried
indefinitely. For these reasons implementers should refrain from handling
or wrapping any SQLException
and instead let it be handled by the
calling code.
dsconfig create-sync-destination \ --destination-name "{destination-name}" \ --type third-party-jdbc \ --set "server:{server-name}" \ --set "extension-class:{class-name}" \ --set "extension-argument:{name=value}"where "{destination-name}" is the name to use for the JDBC sync destination instance, "{server-name}" is the name of the JDBC external server that will be used as the sync destination, "{class-name}" is the fully-qualified name of the Java class written using this API, and "{name=value}" represents name-value pairs for any arguments to provide to the JDBC sync destination. If multiple arguments should be provided to the JDBC sync destination, then the "
--set extension-argument:{name=value}
" option should be
provided multiple times.Constructor and Description |
---|
JDBCSyncDestination()
Creates a new instance of this JDBC Sync Destination.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
createEntry(TransactionContext ctx,
com.unboundid.ldap.sdk.Entry entryToCreate,
SyncOperation operation)
Creates a full database "entry", corresponding to the LDAP
Entry that is passed in. |
void |
defineConfigArguments(com.unboundid.util.args.ArgumentParser parser)
Updates the provided argument parser to define any configuration arguments
which may be used by this extension.
|
abstract void |
deleteEntry(TransactionContext ctx,
com.unboundid.ldap.sdk.Entry fetchedDestEntry,
SyncOperation operation)
Delete a full "entry" from the database, corresponding to the LDAP
Entry that is passed in. |
abstract com.unboundid.ldap.sdk.Entry |
fetchEntry(TransactionContext ctx,
com.unboundid.ldap.sdk.Entry destEntryMappedFromSrc,
SyncOperation operation)
Return a full destination entry (in LDAP form) from the database,
corresponding to the source
Entry that is passed in. |
void |
finalizeJDBCSyncDestination(TransactionContext ctx)
This hook is called when a Sync Pipe shuts down, or when the resync
process shuts down.
|
java.util.Map<java.util.List<java.lang.String>,java.lang.String> |
getExamplesArgumentSets()
Retrieves a map containing examples of configurations that may be used for
this extension.
|
abstract java.lang.String[] |
getExtensionDescription()
Retrieves a human-readable description for this extension.
|
abstract java.lang.String |
getExtensionName()
Retrieves a human-readable name for this extension.
|
void |
initializeJDBCSyncDestination(TransactionContext ctx,
SyncServerContext serverContext,
JDBCSyncDestinationConfig config,
com.unboundid.util.args.ArgumentParser parser)
This hook is called when a Sync Pipe first starts up, or when the
resync process first starts up.
|
abstract void |
modifyEntry(TransactionContext ctx,
com.unboundid.ldap.sdk.Entry fetchedDestEntry,
java.util.List<com.unboundid.ldap.sdk.Modification> modsToApply,
SyncOperation operation)
Modify an "entry" in the database, corresponding to the LDAP
Entry that is passed in. |
public JDBCSyncDestination()
initializeJDBCSyncDestination(com.unboundid.directory.sdk.sync.types.TransactionContext, com.unboundid.directory.sdk.sync.types.SyncServerContext, com.unboundid.directory.sdk.sync.config.JDBCSyncDestinationConfig, com.unboundid.util.args.ArgumentParser)
method.public abstract java.lang.String getExtensionName()
getExtensionName
in interface UnboundIDExtension
public abstract java.lang.String[] getExtensionDescription()
getExtensionDescription
in interface UnboundIDExtension
null
or an empty array if no description should be available.public java.util.Map<java.util.List<java.lang.String>,java.lang.String> getExamplesArgumentSets()
getExamplesArgumentSets
in interface ExampleUsageProvider
null
or empty if there should
not be any example argument sets.public void defineConfigArguments(com.unboundid.util.args.ArgumentParser parser) throws com.unboundid.util.args.ArgumentException
defineConfigArguments
in interface Configurable
parser
- The argument parser to be updated with the configuration
arguments which may be used by this extension.com.unboundid.util.args.ArgumentException
- If a problem is encountered while updating the
provided argument parser.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void initializeJDBCSyncDestination(TransactionContext ctx, SyncServerContext serverContext, JDBCSyncDestinationConfig config, com.unboundid.util.args.ArgumentParser parser)
SyncServerContext
in a class
member so that it can be used elsewhere in the implementation.
A TransactionContext
is provided, which allows
controlled access to the target database. The context will contain a fresh
fresh connection (i.e. a new transaction), and the Data Sync Server
will always commit or rollback the transaction automatically, depending on
whether this method returns normally or throws an exception. See the class
level documentation for warnings and additional details.
The default implementation is empty.
ctx
- a TransactionContext which provides a valid JDBC connection to the
database.serverContext
- A handle to the server context for the server in
which this extension is running.config
- The general configuration for this sync destination.parser
- The argument parser which has been initialized from
the configuration for this JDBC sync destination.@ThreadSafety(level=METHOD_NOT_THREADSAFE) public void finalizeJDBCSyncDestination(TransactionContext ctx)
A TransactionContext
is provided, which allows
controlled access to the target database. The context will contain a fresh
fresh connection (i.e. a new transaction), and the Data Sync Server
will always commit or rollback the transaction automatically, depending on
whether this method returns normally or throws an exception. See the class
level documentation for warnings and additional details.
The default implementation is empty.
ctx
- a TransactionContext which provides a valid JDBC connection to the
database.@ThreadSafety(level=METHOD_THREADSAFE) public abstract com.unboundid.ldap.sdk.Entry fetchEntry(TransactionContext ctx, com.unboundid.ldap.sdk.Entry destEntryMappedFromSrc, SyncOperation operation) throws java.sql.SQLException
Entry
that is passed in.
This method should perform any queries necessary to gather the latest
values for all the attributes to be synchronized and return them in an
Entry.
Note that the if the source entry was renamed (see
SyncOperation.isModifyDN()
), the
destEntryMappedFromSrc
will have the new DN; the old DN can
be obtained by calling
SyncOperation.getDestinationEntryBeforeChange()
and getting the DN
from there. This method should return the entry in its existing form
(i.e. with the old DN, before it is changed).
A TransactionContext
is provided, which allows
controlled access to the target database. The context will contain a fresh
fresh connection (i.e. a new transaction), and the Data Sync Server
will always commit or rollback the transaction automatically, depending on
whether this method returns normally or throws an exception. See the class
level documentation for warnings and additional details.
This method must be thread safe, as it will be called repeatedly and concurrently by each of the Sync Pipe worker threads as they process entries.
ctx
- a TransactionContext which provides a valid JDBC connection to the
database.destEntryMappedFromSrc
- the LDAP entry which corresponds to the database "entry" to fetchoperation
- the sync operation for this changejava.sql.SQLException
- if there is an error fetching the entry@ThreadSafety(level=METHOD_THREADSAFE) public abstract void createEntry(TransactionContext ctx, com.unboundid.ldap.sdk.Entry entryToCreate, SyncOperation operation) throws java.sql.SQLException
Entry
that is passed in. This method should perform any inserts and
updates necessary to make sure the entry is fully created on the database.
A TransactionContext
is provided, which allows
controlled access to the target database. The context will contain a fresh
fresh connection (i.e. a new transaction), and the Data Sync Server
will always commit or rollback the transaction automatically, depending on
whether this method returns normally or throws an exception. See the class
level documentation for warnings and additional details.
This method must be thread safe, as it will be called repeatedly and concurrently by the Sync Pipe worker threads as they process CREATE operations.
ctx
- a TransactionContext which provides a valid JDBC connection to the
database.entryToCreate
- the LDAP entry which corresponds to the database "entry" to createoperation
- the sync operation for this changejava.sql.SQLException
- if there is an error creating the entry@ThreadSafety(level=METHOD_THREADSAFE) public abstract void modifyEntry(TransactionContext ctx, com.unboundid.ldap.sdk.Entry fetchedDestEntry, java.util.List<com.unboundid.ldap.sdk.Modification> modsToApply, SyncOperation operation) throws java.sql.SQLException
Entry
that is passed in. This method may perform multiple updates
(including inserting or deleting rows) in order to fully synchronize the
entire entry on the database.
Note that the if the source entry was renamed (see
SyncOperation.isModifyDN()
), the fetchedDestEntry
will
have the old DN; the new DN can be obtained by calling
SyncOperation.getDestinationEntryAfterChange()
and getting the DN
from there.
A TransactionContext
is provided, which allows
controlled access to the target database. The context will contain a fresh
fresh connection (i.e. a new transaction), and the Data Sync Server
will always commit or rollback the transaction automatically, depending on
whether this method returns normally or throws an exception. See the class
level documentation for warnings and additional details.
This method must be thread safe, as it will be called repeatedly and concurrently by the Sync Pipe worker threads as they process MODIFY operations.
ctx
- a TransactionContext which provides a valid JDBC connection to the
database.fetchedDestEntry
- the LDAP entry which corresponds to the database "entry" to modifymodsToApply
- a list of Modification objects which should be appliedoperation
- the sync operation for this changejava.sql.SQLException
- if there is an error modifying the entry@ThreadSafety(level=METHOD_THREADSAFE) public abstract void deleteEntry(TransactionContext ctx, com.unboundid.ldap.sdk.Entry fetchedDestEntry, SyncOperation operation) throws java.sql.SQLException
Entry
that is passed in. This method may perform multiple deletes
or updates if necessary to fully delete the entry from the database.
A TransactionContext
is provided, which allows
controlled access to the target database. The context will contain a fresh
fresh connection (i.e. a new transaction), and the Data Sync Server
will always commit or rollback the transaction automatically, depending on
whether this method returns normally or throws an exception. See the class
level documentation for warnings and additional details.
This method must be thread safe, as it will be called repeatedly and concurrently by the Sync Pipe worker threads as they process DELETE operations.
ctx
- a TransactionContext which provides a valid JDBC connection to the
database.fetchedDestEntry
- the LDAP entry which corresponds to the database "entry" to deleteoperation
- the sync operation for this changejava.sql.SQLException
- if there is an error deleting the entry