xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.replication
Interface I_DbSpecific

All Superinterfaces:
I_ContribPlugin
All Known Implementing Classes:
SpecificDB2, SpecificDbReadonly, SpecificDefault, SpecificOracle, SpecificPostgres

public interface I_DbSpecific
extends I_ContribPlugin


Field Summary
static java.lang.String NEEDS_PUBLISHER_KEY
          key for the property defining if the publisher is needed on the implementation of this interface.
static boolean[] WIPEOUT_ALL
           
static int WIPEOUT_FUNCTIONS
           
static int WIPEOUT_INDEXES
           
static boolean[] WIPEOUT_NO_TABLES
           
static boolean[] WIPEOUT_ONLY_TABLES
           
static int WIPEOUT_PACKAGES
           
static int WIPEOUT_PROCEDURES
           
static int WIPEOUT_SEQUENCES
           
static int WIPEOUT_SYNONYMS
           
static int WIPEOUT_TABLES
           
static int WIPEOUT_TRIGGERS
           
static int WIPEOUT_VIEWS
           
 
Method Summary
 void addSchemaToWatch(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema)
          Adds a schema to be watched.
 boolean addTableToWatch(TableToWatchInfo tableToWatch, boolean force, java.lang.String[] destinations, boolean forceSend)
          Adds a table to be watcher/replicated.
 void addTrigger(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String tableName)
           
 void addTriggersIfNeeded(boolean force, java.lang.String[] destinations, boolean forceSend)
          Creates the necessary triggers if needed, i.e.
 void bootstrap(java.sql.Connection conn, boolean doWarn, boolean force)
          This method is invoked for the initial setup of the database.
 byte[] broadcastStatement(java.lang.String sql, long maxResponseEntries, boolean isHighPrio, boolean isMaster, java.lang.String sqlTopic, java.lang.String statementId)
          broadcasts a statement to be replicated.
 void cancelUpdate(java.lang.String replSlave)
          Tells the DbSpecific to cancel the ongoing initial update for the given slave.
 void checkTriggerConsistency(boolean doFix)
          Checks if the triggers are consistent, i.e.
 void cleanup(java.sql.Connection conn, boolean doWarn)
          This method is invoked for the cleanup while testing.
 void clearCancelUpdate(java.lang.String replSlave)
          Tells the DbSpecific to clear the cancel flag for ongoing updates for the given slave.
 java.lang.String createTableTrigger(SqlDescription infoDescription, TableToWatchInfo tableToWatch)
          Creates a string containing the trigger of the table to be watched.
 void forceTableChangeCheck()
          Invokes the function to check wether a table has been created, dropped or altered.
 java.lang.StringBuffer getColumnStatement(SqlColumn colInfoDescription)
          This method should actually be protected since it is not used on the outside.
 java.lang.String getContentFromGuid(java.lang.String guid, java.lang.String catalog, java.lang.String schema, java.lang.String table, I_AttributeTransformer transformer)
          This is used for cases where it was not possible to retrieve the (new) content of an entry synchronously in the PL/SQL Code.
 java.lang.String getCreateTableStatement(SqlDescription infoDescription, I_Mapper mapper)
          Returns the statement necessary to create a new table.
 java.lang.String getName()
           
 long incrementReplKey(java.sql.Connection conn)
          Increments and retreives the repl_key sequence counter.
 void initialCommand(java.lang.String[] slaveNames, java.lang.String completeFilename, java.lang.String version)
          This is the intial command which is invoked on the OS.
 void initialCommandPre()
          This is the command/script which is invoked before cleaning up resources on the initial update on the slave side (before the wipeout of the schema to be replicated).
 void initiateUpdate(java.lang.String topic, java.lang.String replManagerAddress, java.lang.String[] slaveName, java.lang.String version, java.lang.String initialFilesLocation)
          Initiates an initial update.
 boolean isDatasourceReadonly()
           
 void readNewTable(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.util.Map attrs, boolean sendInitialContents)
          Reads the metadata and content of the specified table.
 void removeTableToWatch(TableToWatchInfo tableToWatch, boolean removeAlsoSchemaTrigger)
          Removes a table from the repl_tables.
 boolean removeTrigger(java.lang.String triggerName, java.lang.String tableName, boolean isSchemaTrigger)
          removes the specified trigger from the specified table.
 void setAttributeTransformer(I_AttributeTransformer transformer)
           
 boolean triggerExists(java.sql.Connection conn, TableToWatchInfo tableToWatch)
          Checks wether a trigger really exists or not.
 int wipeoutSchema(java.lang.String catalog, java.lang.String schema, boolean[] objectsToWipeout)
          Cleans up the complete schema.
 
Methods inherited from interface org.xmlBlaster.contrib.I_ContribPlugin
getUsedPropertyKeys, init, shutdown
 

Field Detail

WIPEOUT_TRIGGERS

static final int WIPEOUT_TRIGGERS
See Also:
Constant Field Values

WIPEOUT_SEQUENCES

static final int WIPEOUT_SEQUENCES
See Also:
Constant Field Values

WIPEOUT_FUNCTIONS

static final int WIPEOUT_FUNCTIONS
See Also:
Constant Field Values

WIPEOUT_PACKAGES

static final int WIPEOUT_PACKAGES
See Also:
Constant Field Values

WIPEOUT_PROCEDURES

static final int WIPEOUT_PROCEDURES
See Also:
Constant Field Values

WIPEOUT_VIEWS

static final int WIPEOUT_VIEWS
See Also:
Constant Field Values

WIPEOUT_TABLES

static final int WIPEOUT_TABLES
See Also:
Constant Field Values

WIPEOUT_SYNONYMS

static final int WIPEOUT_SYNONYMS
See Also:
Constant Field Values

WIPEOUT_INDEXES

static final int WIPEOUT_INDEXES
See Also:
Constant Field Values

WIPEOUT_ALL

static final boolean[] WIPEOUT_ALL

WIPEOUT_ONLY_TABLES

static final boolean[] WIPEOUT_ONLY_TABLES

WIPEOUT_NO_TABLES

static final boolean[] WIPEOUT_NO_TABLES

NEEDS_PUBLISHER_KEY

static final java.lang.String NEEDS_PUBLISHER_KEY
key for the property defining if the publisher is needed on the implementation of this interface. This is used since this interface can be used on both master and slave. On the slave however it will never need a publisher.

See Also:
Constant Field Values
Method Detail

bootstrap

void bootstrap(java.sql.Connection conn,
               boolean doWarn,
               boolean force)
               throws java.lang.Exception
This method is invoked for the initial setup of the database. In production this method is probably never called. Initial configuration (for example procedural configuration), creation of 'system tables' , 'system functions' and triggers (if any) is done here. We use the term 'system' to specify such elements which are used internally for the replication.

Parameters:
conn -
doWarn - if false no warning is given on excrption.
force - if true, then everything is cleaned up, if false, then tables and sequences are only rebuilt if not existing.
Throws:
java.lang.Exception

cleanup

void cleanup(java.sql.Connection conn,
             boolean doWarn)
             throws java.lang.Exception
This method is invoked for the cleanup while testing. In production this method is probably never called. Cleanup of initial configuration (for example procedural configuration), dropping of 'system tables' , 'system functions' and triggers (if any) is done here. We use the term 'system' to specify such elements which are used internally for the replication.

Parameters:
conn -
doWarn - if false no warning is given on excrption.
Throws:
java.lang.Exception

readNewTable

void readNewTable(java.lang.String catalog,
                  java.lang.String schema,
                  java.lang.String table,
                  java.util.Map attrs,
                  boolean sendInitialContents)
                  throws java.lang.Exception
Reads the metadata and content of the specified table. This is needed for database implementations which can not detect synchronously if a CREATE has been done or which can not register the necessary triggers on that newly created table.

Parameters:
catalog - can be null
schema - can be null
table - can not be null
attrs - can be null
sendInitialContents - if true it will send all the contents of the added table, if false it will not send anything. So normally if you made a dump of the Database you don't want to send all the content of the tables again.
attrs - the attributes to pass to the description object when publishing. It basically contains the information about the metadata of an entry (the columns in repl_items without the old and new contents). Note that the values of such map are normally Strings, while the SqlInfo objects contain attributes where the value is a ClientProperty. That conversion is handled by the SqlDescription object.
Throws:
java.lang.Exception

getCreateTableStatement

java.lang.String getCreateTableStatement(SqlDescription infoDescription,
                                         I_Mapper mapper)
Returns the statement necessary to create a new table.

Parameters:
infoDescription - The description from which to create the statement.
mapper - the mapper to convert the table name (and in future the column names). Can be null, if null, no mapping is done.
Returns:

createTableTrigger

java.lang.String createTableTrigger(SqlDescription infoDescription,
                                    TableToWatchInfo tableToWatch)
Creates a string containing the trigger of the table to be watched. .

Parameters:
infoDescription -
triggerName - the name to give to the trigger associated with this table,
Returns:

forceTableChangeCheck

void forceTableChangeCheck()
                           throws java.lang.Exception
Invokes the function to check wether a table has been created, dropped or altered.

Throws:
java.lang.Exception

incrementReplKey

long incrementReplKey(java.sql.Connection conn)
                      throws java.lang.Exception
Increments and retreives the repl_key sequence counter. The connection must not be null. This method has been made available to the interface for the sole purpose to test it in the testsuite. Otherwise it is used internally by the implementations of this interface.

Parameters:
conn - the connection (it must not be null)
Returns:
the new sequence value for the repl_key sequence.
Throws:
java.lang.Exception - if an exception occurs.

addTableToWatch

boolean addTableToWatch(TableToWatchInfo tableToWatch,
                        boolean force,
                        java.lang.String[] destinations,
                        boolean forceSend)
                        throws java.lang.Exception
Adds a table to be watcher/replicated. It adds the entry to the repl_tables and makes sure that it is added with the correct case (depending upon how case sensitivity is handled by the implementation of the database).

Parameters:
catalog - the name of the catalog to use. If null, an empty string is stored (since part of the PK)
schema - the name of the schema to use. If null, an empty string is stored (since part of the PK).
tableName - the name of the table to be added.
replFlags - is a String containing a combination of 'IDU' (I)nsert, (U)pdate and (D)elete. If null or emtpy, then the trigger used to detect stuff to be replicated is not put anywhere, it is equivalent to not to replicate. If you pass I, then only inserts are performed. You normally will pass IDU' here.
triggerName - is the name which will be given to the trigger to add to the table. Can be null. If null is passed, then a name is choosed by the application. It is good practice to provide with a unique name.
force - if true, then the trigger is added even if it exists already.
destinations - can be null. If it has to be sent to an individual client you pass its session name here. If you pass null, then it is published in pub/sub modus. If you want to publish it to more than one client, you pass more destinations.
forceSend - if true, all content data of the table will be sent.
Returns:
true if the table was added, false otherwise. If the table already was registered (added), then it will not add it anymore.
Throws:
java.lang.Exception - if an exception occurs on the backend. For example if the table already has been added, it will throw an exception.

addSchemaToWatch

void addSchemaToWatch(java.sql.Connection conn,
                      java.lang.String catalog,
                      java.lang.String schema)
                      throws java.lang.Exception
Adds a schema to be watched. By Oracle it would add triggers to the schema.

Parameters:
catalog -
schema -
Throws:
java.lang.Exception

removeTableToWatch

void removeTableToWatch(TableToWatchInfo tableToWatch,
                        boolean removeAlsoSchemaTrigger)
                        throws java.lang.Exception
Removes a table from the repl_tables. This method will make sure that the correct case sensitivity for the table name will be used.

Parameters:
tableToWatch -
removeAlsoSchemaTrigger - if true it will also remove the associated schema trigger.
Throws:
java.lang.Exception

getColumnStatement

java.lang.StringBuffer getColumnStatement(SqlColumn colInfoDescription)
This method should actually be protected since it is not used on the outside. It is part of this interface since the handling for the different databases can be different.

Parameters:
colInfoDescription - The info object describing this column.
Returns:
A String Buffer containing the part of the CREATE statement which is specific to this column.

initiateUpdate

void initiateUpdate(java.lang.String topic,
                    java.lang.String replManagerAddress,
                    java.lang.String[] slaveName,
                    java.lang.String version,
                    java.lang.String initialFilesLocation)
                    throws java.lang.Exception
Initiates an initial update. It is invoked by the InitialUpdater in asynchronous mode.

Parameters:
topic -
replManagerAddress - the address to which to send acknowleges.
slaveName - the name of the slave interested in these updates
version - the version for which to start replication. If null the current version
initialFilesLocation - tells where to store the initial files in case the replication data has to be transfered manually by means of copying files. is ment.
Throws:
java.lang.Exception

initialCommand

void initialCommand(java.lang.String[] slaveNames,
                    java.lang.String completeFilename,
                    java.lang.String version)
                    throws java.lang.Exception
This is the intial command which is invoked on the OS. It is basically used for the import and export of the DB. Could also be used for other operations on the OS. It is a helper method.

Parameters:
slaveNames - an array containing the slaveNames to be updated. can be null.
completeFilename - the filename to be used to execute.
version - the version for which to start replication. If null the current version is ment.
Throws:
java.lang.Exception

initialCommandPre

void initialCommandPre()
                       throws java.lang.Exception
This is the command/script which is invoked before cleaning up resources on the initial update on the slave side (before the wipeout of the schema to be replicated).

Throws:
java.lang.Exception - if an exception occurs when executing the script.

removeTrigger

boolean removeTrigger(java.lang.String triggerName,
                      java.lang.String tableName,
                      boolean isSchemaTrigger)
removes the specified trigger from the specified table.

Parameters:
triggerName -
tableName -
isSchemaTrigger - true if the trigger to be removed is a schema trigger.
Returns:
true if the trigger has been removed, false otherwise.
Throws:
java.lang.Exception

wipeoutSchema

int wipeoutSchema(java.lang.String catalog,
                  java.lang.String schema,
                  boolean[] objectsToWipeout)
                  throws java.lang.Exception
Cleans up the complete schema. It cleans tables, sequences, views, functions, procedures, triggers and indexes.

Parameters:
catalog -
schema -
objectsToWipeout - a boolean[] array containing 9 elements telling wether the specified objects of a certain type have to be wiped out or not. For the relationship between position and meaning see the static variables. If you pass null here all object types are wiped out.
Returns:
the number of entries removed.
Throws:
java.lang.Exception

getContentFromGuid

java.lang.String getContentFromGuid(java.lang.String guid,
                                    java.lang.String catalog,
                                    java.lang.String schema,
                                    java.lang.String table,
                                    I_AttributeTransformer transformer)
                                    throws java.lang.Exception
This is used for cases where it was not possible to retrieve the (new) content of an entry synchronously in the PL/SQL Code.

Parameters:
guid - the unique Id identifying this entry. This is needed. Can not be null
catalog - can be null
schema - can be null
table - must be defined (can not be null).
transformer - An optional plugin
Returns:
the String containing the serialized entry.
Throws:
java.lang.Exception

getName

java.lang.String getName()

addTriggersIfNeeded

void addTriggersIfNeeded(boolean force,
                         java.lang.String[] destinations,
                         boolean forceSend)
                         throws java.lang.Exception
Creates the necessary triggers if needed, i.e. if the triggers are not existing already.

Parameters:
force - to force recreation of triggers even if they exist already.
Throws:
java.lang.Exception

triggerExists

boolean triggerExists(java.sql.Connection conn,
                      TableToWatchInfo tableToWatch)
                      throws java.lang.Exception
Checks wether a trigger really exists or not. This method is normally implemented by the vendor specific implementation. It is used to detect inconsistencies.

Parameters:
tableToWatch - The object containing the table to be checked for trigger
Returns:
true if the trigger really exists, false otherwise.
Throws:
java.lang.Exception - If an exception occurs in the backend.

checkTriggerConsistency

void checkTriggerConsistency(boolean doFix)
                             throws java.lang.Exception
Checks if the triggers are consistent, i.e. if the description found in the table is consistent with the real values.

Parameters:
doFix -
Throws:
java.lang.Exception

broadcastStatement

byte[] broadcastStatement(java.lang.String sql,
                          long maxResponseEntries,
                          boolean isHighPrio,
                          boolean isMaster,
                          java.lang.String sqlTopic,
                          java.lang.String statementId)
                          throws java.lang.Exception
broadcasts a statement to be replicated.

Parameters:
sql -
maxResponseEntries -
isHighPrio -
isMaster - true if it is on the master side, i.e. in the DbWatcher. Then it will first put an entry in the ITEMS table and thereafter execute the statement.
sqlTopic - the topic on which the response will be published.
statementId - The unique Id identifying this statement. This will also be the topic on which the response is sent.
Returns:
a byte[] containing the response (an xml literal)
Throws:
java.lang.Exception

cancelUpdate

void cancelUpdate(java.lang.String replSlave)
Tells the DbSpecific to cancel the ongoing initial update for the given slave.

Parameters:
replSlave - the String identifying the slave name.

clearCancelUpdate

void clearCancelUpdate(java.lang.String replSlave)
Tells the DbSpecific to clear the cancel flag for ongoing updates for the given slave.

Parameters:
replSlave - the String identifying the slave name.

setAttributeTransformer

void setAttributeTransformer(I_AttributeTransformer transformer)

isDatasourceReadonly

boolean isDatasourceReadonly()

addTrigger

void addTrigger(java.sql.Connection conn,
                java.lang.String catalog,
                java.lang.String schema,
                java.lang.String tableName)
                throws java.lang.Exception
Throws:
java.lang.Exception

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.