@Extensible @SynchronizationServerExtension(appliesToLocalContent=false, appliesToSynchronizedContent=true) public abstract class ChangeDetector extends java.lang.Object implements UnboundIDExtension, Reconfigurable<ChangeDetectorConfig>, ExampleUsageProvider
dsconfig create-change-detector \ --detector-name "{detector-name}" \ --type third-party \ --set "extension-class:{class-name}" \ --set "extension-argument:{name=vale}"where "{plugin-name}" is the name to use for the Change Detector instance, "{class-name}" is the fully-qualified name of the Java class that extends
com.unboundid.directory.sdk.sync.api.ChangeDetector
,
and "{name=value}" represents name-value pairs for any arguments to
provide to the Change Detector. If multiple arguments should be provided
to the Change Detector, then the
"--set extension-argument:{name=value}
"
option should be provided multiple times.Constructor and Description |
---|
ChangeDetector()
Creates a new instance of this LDAP Change Detector.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
acknowledgeCompletedOps(java.util.LinkedList<SyncOperation> completedOps)
Provides a way for the Data Sync Server to acknowledge back to the
extension which sync operations it has processed.
|
ResultCode |
applyConfiguration(ChangeDetectorConfig config,
ArgumentParser parser,
java.util.List<java.lang.String> adminActionsRequired,
java.util.List<java.lang.String> messages)
Attempts to apply the configuration from the provided argument parser to
this extension.
|
void |
defineConfigArguments(ArgumentParser parser)
Updates the provided argument parser to define any configuration arguments
which may be used by this extension.
|
void |
finalizeChangeDetector()
This hook is called when a Sync Pipe shuts down or when the set-startpoint
subcommand (from the realtime-sync command line tool) is finished.
|
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.
|
abstract java.util.List<ChangeRecord> |
getNextBatchOfChanges(int maxChanges,
java.util.concurrent.atomic.AtomicLong numStillPending)
Return the next batch of change records from the source.
|
abstract java.io.Serializable |
getStartpoint()
Gets the current value of the startpoint for change detection.
|
void |
initializeChangeDetector(SyncServerContext serverContext,
SyncSourceContext syncSourceContext,
ArgumentParser parser)
This hook is called when a Sync Pipe first starts up or when the
set-startpoint subcommand is called from the realtime-sync command
line tool.
|
boolean |
isConfigurationAcceptable(ChangeDetectorConfig config,
ArgumentParser parser,
java.util.List<java.lang.String> unacceptableReasons)
Indicates whether the configuration represented by the provided argument
parser is acceptable for use by this extension.
|
abstract void |
setStartpoint(SetStartpointOptions options)
This method should effectively set the starting point for synchronization
to the place specified by the
options parameter. |
public ChangeDetector()
initializeChangeDetector
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(ArgumentParser parser) throws ArgumentException
defineConfigArguments
in interface Configurable
parser
- The argument parser to be updated with the configuration
arguments which may be used by this extension.ArgumentException
- If a problem is encountered while updating the
provided argument parser.public void initializeChangeDetector(SyncServerContext serverContext, SyncSourceContext syncSourceContext, ArgumentParser parser)
SyncServerContext
and SyncSourceContext
in a class member so that it can be used
elsewhere in the implementation.
The default implementation is empty.
serverContext
- A handle to the server context for the server in
which this extension is running.syncSourceContext
- An interface for interacting with the Sync
Source that owns this Change Detector or
null
if the Change Detector is only
being initialized to validate its configuration.parser
- The argument parser which has been initialized
from the configuration for this sync source.public void finalizeChangeDetector()
The default implementation is empty.
public boolean isConfigurationAcceptable(ChangeDetectorConfig config, ArgumentParser parser, java.util.List<java.lang.String> unacceptableReasons)
isConfigurationAcceptable
in interface Reconfigurable<ChangeDetectorConfig>
config
- The general configuration for this extension.parser
- The argument parser that has been used to
parse the proposed configuration for this
extension.unacceptableReasons
- A list to which messages may be added to
provide additional information about why the
provided configuration is not acceptable.true
if the configuration in the provided argument parser
appears to be acceptable, or false
if not.public ResultCode applyConfiguration(ChangeDetectorConfig config, ArgumentParser parser, java.util.List<java.lang.String> adminActionsRequired, java.util.List<java.lang.String> messages)
applyConfiguration
in interface Reconfigurable<ChangeDetectorConfig>
config
- The general configuration for this extension.parser
- The argument parser that has been used to
parse the new configuration for this
extension.adminActionsRequired
- A list to which messages may be added to
provide additional information about any
additional administrative actions that may
be required to apply some of the
configuration changes.messages
- A list to which messages may be added to
provide additional information about the
processing performed by this method.SUCCESS
should be
used to indicate that all processing completed successfully. Any
other result will indicate that a problem occurred during
processing.public abstract void setStartpoint(SetStartpointOptions options) throws EndpointException
options
parameter. This should
cause all changes previous to the specified start point to be disregarded
and only changes after that point to be returned by
getNextBatchOfChanges(int, AtomicLong)
.
There are several different startpoint types (see
SetStartpointOptions
), and this implementation is not required to
support them all. If the specified startpoint type is unsupported, this
method should throw an UnsupportedOperationException
.
IMPORTANT: The RESUME_AT_SERIALIZABLE
startpoint type
must be supported by your implementation, because this is used when a Sync
Pipe first starts up. The Serializable
in this case is the same
type that is returned by getStartpoint()
; the Sync Server persists
it and passes it back in on a restart.
This method can be called from two different contexts:
getNextBatchOfChanges(int, AtomicLong)
)options
- an object which indicates where exactly to start
synchronizing (e.g. the end of the changelog, specific
change number, a certain time ago, etc)EndpointException
- if there is any error while setting the
start pointpublic abstract java.io.Serializable getStartpoint()
acknowledgeCompletedOps(LinkedList)
.
This method is called periodically and the return value is saved in the
persistent state for the Sync Pipe that uses this extension as its Sync
Source.
IMPORTANT: The internal value for the startpoint should only be
updated after a sync operation is acknowledged back to this extension (via
acknowledgeCompletedOps(LinkedList)
).
Otherwise it will be possible for changes to be missed when the
Data Sync Server is restarted or a connection error occurs.
setStartpoint(SetStartpointOptions)
when the sync pipe starts up.public abstract java.util.List<ChangeRecord> getNextBatchOfChanges(int maxChanges, java.util.concurrent.atomic.AtomicLong numStillPending) throws EndpointException
On the first invocation, this should return changes starting from the
startpoint that was set by
setStartpoint(SetStartpointOptions)
. This method is also
responsible for updating the internal state such that subsequent
invocations do not return duplicate changes.
The resulting list should be limited by maxChanges
. The
numStillPending
reference should be set to the estimated
number of changes that haven't yet been retrieved from the source endpoint
when this method returns, or zero if all the current changes have been
retrieved.
IMPORTANT: While this method needs to keep track of which changes
have already been returned so that it does not return them again, it should
NOT modify the official startpoint. The internal value for the
startpoint should only be updated after a sync operation is acknowledged
back to this extension (via
acknowledgeCompletedOps(LinkedList)
).
Otherwise it will be possible for changes to be missed when the
Data Sync Server is restarted or a connection error occurs. The
startpoint should not change as a result of this method.
This method does not need to be thread-safe. It will be invoked repeatedly by a single thread, based on the polling interval set in the Sync Pipe configuration.
maxChanges
- the maximum number of changes to retrievenumStillPending
- this should be set to the number of unretrieved
changes that are still pending after this batch has
been retrieved. This will be passed in as zero, and
may be left that way if the actual value cannot be
determined.ChangeRecord
instances, each
corresponding to a single change at the source endpoint.
If there are no new changes to return, this method should return
an empty list.EndpointException
- if there is any error while retrieving the
next batch of changespublic abstract void acknowledgeCompletedOps(java.util.LinkedList<SyncOperation> completedOps) throws EndpointException
setStartpoint(SetStartpointOptions)
and is
returned by getStartpoint()
.
IMPORTANT: The internal value for the startpoint should only be
updated after a sync operation is acknowledged back to this extension (via
this method). Otherwise it will be possible for changes to be missed when
the Data Sync Server is restarted or a connection error occurs.completedOps
- a list of SyncOperation
s that have finished
processing. The records are listed in the order they
were first detected.EndpointException
- if there is an error acknowledging the changes
back to the source