xmlBlaster 2.1.0 API

org.xmlBlaster.contrib.replication.impl
Class InitialUpdater

java.lang.Object
  extended by org.xmlBlaster.contrib.replication.impl.InitialUpdater
All Implemented Interfaces:
I_ConnectionStateListener, ContribConstants, I_ContribPlugin, I_Update, I_ReplSource, ReplicationConstants, I_ReplaceContent

public class InitialUpdater
extends java.lang.Object
implements I_Update, I_ContribPlugin, I_ConnectionStateListener, I_ReplaceContent, ReplicationConstants, I_ReplSource


Nested Class Summary
 class InitialUpdater.ConnectionInfo
           
(package private)  class InitialUpdater.ExecuteListener
           
(package private)  class InitialUpdater.ExecutionThread
           
 
Field Summary
private  boolean collectInitialUpdates
           
private  java.lang.String CREATE_COUNTER_KEY
           
private  I_DbSpecific dbSpecific
           
protected  I_Info info
           
private  java.lang.String initialCmd
           
private  java.lang.String initialCmdPath
           
private  java.lang.String initialCmdPre
           
private  long initialCmdSleepDelay
           
private  java.lang.String initialDataTopic
           
private  boolean initialDumpAsXml
           
private  int initialDumpMaxSize
           
private  boolean keepDumpFiles
           
private static java.util.logging.Logger log
           
private  java.util.Map preparedUpdates
          Contains updates to be executed where the key is the version
protected  I_ChangePublisher publisher
          used to publish CREATE changes
private  java.lang.String replPrefix
           
private  ReplSourceEngine replSourceEngine
           
private  java.util.Map runningExecutes
           
private  java.lang.String stringToCheck
           
 
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
InitialUpdater(I_DbSpecific dbSpecific)
          Not doing anything.
 
Method Summary
 java.lang.String buildFilename(java.lang.String replPrefix_, java.lang.String requestedVersion)
          It builds the name to return in case the version is different from the current version.
 void cancelUpdate(java.lang.String slaveName)
           
 void collectInitialUpdate()
           
 byte[] executeStatement(java.lang.String sql, long maxResponseEntries, boolean isHighPrio, boolean isMaster, java.lang.String sqlTopic, java.lang.String statementId)
           
 InitialUpdater.ConnectionInfo getConnectionInfo(java.sql.Connection conn)
           
private  java.lang.String getSupportedVersions(java.lang.String currentReplVersion)
           
 java.lang.String getTopic()
           
 java.util.Set getUsedPropertyKeys()
          Gets all property keys which may be used by this object.
 void init(I_Info info_)
           
 java.lang.String initialCommand(java.lang.String[] slaveNames, java.lang.String completeFilename, InitialUpdater.ConnectionInfo connInfo, java.lang.String version)
          This is the intial command which is invoked on the OS.
 void initialCommandPre()
           
 void initialUpdate(java.lang.String replTopic, java.lang.String replManagerAddress, java.lang.String slaveName, java.lang.String requestedVersion, java.lang.String initialFilesLocation, boolean onlyRegister)
           
private  void osExecute(java.lang.String[] slaveNames, java.lang.String cmd, InitialUpdater.ConnectionInfo connInfo)
          Executes an Operating System command.
 java.lang.String publishCreate(int counter, SqlInfo updateInfo, long newReplKey, java.lang.String destination)
          Publishes a 'CREATE TABLE' operation to the XmlBlaster.
 void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          Sends a new registration message
 void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE.
 void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from XmlBlasterAccess informing the client that the connection was lost (i.e.
 void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from XmlBlasterAccess informing the client that the connection state has changed to POLLING.
 void recreateTriggers()
           
 byte[] replace(byte[] oldContent, java.util.Map clientProperties)
          Replaces or modifies the oldcontent.
 void sendEndOfTransitionMessage(java.lang.String[] slaveSessionNames)
          This method is used where the end of transition message has to be sent separately (for example for read-only applications without triggers)
 void sendInitialDataResponse(java.lang.String[] slaveSessionNames, java.lang.String shortFilename, java.lang.String replManagerAddress, long minKey, long maxKey, java.lang.String requestedVersion, java.lang.String currentVersion, java.lang.String initialFilesLocation)
           
 void sendInitialDataResponseOnly(java.lang.String[] slaveSessionNames, java.lang.String replManagerAddress, long minKey, long maxKey)
          Sending this message will reactivate the Dispatcher of the associated slave
 void shutdown()
           
 void startInitialUpdateBatch()
           
 void update(java.lang.String topic, java.io.InputStream is, java.util.Map attrMap)
          The message received from the MoM or from another source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATE_COUNTER_KEY

private java.lang.String CREATE_COUNTER_KEY

log

private static java.util.logging.Logger log

publisher

protected I_ChangePublisher publisher
used to publish CREATE changes


info

protected I_Info info

initialCmd

private java.lang.String initialCmd

initialCmdPre

private java.lang.String initialCmdPre

initialCmdPath

private java.lang.String initialCmdPath

keepDumpFiles

private boolean keepDumpFiles

replPrefix

private java.lang.String replPrefix

dbSpecific

private I_DbSpecific dbSpecific

stringToCheck

private java.lang.String stringToCheck

runningExecutes

private java.util.Map runningExecutes

initialDataTopic

private java.lang.String initialDataTopic

preparedUpdates

private java.util.Map preparedUpdates
Contains updates to be executed where the key is the version


collectInitialUpdates

private boolean collectInitialUpdates

initialDumpAsXml

private boolean initialDumpAsXml

initialDumpMaxSize

private int initialDumpMaxSize

initialCmdSleepDelay

private long initialCmdSleepDelay

replSourceEngine

private ReplSourceEngine replSourceEngine
Constructor Detail

InitialUpdater

public InitialUpdater(I_DbSpecific dbSpecific)
Not doing anything.

Method Detail

getUsedPropertyKeys

public final 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()

getConnectionInfo

public InitialUpdater.ConnectionInfo getConnectionInfo(java.sql.Connection conn)

init

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

shutdown

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

publishCreate

public final java.lang.String publishCreate(int counter,
                                            SqlInfo updateInfo,
                                            long newReplKey,
                                            java.lang.String destination)
                                     throws java.lang.Exception
Publishes a 'CREATE TABLE' operation to the XmlBlaster. It is used on the DbWatcher side. Note that it is also used to publish the INSERT commands related to a CREATE TABLE operation, i.e. if on a CREATE TABLE operation it is found that the table is already populated when reading it, then these INSERT operations are published with this method.

Parameters:
counter - The counter indicating which message number it is. The create opeation itself will have '0', the subsequent associated INSERT operations will have an increasing number (it is the number of the message not the number of the associated INSERT operation).
destination - in case it is a ptp it is sent only to that destination, otherwise it is sent as a pub/sub. This parameter also determines on which topic to publish.
Returns:
a uniqueId identifying this publish operation.
Throws:
java.lang.Exception

sendInitialDataResponseOnly

public final void sendInitialDataResponseOnly(java.lang.String[] slaveSessionNames,
                                              java.lang.String replManagerAddress,
                                              long minKey,
                                              long maxKey)
                                       throws java.lang.Exception
Sending this message will reactivate the Dispatcher of the associated slave

Parameters:
topic -
filename -
replManagerAddress -
slaveName -
minKey -
maxKey -
Throws:
java.lang.Exception

sendInitialDataResponse

public final void sendInitialDataResponse(java.lang.String[] slaveSessionNames,
                                          java.lang.String shortFilename,
                                          java.lang.String replManagerAddress,
                                          long minKey,
                                          long maxKey,
                                          java.lang.String requestedVersion,
                                          java.lang.String currentVersion,
                                          java.lang.String initialFilesLocation)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

sendEndOfTransitionMessage

public void sendEndOfTransitionMessage(java.lang.String[] slaveSessionNames)
                                throws javax.jms.JMSException
This method is used where the end of transition message has to be sent separately (for example for read-only applications without triggers)

Parameters:
slaveSessionNames -
Throws:
javax.jms.JMSException

osExecute

private void osExecute(java.lang.String[] slaveNames,
                       java.lang.String cmd,
                       InitialUpdater.ConnectionInfo connInfo)
                throws java.lang.Exception
Executes an Operating System command.

Parameters:
cmd -
Throws:
java.lang.Exception

getSupportedVersions

private java.lang.String getSupportedVersions(java.lang.String currentReplVersion)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

initialCommand

public final java.lang.String initialCommand(java.lang.String[] slaveNames,
                                             java.lang.String completeFilename,
                                             InitialUpdater.ConnectionInfo connInfo,
                                             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. If the initialCmd (the 'replication.initialCmd' property) is null, then it silently returns null as the filename.

Parameters:
argument - the argument to execute. It is normally the absolute file name to be exported/imported. Can be null, if null, one is generated by using the current timestamp.
conn - the connection to perform a commit on. Can be null, if null, no commit is done asynchronously.
Throws:
java.lang.Exception

buildFilename

public java.lang.String buildFilename(java.lang.String replPrefix_,
                                      java.lang.String requestedVersion)
It builds the name to return in case the version is different from the current version. If initialCmd has been defined as null, null is silenty returned.

Parameters:
replPrefix_ -
requestedVersion -
Returns:

initialCommandPre

public final void initialCommandPre()
                             throws java.lang.Exception
Throws:
java.lang.Exception

reachedAlive

public void reachedAlive(ConnectionStateEnum oldState,
                         I_XmlBlasterAccess connection)
Sends a new registration message

Specified by:
reachedAlive in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.
See Also:
I_ConnectionStateListener.reachedAlive(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)

reachedAliveSync

public void reachedAliveSync(ConnectionStateEnum oldState,
                             I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE. Note that this could take some time or in the worst case it could never been invoked if the queue is never completely processed.

Specified by:
reachedAliveSync in interface I_ConnectionStateListener
Parameters:
oldState - is always ALIVE.

reachedDead

public void reachedDead(ConnectionStateEnum oldState,
                        I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess informing the client that the connection was lost (i.e. when the state of the connection has gone to DEAD).

Specified by:
reachedDead in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.
See Also:
I_ConnectionStateListener.reachedDead(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)

reachedPolling

public void reachedPolling(ConnectionStateEnum oldState,
                           I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess informing the client that the connection state has changed to POLLING.

Specified by:
reachedPolling in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.
See Also:
I_ConnectionStateListener.reachedPolling(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)

replace

public byte[] replace(byte[] oldContent,
                      java.util.Map clientProperties)
Description copied from interface: I_ReplaceContent
Replaces or modifies the oldcontent. The returned instance can be the same as passed as the oldContent or it can be a new instance.

Specified by:
replace in interface I_ReplaceContent
clientProperties - the map can either be used as attributes or it can be modified in this method.
Returns:
value

update

public final void update(java.lang.String topic,
                         java.io.InputStream is,
                         java.util.Map attrMap)
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
See Also:
org.xmlBlaster.contrib.I_Update#update(java.lang.String, byte[], java.util.Map)

collectInitialUpdate

public void collectInitialUpdate()
Specified by:
collectInitialUpdate in interface I_ReplSource

executeStatement

public byte[] executeStatement(java.lang.String sql,
                               long maxResponseEntries,
                               boolean isHighPrio,
                               boolean isMaster,
                               java.lang.String sqlTopic,
                               java.lang.String statementId)
                        throws java.lang.Exception
Specified by:
executeStatement in interface I_ReplSource
Throws:
java.lang.Exception

recreateTriggers

public void recreateTriggers()
                      throws java.lang.Exception
Specified by:
recreateTriggers in interface I_ReplSource
Throws:
java.lang.Exception

cancelUpdate

public void cancelUpdate(java.lang.String slaveName)
Specified by:
cancelUpdate in interface I_ReplSource

initialUpdate

public void initialUpdate(java.lang.String replTopic,
                          java.lang.String replManagerAddress,
                          java.lang.String slaveName,
                          java.lang.String requestedVersion,
                          java.lang.String initialFilesLocation,
                          boolean onlyRegister)
Specified by:
initialUpdate in interface I_ReplSource

getTopic

public java.lang.String getTopic()
Specified by:
getTopic in interface I_ReplSource

startInitialUpdateBatch

public void startInitialUpdateBatch()
Specified by:
startInitialUpdateBatch in interface I_ReplSource

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.