|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.sync.SyncProcessor
public abstract class SyncProcessor
Manages one or more synchronized data sets for a particular external system and processes sync operations. Subclasses of this abstract class are used for specific types of external systems.
This class provides two types of extensibility.
First, it may be extended directly to implement its abstract methods in in order to implement synchronization with an external system that is not supported by one of the built-in SyncProcessor subclasses. Such subclasses may call the writeProcessorMetadata, readProcessorMetadata, writeProcessorTxnData and readProcessorTxnData methods.
Second, a concrete SyncProcessor subclass may itself by extended to override the openChangeReader method to provide a custom source of change set information. Such subclasses may call the writeChangeSetData and readChangeSetData methods.
Field Summary | |
---|---|
protected Environment |
env
|
protected EnvironmentImpl |
envImpl
|
protected String |
processorName
|
Constructor Summary | |
---|---|
protected |
SyncProcessor(Environment env,
String processorName)
Used by subclasses to create a SyncProcessor. |
Method Summary | ||
---|---|---|
abstract SyncDataSet |
addDataSet(String dataSetName,
Collection<SyncDatabase> databases)
Adds a data set that is managed by this processor. |
|
abstract void |
cancelSync()
Cancels a sync operation being performed in another thread. |
|
abstract Map<String,SyncDataSet> |
getDataSets()
Returns all SyncDataSets that are managed by this processor. |
|
Environment |
getEnvironment()
Returns the JE Environment associated with this processor. |
|
String |
getName()
Returns the name of the processor, which is unique among all processors for a JE Environment. |
|
SyncDB |
getSyncDB()
|
|
protected ChangeReader |
openChangeReader(String dataSetName,
boolean consolidateTransactions,
long consolidateMaxMemory)
Called internally by the SyncProcessor during a sync operation to obtain the set of local changes to be transferred to the external system. |
|
void |
readChangeSetData(Transaction txn,
String dataSetName,
DatabaseEntry data)
Called internally by the SyncProcessor to read change set data. |
|
|
readProcessorMetadata(Transaction txn)
Called internally by the SyncProcessor to read processor-specific configuration data, such as connection properties. |
|
protected void |
readProcessorTxnData(Transaction txn,
String dataSetName,
DatabaseEntry data)
Called internally by the SyncProcessor to read processor-specific transaction data. |
|
protected void |
registerDataSet(SyncDataSet dataSet)
Called internally by the SyncProcessor during a call to addDataSet(java.lang.String, java.util.Collection . |
|
abstract void |
removeDataSet(String dataSetName)
Removes a data set that is managed by this processor. |
|
void |
setAddHook(TestHook addHook)
|
|
void |
setRemoveHook(TestHook removeHook)
|
|
abstract void |
sync(ExportConfig exportConfig,
ImportConfig importConfig,
String... dataSetName)
Performs a sync operation for the specified SyncDataSets. |
|
abstract void |
syncAll(ExportConfig exportConfig,
ImportConfig importConfig)
Performs a sync operation for all SyncDataSets managed by this processor. |
|
protected void |
unregisterDataSet(String dataSetName)
Called internally by the SyncProcessor during a call to removeDataSet(java.lang.String) . |
|
void |
writeChangeSetData(Transaction txn,
String dataSetName,
DatabaseEntry data)
Called internally by the SyncProcessor to write change set data. |
|
|
writeProcessorMetadata(Transaction txn,
M metadata)
Called internally by the SyncProcessor to write processor-specific metadata, including a collection of SyncDataSet objects and processor connection properties. |
|
protected void |
writeProcessorTxnData(Transaction txn,
String dataSetName,
DatabaseEntry data)
Called internally by the SyncProcessor to write processor-specific transaction data. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Environment env
protected final EnvironmentImpl envImpl
protected final String processorName
Constructor Detail |
---|
protected SyncProcessor(Environment env, String processorName)
Method Detail |
---|
public String getName()
public Environment getEnvironment()
public abstract SyncDataSet addDataSet(String dataSetName, Collection<SyncDatabase> databases)
After calling this method, all changes to the JE databases in the data set will be tracked by JE, so they can be exported to the external system during a sync operation. The tracking of changes in the external system, if any, is defined by the SyncProcessor subclass.
The user must ensure that no transactions for the databases in the data set are active during the call to this method. If transactions are active, the results of the first sync operation with respect to these transactions are undefined, and the sync is unlikely to succeed.
Normally, each database in a newly added data set should be initially empty or non-existent. If a database is non-empty, the user must ensure that the records in the database are present in the external system.
IllegalStateException
- if a data set with the given name already
exists.public void setAddHook(TestHook addHook)
protected void registerDataSet(SyncDataSet dataSet)
addDataSet(java.lang.String, java.util.Collection)
. This method initializes change tracking for all databases
in the data set.
The user should only call this method when extending SyncProcessor directly to implement a custom processor for an external system that is not supported by the built-in SyncProcessor classes.
public abstract void removeDataSet(String dataSetName)
IllegalStateException
- if a data set with the given name does not
exist.public void setRemoveHook(TestHook removeHook)
protected void unregisterDataSet(String dataSetName)
removeDataSet(java.lang.String)
. This method will remove the change tracking information
for this SyncDataSet from the internal databases.
The user should only call this method when extending SyncProcessor directly to implement a custom processor for an external system that is not supported by the built-in SyncProcessor classes.
public abstract Map<String,SyncDataSet> getDataSets()
public abstract void syncAll(ExportConfig exportConfig, ImportConfig importConfig) throws SyncCanceledException
SyncCanceledException
public abstract void sync(ExportConfig exportConfig, ImportConfig importConfig, String... dataSetName) throws SyncCanceledException
SyncCanceledException
public abstract void cancelSync()
protected ChangeReader openChangeReader(String dataSetName, boolean consolidateTransactions, long consolidateMaxMemory)
The user should never have a need to call this method, but may wish to override it as described below.
The default implementation of this method returns a ChangeReader that reads the JE log and keeps track of processed and pending changes automatically. Note that the portion the JE log that contains change sets will be retained (the log cleaner will not delete the log files in this portion of the log) until all changes in that portion of the log are fully processed.
For advanced use, a user may override this method in any SyncProcessor to provide the change set by some other mechanism. For example, if a JE Database is used as an insert-only input queue for data to be transferred to an external system, a ChangeReader could be implemented that uses key ranges to keep track of processed and pending changes, and that reads the records in a key range from the Database, in order to supply the changes to the SyncProcessor. To keep track of change set metadata, a custom implementation may call writeChangeSetData and readChangeSetDat.
public final void writeChangeSetData(Transaction txn, String dataSetName, DatabaseEntry data)
The user should only call this method when extending a SyncProcessor class to override the openChangeReader method.
public final void readChangeSetData(Transaction txn, String dataSetName, DatabaseEntry data)
The user should only call this method when extending a SyncProcessor class to override the openChangeReader method.
public final <M extends ProcessorMetadata> void writeProcessorMetadata(Transaction txn, M metadata)
The user should only call this method when extending SyncProcessor directly to implement a custom processor for an external system that is not supported by the built-in SyncProcessor classes. Such implementations will also normally subclass ProcessorMetadata to add processor specific connection properties and other metadata.
public final <M extends ProcessorMetadata> M readProcessorMetadata(Transaction txn)
The user should only call this method when extending SyncProcessor directly to implement a custom processor for an external system that is not supported by the built-in SyncProcessor classes.
protected final void writeProcessorTxnData(Transaction txn, String dataSetName, DatabaseEntry data)
The user should only call this method when extending SyncProcessor directly to implement a custom processor for an external system that is not supported by the built-in SyncProcessor classes.
protected final void readProcessorTxnData(Transaction txn, String dataSetName, DatabaseEntry data)
The user should only call this method when extending SyncProcessor directly to implement a custom processor for an external system that is not supported by the built-in SyncProcessor classes.
public SyncDB getSyncDB()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |