xmlBlaster 2.1.0 API

org.xmlBlaster.contrib.replication
Class ReplicationWriter

java.lang.Object
  extended by org.xmlBlaster.contrib.replication.ReplicationWriter
All Implemented Interfaces:
ContribConstants, I_Writer, I_ContribPlugin, I_Update, ReplicationConstants

public class ReplicationWriter
extends java.lang.Object
implements I_Writer, ReplicationConstants


Field Summary
private  I_Update callback
           
private  I_DbSpecific dbSpecific
           
private  java.io.OutputStream debugOs
           
private  boolean doAlter
           
private  boolean doCreate
           
private  boolean doDrop
           
private  boolean doStatement
           
private  boolean exceptionInTransaction
           
private  boolean hasInitialCmd
           
private  java.lang.String importLocation
           
protected  I_Info info
           
private  boolean keepDumpFiles
           
private  java.sql.Connection keptConnection
           
private static java.util.logging.Logger log
           
(package private)  I_Mapper mapper
           
private static java.lang.String ME
           
private  boolean nirvanaClient
           
private  boolean overwriteTables
           
private  I_Parser parserForOldInUpdates
           
protected  I_DbPool pool
           
private  I_PrePostStatement prePostStatement
           
private  boolean recreateTables
           
private  java.lang.String schemaToWipeout
           
private static int SQL_INFO_CACHE_MAX_SIZE_DEFAULT
           
private  java.util.Map sqlInfoCache
           
private  int sqlInfoCacheMaxSize
           
 
Fields inherited from interface org.xmlBlaster.contrib.replication.ReplicationConstants
ABSOLUTE_COUNT, ACTION_ATTR, ALREADY_PROCESSED_ATTR, ALTER_ACTION, CATALOG_ATTR, CONTRIB_PERSISTENT_MAP, CREATE_ACTION, DB_ID_ATTR, DELETE_ACTION, DROP_ACTION, DUMP_ACTION, DUMP_CONTENT_ATTR, DUMP_FILENAME, DUMP_POSTFIX, END_OF_TRANSITION, EXCEPTION_ATTR, EXTRA_REPL_KEY_ATTR, GUID_ATTR, INITIAL_DATA_END, INITIAL_DATA_END_TO_REMOTE, INITIAL_DATA_ID, INITIAL_DUMP_AS_XML, INITIAL_FILES_LOCATION, INITIAL_UPDATE_COLLECT, INITIAL_UPDATE_ONLY_REGISTER, INITIAL_UPDATE_START_BATCH, INITIAL_XML_CMD, INSERT_ACTION, KEEP_TRANSACTION_OPEN, MASTER_ATTR, MAX_ENTRIES_ATTR, MESSAGE_SEQ, NUM_OF_TRANSACTIONS, OLD_CONTENT_ATTR, PURPOSE_REPLICATION, REPL_KEY_ATTR, REPL_MANAGER_SESSION, REPL_MANAGER_TOPIC, REPL_PREFIX_DEFAULT, REPL_PREFIX_GROUP_KEY, REPL_PREFIX_KEY, REPL_REQUEST_CANCEL_UPDATE, REPL_REQUEST_RECREATE_TRIGGERS, REPL_REQUEST_UPDATE, REPL_VERSION, REPLICATION_CMD, REPLICATION_FORCE_SENDING, REPLICATION_MAX_ENTRIES_DEFAULT, REPLICATION_MAX_ENTRIES_KEY, REPLICATION_SEND_UNCHANGED_UPDATES, REPLICATION_VERSION, REQUEST_BROADCAST_SQL_TOPIC, REQUEST_CANCEL_UPDATE_TOPIC, REQUEST_INITIAL_DATA_TOPIC, REQUEST_RECREATE_TRIGGERS, RESPONSE_INITIAL_DATA_TOPIC, SCHEMA_ATTR, SIMPLE_MESSAGE, SLAVE_NAME, SQL_TOPIC_ATTR, STATEMENT_ACTION, STATEMENT_ATTR, STATEMENT_ID_ATTR, STATEMENT_PRIO_ATTR, SUPPORTED_VERSIONS, TABLE_NAME_ATTR, TRANSACTION_ATTR, TRANSACTION_SEQ, UPDATE_ACTION, VERSION_ATTR, VERSION_TOKEN
 
Fields inherited from interface org.xmlBlaster.contrib.ContribConstants
FILE_DATE, FILENAME_ATTR, FILENAME_ATTR_OLD_FASHION, SUBDIR_ATTR, TIMESTAMP_ATTR, TOPIC_NAME
 
Constructor Summary
ReplicationWriter()
           
 
Method Summary
private  void addToSqlInfoCache(SqlInfo sqlInfo)
           
private  boolean checkIfAlreadyProcessed(SqlInfo dbInfo)
          Checks weather an entry has already been processed, in which case it will not be processed anymore
private  void clearSqlInfoCache()
           
private  void deleteFiles(java.util.Map attrMap)
           
private  void deleteFiles(java.lang.String filename)
           
private  java.lang.String getCompleteFileName(java.lang.String filename)
           
private  java.lang.String getKey(java.lang.String catalog, java.lang.String schema, java.lang.String tableName)
           
private  java.lang.String getStringAttribute(java.lang.String key, SqlRow row, SqlDescription description)
          It first searches in the row and if nothing found it searches in the description.
private  SqlDescription getTableDescription(java.lang.String catalog, java.lang.String schema, java.lang.String tableName, java.sql.Connection conn)
          Returns the structure information of the table in question.
private  SqlInfo getTableDescriptionFromCache(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.
 void init(I_Info info_)
           
private  boolean isAllowedCommand(java.lang.String command)
           
private  int modifyColumnsIfNecessary(java.lang.String originalCatalog, java.lang.String originalSchema, java.lang.String originalTable, SqlRow row)
          Returns the number of columns modified.
private  void removeTableDescriptionFromCache(java.lang.String catalog, java.lang.String schema, java.lang.String tableName)
           
 void shutdown()
           
 void store(SqlInfo dbInfo)
           
 void update(java.lang.String topic, java.io.InputStream is, java.util.Map attrMap)
          The message received from the MoM or from another source.
private  void updateDump(java.lang.String topic, java.io.InputStream is, java.util.Map attrMap)
          This is invoked for dump files
private  void updateManualTransfer(java.lang.String topic, java.io.InputStream is, java.util.Map attrMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

log

private static java.util.logging.Logger log

pool

protected I_DbPool pool

info

protected I_Info info

dbSpecific

private I_DbSpecific dbSpecific

mapper

I_Mapper mapper

overwriteTables

private boolean overwriteTables

recreateTables

private boolean recreateTables

importLocation

private java.lang.String importLocation

callback

private I_Update callback

keepDumpFiles

private boolean keepDumpFiles

doDrop

private boolean doDrop

doCreate

private boolean doCreate

doAlter

private boolean doAlter

doStatement

private boolean doStatement

schemaToWipeout

private java.lang.String schemaToWipeout

prePostStatement

private I_PrePostStatement prePostStatement

hasInitialCmd

private boolean hasInitialCmd

parserForOldInUpdates

private I_Parser parserForOldInUpdates

nirvanaClient

private boolean nirvanaClient

sqlInfoCache

private java.util.Map sqlInfoCache

SQL_INFO_CACHE_MAX_SIZE_DEFAULT

private static final int SQL_INFO_CACHE_MAX_SIZE_DEFAULT
See Also:
Constant Field Values

sqlInfoCacheMaxSize

private int sqlInfoCacheMaxSize

exceptionInTransaction

private boolean exceptionInTransaction

keptConnection

private java.sql.Connection keptConnection

debugOs

private java.io.OutputStream debugOs
Constructor Detail

ReplicationWriter

public ReplicationWriter()
Method Detail

getUsedPropertyKeys

public java.util.Set getUsedPropertyKeys()
Description copied from interface: I_ContribPlugin
Gets all property keys which may be used by this object.

Specified by:
getUsedPropertyKeys in interface I_ContribPlugin
Returns:
See Also:
I_ContribPlugin.getUsedPropertyKeys()

init

public void init(I_Info info_)
          throws java.lang.Exception
Specified by:
init in interface I_ContribPlugin
Throws:
java.lang.Exception

shutdown

public void shutdown()
              throws java.lang.Exception
Specified by:
shutdown in interface I_ContribPlugin
Throws:
java.lang.Exception
See Also:
I_Plugin

getStringAttribute

private java.lang.String getStringAttribute(java.lang.String key,
                                            SqlRow row,
                                            SqlDescription description)
It first searches in the row and if nothing found it searches in the description. Both row and description are allowed to be null.

Parameters:
key -
row -
Returns:

isAllowedCommand

private boolean isAllowedCommand(java.lang.String command)

modifyColumnsIfNecessary

private final int modifyColumnsIfNecessary(java.lang.String originalCatalog,
                                           java.lang.String originalSchema,
                                           java.lang.String originalTable,
                                           SqlRow row)
                                    throws java.lang.Exception
Returns the number of columns modified.

Parameters:
originalCatalog -
originalSchema -
originalTable -
row - if null, nothing is changed
Returns:
Throws:
java.lang.Exception

checkIfAlreadyProcessed

private boolean checkIfAlreadyProcessed(SqlInfo dbInfo)
Checks weather an entry has already been processed, in which case it will not be processed anymore

Parameters:
dbInfo -
Returns:

store

public void store(SqlInfo dbInfo)
           throws java.lang.Exception
Specified by:
store in interface I_Writer
Throws:
java.lang.Exception

getKey

private final java.lang.String getKey(java.lang.String catalog,
                                      java.lang.String schema,
                                      java.lang.String tableName)

getTableDescriptionFromCache

private final SqlInfo getTableDescriptionFromCache(java.lang.String catalog,
                                                   java.lang.String schema,
                                                   java.lang.String tableName)

removeTableDescriptionFromCache

private final void removeTableDescriptionFromCache(java.lang.String catalog,
                                                   java.lang.String schema,
                                                   java.lang.String tableName)

addToSqlInfoCache

private final void addToSqlInfoCache(SqlInfo sqlInfo)

clearSqlInfoCache

private final void clearSqlInfoCache()

getTableDescription

private SqlDescription getTableDescription(java.lang.String catalog,
                                           java.lang.String schema,
                                           java.lang.String tableName,
                                           java.sql.Connection conn)
                                    throws java.lang.Exception
Returns the structure information of the table in question. This could be cached to get better performance.

Parameters:
schema -
tableName -
conn -
Returns:
Throws:
java.lang.Exception

getCompleteFileName

private final java.lang.String getCompleteFileName(java.lang.String filename)

deleteFiles

private void deleteFiles(java.lang.String filename)

deleteFiles

private void deleteFiles(java.util.Map attrMap)

updateDump

private void updateDump(java.lang.String topic,
                        java.io.InputStream is,
                        java.util.Map attrMap)
                 throws java.lang.Exception
This is invoked for dump files

Throws:
java.lang.Exception

updateManualTransfer

private void updateManualTransfer(java.lang.String topic,
                                  java.io.InputStream is,
                                  java.util.Map attrMap)
                           throws java.lang.Exception
Throws:
java.lang.Exception

update

public void update(java.lang.String topic,
                   java.io.InputStream is,
                   java.util.Map attrMap)
            throws java.lang.Exception
Description copied from interface: I_Update
The message received from the MoM or from another source.

Specified by:
update in interface I_Update
Parameters:
topic - The topic name
attrMap - A map with attribute, can be null
Throws:
java.lang.Exception

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.