|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.contrib.replication.impl.SpecificDefault
public abstract class SpecificDefault
Nested Class Summary | |
---|---|
(package private) class |
SpecificDefault.Replacer
|
Field Summary | |
---|---|
protected boolean |
blockLoop
|
private boolean |
bootstrapWarnings
|
private java.util.Set |
cancelledUpdates
|
static boolean |
COMMIT_NO
|
static boolean |
COMMIT_YES
|
protected DbMetaHelper |
dbMetaHelper
|
protected I_DbPool |
dbPool
|
protected I_Info |
info
|
private int |
initCount
|
protected InitialUpdater |
initialUpdater
|
protected boolean |
isDbWriteable
|
private boolean |
isInMaster
|
private static java.util.logging.Logger |
log
|
protected SpecificDefault.Replacer |
replacer
|
protected ReplaceVariable |
replaceVariable
|
protected java.lang.String |
replPrefix
|
protected java.lang.String |
replVersion
|
static boolean |
ROLLBACK_NO
|
static boolean |
ROLLBACK_YES
|
private int |
rowsPerMessage
|
protected I_AttributeTransformer |
transformer
|
Fields inherited from interface org.xmlBlaster.contrib.replication.I_DbSpecific |
---|
NEEDS_PUBLISHER_KEY, WIPEOUT_ALL, WIPEOUT_FUNCTIONS, WIPEOUT_INDEXES, WIPEOUT_NO_TABLES, WIPEOUT_ONLY_TABLES, WIPEOUT_PACKAGES, WIPEOUT_PROCEDURES, WIPEOUT_SEQUENCES, WIPEOUT_SYNONYMS, WIPEOUT_TABLES, WIPEOUT_TRIGGERS, WIPEOUT_VIEWS |
Constructor Summary | |
---|---|
SpecificDefault()
Not doing anything. |
Method Summary | |
---|---|
boolean |
addTableToWatch(TableToWatchInfo firstTableToWatch,
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)
|
private void |
addTrigger(java.sql.Connection conn,
TableToWatchInfo tableToWatch,
SqlInfo sqlInfo,
boolean force)
Adds a trigger. |
void |
addTriggersIfNeeded(boolean force,
java.lang.String[] destinations,
boolean forceSend)
If force is true, it deletes first all entries from the Tables table (kind of reset). |
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. |
int |
checkSequenceForCreation(java.lang.String creationRequest)
Checks if the sequence has to be created. |
int |
checkTableForCreation(java.lang.String creationRequest)
Checks if the table has to be created. |
void |
checkTriggerConsistency(boolean doFix)
Checks the consistency of the triggers. |
int |
checkTriggerForCreation(java.lang.String creationRequest)
Checks if the trigger has to be created. |
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. |
private void |
doBootstrapIfNeeded()
Checks wheter a bootstrapping is needed. |
void |
forceTableChangeCheck()
Invokes the function to check wether a table has been created, dropped or altered. |
java.util.List |
getContentFromClasspath(java.lang.String filename,
java.lang.String method,
java.lang.String flushSeparator,
java.lang.String cmdSeparator)
|
java.lang.String |
getCreateTableStatement(SqlDescription infoDescription,
I_Mapper mapper)
Returns the statement necessary to create a new table. |
java.lang.String |
getName()
Returns a name identifying this SpecificDefault. |
java.lang.String |
getObjectName(java.lang.String op,
java.lang.String req)
Gets the specified object name and returns its value (name). |
protected java.lang.String |
getOwnSchema()
|
static java.lang.String |
getReplPrefix(I_Info info)
|
private TableToWatchInfo |
getTableToWatch(java.sql.Connection conn,
java.lang.String catalog,
java.lang.String schema,
java.lang.String tableName)
|
java.util.Set |
getUsedPropertyKeys()
Gets all property keys which may be used by this object. |
long |
incrementReplKey(java.sql.Connection conn)
Increments and retreives the ${replPrefix}key sequence counter. |
void |
init(I_Info info)
|
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[] slaveNames,
java.lang.String requestedVersion,
java.lang.String initialFilesLocation)
Initiates an initial update. |
private boolean |
isCancelled(java.lang.String replSlave)
|
boolean |
isDatasourceReadonly()
|
private boolean |
isSchemaRegistered(java.sql.Connection conn,
java.lang.String schema)
To use this method the arguments must already have been cleaned. |
static void |
main(java.lang.String[] args)
Example code. |
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. |
protected java.sql.Connection |
releaseIntoPool(java.sql.Connection conn,
boolean doCommit)
Always returns null (to nullify the connection). |
static java.sql.Connection |
releaseIntoPool(java.sql.Connection conn,
boolean doCommit,
I_DbPool pool)
Always returns null (to nullify the connection). |
protected java.sql.Connection |
removeFromPool(java.sql.Connection conn,
boolean doRollback)
Always returns null (to nullify the connection). |
static java.sql.Connection |
removeFromPool(java.sql.Connection conn,
boolean doRollback,
I_DbPool pool)
Always returns null (to nullify the connection). |
void |
removeSchemaTriggers(java.lang.String schema)
Currently made public for testing. |
void |
removeTableToWatch(TableToWatchInfo tableToWatch,
boolean removeAlsoSchemaTrigger)
Removes a table from the repl_tables. |
private java.lang.String |
replaceTokens(java.lang.String content,
SpecificDefault.Replacer repl)
Replaces all tokens found in the content and returns the content with the values of the tokens. |
protected abstract boolean |
sequenceExists(java.sql.Connection conn,
java.lang.String sequenceName)
|
void |
setAttributeTransformer(I_AttributeTransformer transformer)
|
void |
shutdown()
|
static java.lang.String |
toString(java.lang.String[] str)
Convenience method for nice output, also used to set the _destination property in the Client properties of a message. |
protected abstract boolean |
triggerExists(java.sql.Connection conn,
java.lang.String triggerName)
|
protected void |
updateFromFile(java.sql.Connection conn,
java.lang.String method,
java.lang.String propKey,
java.lang.String propDefault,
boolean doWarn,
boolean force,
SpecificDefault.Replacer repl)
Reads the content to be executed from a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.xmlBlaster.contrib.replication.I_DbSpecific |
---|
addSchemaToWatch, createTableTrigger, getColumnStatement, getContentFromGuid, removeTrigger, triggerExists, wipeoutSchema |
Field Detail |
---|
public static final boolean ROLLBACK_YES
public static final boolean ROLLBACK_NO
public static final boolean COMMIT_YES
public static final boolean COMMIT_NO
private static java.util.logging.Logger log
private int rowsPerMessage
protected I_Info info
protected I_DbPool dbPool
protected DbMetaHelper dbMetaHelper
protected java.lang.String replPrefix
protected java.lang.String replVersion
protected ReplaceVariable replaceVariable
protected SpecificDefault.Replacer replacer
protected InitialUpdater initialUpdater
protected I_AttributeTransformer transformer
private boolean bootstrapWarnings
private int initCount
private boolean isInMaster
private java.util.Set cancelledUpdates
protected boolean isDbWriteable
protected boolean blockLoop
Constructor Detail |
---|
public SpecificDefault()
Method Detail |
---|
public java.util.List getContentFromClasspath(java.lang.String filename, java.lang.String method, java.lang.String flushSeparator, java.lang.String cmdSeparator) throws java.lang.Exception
filename
- method
-
java.lang.Exception
private final java.lang.String replaceTokens(java.lang.String content, SpecificDefault.Replacer repl)
content
-
public final java.lang.String getObjectName(java.lang.String op, java.lang.String req)
op
- req
-
public final int checkTableForCreation(java.lang.String creationRequest) throws java.lang.Exception
creationRequest
- the sql request to analyze.
java.lang.Exception
protected abstract boolean sequenceExists(java.sql.Connection conn, java.lang.String sequenceName) throws java.lang.Exception
java.lang.Exception
protected abstract boolean triggerExists(java.sql.Connection conn, java.lang.String triggerName) throws java.lang.Exception
java.lang.Exception
public int checkSequenceForCreation(java.lang.String creationRequest) throws java.lang.Exception
creationRequest
- the sql request to analyze.
NOTE: only made public for testing purposes.
java.lang.Exception
public final int checkTriggerForCreation(java.lang.String creationRequest) throws java.lang.Exception
creationRequest
- the sql request to analyze.
NOTE: only made public for testing purposes.
java.lang.Exception
public static java.lang.String toString(java.lang.String[] str)
str
-
protected void updateFromFile(java.sql.Connection conn, java.lang.String method, java.lang.String propKey, java.lang.String propDefault, boolean doWarn, boolean force, SpecificDefault.Replacer repl) throws java.lang.Exception
conn
- The connection on which to operate. Must not be null.method
- The method which uses this invocation (used for logging
purposes).propKey
- The name (or key) of the property to retrieve. The content of
this property is the bootstrap file namepropDefault
- The default of the property.force
- if force is true it will add it no matter what (overwrites
existing stuff), otherwise it will check for existence.
java.lang.Exception
- if an exception occurs when reading the bootstrap file. Note
that in case of an exception you need to erase the connection from the pool (if you
are using a pool)public void bootstrap(java.sql.Connection conn, boolean doWarn, boolean force) throws java.lang.Exception
I_DbSpecific
bootstrap
in interface I_DbSpecific
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.
java.lang.Exception
In case of an exception you need to cleanup the connection yourself.
public void cleanup(java.sql.Connection conn, boolean doWarn) throws java.lang.Exception
I_DbSpecific
cleanup
in interface I_DbSpecific
doWarn
- if false no warning is given on excrption.
java.lang.Exception
In case of an exception you need to cleanup
the connection yourself.
public final java.util.Set getUsedPropertyKeys()
I_ContribPlugin
getUsedPropertyKeys
in interface I_ContribPlugin
I_ContribPlugin.getUsedPropertyKeys()
public final java.lang.String getName()
getName
in interface I_DbSpecific
public void init(I_Info info) throws java.lang.Exception
init
in interface I_ContribPlugin
java.lang.Exception
I_ContribPlugin.init(I_Info)
protected java.lang.String getOwnSchema()
public void checkTriggerConsistency(boolean doFix) throws java.lang.Exception
checkTriggerConsistency
in interface I_DbSpecific
java.lang.Exception
private final void doBootstrapIfNeeded() throws java.lang.Exception
java.lang.Exception
public final void shutdown()
shutdown
in interface I_ContribPlugin
I_ContribPlugin.shutdown()
public long incrementReplKey(java.sql.Connection conn) throws java.lang.Exception
incrementReplKey
in interface I_DbSpecific
conn
-
java.lang.Exception
I_DbSpecific.incrementReplKey(Connection)
private final void addTrigger(java.sql.Connection conn, TableToWatchInfo tableToWatch, SqlInfo sqlInfo, boolean force) throws java.lang.Exception
conn
- tableToWatch
- sqlInfo
-
java.lang.Exception
public void addTrigger(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String tableName) throws java.lang.Exception
addTrigger
in interface I_DbSpecific
java.lang.Exception
org.xmlBlaster.contrib.replication.I_DbSpecific#addTrigger(java.sql.Connection, java.lang.String, java.lang.String, java.lang.String, org.xmlBlaster.contrib.dbwriter.info.SqlInfo)
public final void readNewTable(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.util.Map attrs, boolean sendInitialContents) throws java.lang.Exception
I_DbSpecific
readNewTable
in interface I_DbSpecific
catalog
- can be nullschema
- can be nulltable
- can not be nullattrs
- can be nullsendInitialContents
- 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.
java.lang.Exception
I_DbSpecific#readNewTable(String, String, String, Map)
public void forceTableChangeCheck() throws java.lang.Exception
I_DbSpecific
forceTableChangeCheck
in interface I_DbSpecific
java.lang.Exception
private final boolean isSchemaRegistered(java.sql.Connection conn, java.lang.String schema) throws java.sql.SQLException
schema
- can not be null (use ' ' for null)
java.sql.SQLException
private final TableToWatchInfo getTableToWatch(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String tableName) throws java.lang.Exception
java.lang.Exception
public final boolean addTableToWatch(TableToWatchInfo firstTableToWatch, boolean force, java.lang.String[] destinations, boolean forceSend) throws java.lang.Exception
I_DbSpecific
addTableToWatch
in interface I_DbSpecific
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.
java.lang.Exception
- if an exception occurs on the backend. For example if the table already has been
added, it will throw an exception.I_DbSpecific#addTableToWatch(String, String, String, String, String, boolean, String, boolean)
public void removeSchemaTriggers(java.lang.String schema)
schema
- public final void removeTableToWatch(TableToWatchInfo tableToWatch, boolean removeAlsoSchemaTrigger) throws java.lang.Exception
I_DbSpecific
removeTableToWatch
in interface I_DbSpecific
removeAlsoSchemaTrigger
- if true it will also remove the associated schema trigger.
java.lang.Exception
I_DbSpecific#removeTableToWatch(String)
public final java.lang.String getCreateTableStatement(SqlDescription infoDescription, I_Mapper mapper)
I_DbSpecific
getCreateTableStatement
in interface I_DbSpecific
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.
I_DbSpecific.getCreateTableStatement(SqlDescription,
I_Mapper)
public void addTriggersIfNeeded(boolean force, java.lang.String[] destinations, boolean forceSend) throws java.lang.Exception
addTriggersIfNeeded
in interface I_DbSpecific
force
- to force recreation of triggers even if they exist already.
java.lang.Exception
public void initiateUpdate(java.lang.String topic, java.lang.String replManagerAddress, java.lang.String[] slaveNames, java.lang.String requestedVersion, java.lang.String initialFilesLocation) throws java.lang.Exception
I_DbSpecific
initiateUpdate
in interface I_DbSpecific
replManagerAddress
- the address to which to send acknowleges.slaveNames
- the name of the slave interested in these updatesrequestedVersion
- the version for which to start replication. If null the current versioninitialFilesLocation
- tells where to store the initial files in case the replication data
has to be transfered manually by means of copying files.
is ment.
java.lang.Exception
org.xmlBlaster.contrib.replication.I_DbSpecific#initiateUpdate(java.lang.String)
public void initialCommand(java.lang.String[] slaveNames, java.lang.String completeFilename, java.lang.String version) throws java.lang.Exception
I_DbSpecific
initialCommand
in interface I_DbSpecific
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.
java.lang.Exception
org.xmlBlaster.contrib.replication.I_DbSpecific#initialCommand(java.lang.String, java.lang.String)
public void initialCommandPre() throws java.lang.Exception
I_DbSpecific
initialCommandPre
in interface I_DbSpecific
java.lang.Exception
- if an exception occurs when executing the script.I_DbSpecific.initialCommandPre()
public byte[] broadcastStatement(java.lang.String sql, long maxResponseEntries, boolean isHighPrio, boolean isMaster, java.lang.String sqlTopic, java.lang.String statementId) throws java.lang.Exception
I_DbSpecific
broadcastStatement
in interface I_DbSpecific
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.
java.lang.Exception
org.xmlBlaster.contrib.replication.I_DbSpecific#broadcastStatement(java.lang.String, long, long, boolean, boolean, String, String)
protected java.sql.Connection removeFromPool(java.sql.Connection conn, boolean doRollback)
conn
- The connection. Can be null, in which case nothing is done.doRollback
- if true, a rollback is done, on false no rollback is done.
public static java.sql.Connection removeFromPool(java.sql.Connection conn, boolean doRollback, I_DbPool pool)
conn
- The connection. Can be null, in which case nothing is done.doRollback
- if true, a rollback is done, on false no rollback is done.pool
- the pool to which the connection belongs.
protected java.sql.Connection releaseIntoPool(java.sql.Connection conn, boolean doCommit)
conn
- The connection. Can be null, in which case nothing is done.doCommit
- if true, a commit is done, on false no commit is done.
public static java.sql.Connection releaseIntoPool(java.sql.Connection conn, boolean doCommit, I_DbPool pool)
conn
- The connection. Can be null, in which case nothing is done.doCommit
- if true, a commit is done, on false no commit is done.pool
- the pool to which the connection belongs.
public void cancelUpdate(java.lang.String replSlave)
I_DbSpecific
cancelUpdate
in interface I_DbSpecific
replSlave
- the String identifying the slave name.I_DbSpecific.cancelUpdate(java.lang.String)
public void clearCancelUpdate(java.lang.String replSlave)
I_DbSpecific
clearCancelUpdate
in interface I_DbSpecific
replSlave
- the String identifying the slave name.I_DbSpecific.clearCancelUpdate(java.lang.String)
private boolean isCancelled(java.lang.String replSlave)
public static java.lang.String getReplPrefix(I_Info info)
public static void main(java.lang.String[] args)
args
- Command linepublic void setAttributeTransformer(I_AttributeTransformer transformer)
setAttributeTransformer
in interface I_DbSpecific
public boolean isDatasourceReadonly()
isDatasourceReadonly
in interface I_DbSpecific
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |