xmlBlaster 2.2.0 contributions API

org.xmlBlaster.contrib.replication
Class ReplSlave

java.lang.Object
  extended by org.xmlBlaster.contrib.replication.ReplSlave
All Implemented Interfaces:
ContribConstants, I_ContribPlugin, I_ReplSlave, ReplicationConstants, ReplSlaveMBean

public class ReplSlave
extends java.lang.Object
implements I_ReplSlave, ReplSlaveMBean, ReplicationConstants

ReplSlave Used Topics:

Author:
Michele Laghi

Field Summary
 
Fields inherited from interface org.xmlBlaster.contrib.replication.I_ReplSlave
CASCADED_REPL_PREFIX, CASCADED_REPL_SLAVE, DBWATCHER_SESSION_NAME, STATUS_INCONSISTENT, STATUS_INITIAL, STATUS_NORMAL, STATUS_TRANSITION, STATUS_UNCONFIGURED
 
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
ReplSlave(org.xmlBlaster.util.Global global, ReplManagerPlugin manager, java.lang.String slaveSessionId, org.xmlBlaster.util.qos.ConnectQosData connQosData)
           
 
Method Summary
 void cancelInitialUpdate()
          TODO fix this since it potentially could delete request from other slaves since the DbWatcher is serving several slaves.
 void cancelInitialUpdate(boolean async)
          TODO fix this since it potentially could delete request from other slaves since the DbWatcher is serving several slaves.
 java.util.ArrayList check(java.util.List<org.xmlBlaster.util.queue.I_Entry> entries, org.xmlBlaster.util.queue.I_Queue queue)
           
 void checkStatus()
          Checks on the backend data which has to be displayed on the MBean.
 void clearQueue()
           
static byte[] decompressQueueEntryContent(org.xmlBlaster.engine.queuemsg.ReferenceEntry entry)
           
 void doContinue(boolean doPersist)
           
 void doPause(boolean doPersist)
           
 java.lang.String dumpEntries(int maxNum, long maxSize, java.lang.String fileName)
           
 java.lang.String dumpFirstEntry()
           
 java.lang.String getCascadedConnection()
           
 java.lang.String getCascadedMasterConnection()
           
 long getCascadedQueueEntries()
           
 java.lang.String getCascadedSessionName()
           
 java.lang.String getCascadedStatus()
           
 long getCascadedTransactionSeq()
           
 java.lang.String getCascadedVersion()
           
 java.lang.String getConnection()
          Returns a string telling in which state the connection is.
 java.lang.String getLastMessage()
           
 java.lang.String getMasterConnection()
           
 int getMaxNumOfEntries()
           
 long getMaxReplKey()
           
 long getMinReplKey()
           
 long getQueueEntries()
          Convenience method enforced by the MBean which returns the number of entries in the queue.
 java.lang.String getReplPrefix()
           
 java.lang.String getReplPrefixGroup()
           
 java.lang.String getSessionName()
           
 java.lang.String getSqlResponse()
           
 java.lang.String getStatus()
           
 int getStatusAsInt()
           
 java.lang.String getTopic()
           
 long getTransactionSeq()
           
 java.util.Set getUsedPropertyKeys()
          Gets all property keys which may be used by this object.
 java.lang.String getVersion()
           
 void handleException(java.lang.Throwable ex)
          Pauses the dispatcher.
 void incrementPtPEntries(long numOfTransactions)
          Increments the amount of entries in the ptp counter queue
 void init(I_Info info)
          The info comes as the client properties of the subscription Qos.
 boolean isActive()
          Convenience method enforced by the MBean which returns true if the dispatcher of the slave session is active, false otherwise.
 boolean isCascadedActive()
           
 boolean isCascadedConnected()
           
 boolean isCascading()
           
 boolean isConnected()
          Convenience method enforced by the MBean which returns true if the real slave is connected or false otherwise.
 boolean isCountSingleMsg()
           
 boolean isStalled()
          Convenience method enforced by the MBean which returns true if the connection to the real slave is stalled or false otherwise.
 void kill()
           
 void onDeadLetter(java.util.Map qosClientProperties)
          Invoked by the ReplManagerPlugin when a deadMessage is published because an error
 void postCheck(org.xmlBlaster.util.MsgUnit[] processedMsgUnits)
           
 void prepareForRequest(I_Info individualInfo)
          This is the first step in the process of requesting the initial Data.
 void reactivateDestination(long minReplKey, long maxReplKey)
          6 This is received by the DbWatcher jvm.
 boolean reInitiate(I_Info info)
           
 java.lang.String reInitiateReplication()
           
 long removeQueueEntries(long entries)
           
 void requestInitialData(java.lang.String dbWatcherSessionId, boolean onlyRegister)
          Sends a PtP message to the responsible for the initial update (which is the DbWatcher or an object running in the DbWatcher jvm) telling a new initial update has to be initiating.
 boolean run(I_Info info, java.lang.String dbWatcherSessionId, java.lang.String cascadeReplPrefix, java.lang.String cascadeSlaveSessionName, boolean onlyRegister)
          Starts a replication
 void setCountSingleMsg(boolean countSingleMsg)
           
 boolean setDispatcher(boolean status)
           
 boolean setDispatcher(boolean status, boolean doPersist)
           
 void setMaxNumOfEntries(int maxNumOfEntries)
          Sets the maximum number of entries to be sent in one single message.
 void setSqlResponse(java.lang.String sqlResponse)
           
 void shutdown()
           
 boolean toggleActive()
          Toggles the dispatcher from active to inactive or vice versa.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReplSlave

public ReplSlave(org.xmlBlaster.util.Global global,
                 ReplManagerPlugin manager,
                 java.lang.String slaveSessionId,
                 org.xmlBlaster.util.qos.ConnectQosData connQosData)
          throws org.xmlBlaster.util.XmlBlasterException
Throws:
org.xmlBlaster.util.XmlBlasterException
Method Detail

getTopic

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

getMinReplKey

public long getMinReplKey()
Specified by:
getMinReplKey in interface ReplSlaveMBean

getMaxReplKey

public long getMaxReplKey()
Specified by:
getMaxReplKey in interface ReplSlaveMBean

getStatusAsInt

public int getStatusAsInt()
Specified by:
getStatusAsInt in interface I_ReplSlave

getStatus

public java.lang.String getStatus()
Specified by:
getStatus in interface I_ReplSlave
Specified by:
getStatus in interface ReplSlaveMBean

init

public void init(I_Info info)
          throws java.lang.Exception
The info comes as the client properties of the subscription Qos. Avoids double configuration.

Specified by:
init in interface I_ContribPlugin
Throws:
java.lang.Exception

reInitiate

public boolean reInitiate(I_Info info)
                   throws java.lang.Exception
Specified by:
reInitiate in interface I_ReplSlave
Throws:
java.lang.Exception

run

public boolean run(I_Info info,
                   java.lang.String dbWatcherSessionId,
                   java.lang.String cascadeReplPrefix,
                   java.lang.String cascadeSlaveSessionName,
                   boolean onlyRegister)
            throws java.lang.Exception
Description copied from interface: I_ReplSlave
Starts a replication

Specified by:
run in interface I_ReplSlave
Parameters:
info -
dbWatcherSessionId -
cascadeReplPrefix -
cascadeSlaveSessionName -
onlyRegister - if true it only registers for initial update but does not execute it yet. It will wait for a further (common) start message.
Returns:
Throws:
java.lang.Exception

prepareForRequest

public void prepareForRequest(I_Info individualInfo)
                       throws java.lang.Exception
This is the first step in the process of requesting the initial Data.

Specified by:
prepareForRequest in interface I_ReplSlave
Throws:
java.lang.Exception
See Also:
I_ReplSlave.prepareForRequest(I_Info)

requestInitialData

public void requestInitialData(java.lang.String dbWatcherSessionId,
                               boolean onlyRegister)
                        throws java.lang.Exception
Sends a PtP message to the responsible for the initial update (which is the DbWatcher or an object running in the DbWatcher jvm) telling a new initial update has to be initiating.

Specified by:
requestInitialData in interface I_ReplSlave
Throws:
java.lang.Exception
See Also:
org.xmlBlaster.contrib.replication.I_ReplSlave#requestInitialData()

reactivateDestination

public void reactivateDestination(long minReplKey,
                                  long maxReplKey)
                           throws java.lang.Exception
Description copied from interface: I_ReplSlave
6 This is received by the DbWatcher jvm. If the maxReplKey != (minReplKey+1), then it means somebody has written into the database while operating, This could result in inconsistencies in cases transaction isolation can not be assured.

Specified by:
reactivateDestination in interface I_ReplSlave
Parameters:
minReplKey - the replication key taken before initiating the db side operation on the master.
maxReplKey - the replication key taken after initiating the db side operation on the master.
Throws:
java.lang.Exception
See Also:
org.xmlBlaster.contrib.replication.I_ReplSlave#reactivateDestination()

shutdown

public void shutdown()
Specified by:
shutdown in interface I_ContribPlugin
See Also:
org.xmlBlaster.contrib.dbwriter.I_ContribPlugin#shutdown()

check

public java.util.ArrayList check(java.util.List<org.xmlBlaster.util.queue.I_Entry> entries,
                                 org.xmlBlaster.util.queue.I_Queue queue)
                          throws java.lang.Exception
Specified by:
check in interface I_ReplSlave
Throws:
java.lang.Exception

getSqlResponse

public java.lang.String getSqlResponse()
Specified by:
getSqlResponse in interface ReplSlaveMBean
Returns:
Returns the sqlResponse.

setSqlResponse

public void setSqlResponse(java.lang.String sqlResponse)
Specified by:
setSqlResponse in interface I_ReplSlave
Parameters:
sqlResponse - The sqlResponse to set.

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

setDispatcher

public boolean setDispatcher(boolean status)
Specified by:
setDispatcher in interface I_ReplSlave

setDispatcher

public final boolean setDispatcher(boolean status,
                                   boolean doPersist)
                            throws java.lang.Exception
Specified by:
setDispatcher in interface I_ReplSlave
Throws:
java.lang.Exception

doContinue

public void doContinue(boolean doPersist)
                throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
org.xmlBlaster.contrib.replication.ReplSlaveMBean#doContinue()

doPause

public void doPause(boolean doPersist)
             throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
org.xmlBlaster.contrib.replication.ReplSlaveMBean#doPause()

handleException

public void handleException(java.lang.Throwable ex)
Description copied from interface: I_ReplSlave
Pauses the dispatcher. and sets the message.

Specified by:
handleException in interface I_ReplSlave

toggleActive

public boolean toggleActive()
                     throws java.lang.Exception
Toggles the dispatcher from active to inactive or vice versa. Returns the actual state.

Specified by:
toggleActive in interface ReplSlaveMBean
Returns:
the actual state.
Throws:
java.lang.Exception
See Also:
ReplSlaveMBean.toggleActive()

cancelInitialUpdate

public void cancelInitialUpdate(boolean async)
                         throws java.lang.Exception
TODO fix this since it potentially could delete request from other slaves since the DbWatcher is serving several slaves. Cancels an ongoing initialUpdate Request.

Specified by:
cancelInitialUpdate in interface I_ReplSlave
Throws:
java.lang.Exception

cancelInitialUpdate

public void cancelInitialUpdate()
                         throws java.lang.Exception
TODO fix this since it potentially could delete request from other slaves since the DbWatcher is serving several slaves. Cancels an ongoing initialUpdate Request.

Specified by:
cancelInitialUpdate in interface ReplSlaveMBean
Throws:
java.lang.Exception

clearQueue

public void clearQueue()
                throws java.lang.Exception
Specified by:
clearQueue in interface ReplSlaveMBean
Throws:
java.lang.Exception

removeQueueEntries

public long removeQueueEntries(long entries)
                        throws java.lang.Exception
Specified by:
removeQueueEntries in interface ReplSlaveMBean
Throws:
java.lang.Exception

kill

public void kill()
          throws java.lang.Exception
Specified by:
kill in interface ReplSlaveMBean
Throws:
java.lang.Exception

reInitiateReplication

public java.lang.String reInitiateReplication()
                                       throws java.lang.Exception
Specified by:
reInitiateReplication in interface ReplSlaveMBean
Throws:
java.lang.Exception

getReplPrefix

public java.lang.String getReplPrefix()
Specified by:
getReplPrefix in interface I_ReplSlave
Specified by:
getReplPrefix in interface ReplSlaveMBean

getReplPrefixGroup

public java.lang.String getReplPrefixGroup()
Specified by:
getReplPrefixGroup in interface ReplSlaveMBean

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface ReplSlaveMBean

isActive

public boolean isActive()
Convenience method enforced by the MBean which returns true if the dispatcher of the slave session is active, false otherwise.

Specified by:
isActive in interface ReplSlaveMBean

getQueueEntries

public long getQueueEntries()
Convenience method enforced by the MBean which returns the number of entries in the queue.

Specified by:
getQueueEntries in interface ReplSlaveMBean

isConnected

public boolean isConnected()
Convenience method enforced by the MBean which returns true if the real slave is connected or false otherwise.

Specified by:
isConnected in interface ReplSlaveMBean

isStalled

public boolean isStalled()
Convenience method enforced by the MBean which returns true if the connection to the real slave is stalled or false otherwise.


getSessionName

public java.lang.String getSessionName()
Specified by:
getSessionName in interface I_ReplSlave
Specified by:
getSessionName in interface ReplSlaveMBean

getLastMessage

public java.lang.String getLastMessage()
Specified by:
getLastMessage in interface ReplSlaveMBean

checkStatus

public void checkStatus()
Description copied from interface: I_ReplSlave
Checks on the backend data which has to be displayed on the MBean.

Specified by:
checkStatus in interface I_ReplSlave

postCheck

public void postCheck(org.xmlBlaster.util.MsgUnit[] processedMsgUnits)
               throws java.lang.Exception
Specified by:
postCheck in interface I_ReplSlave
Throws:
java.lang.Exception

getTransactionSeq

public long getTransactionSeq()
Specified by:
getTransactionSeq in interface ReplSlaveMBean

decompressQueueEntryContent

public static byte[] decompressQueueEntryContent(org.xmlBlaster.engine.queuemsg.ReferenceEntry entry)

dumpEntries

public java.lang.String dumpEntries(int maxNum,
                                    long maxSize,
                                    java.lang.String fileName)
Specified by:
dumpEntries in interface ReplSlaveMBean

dumpFirstEntry

public java.lang.String dumpFirstEntry()
Specified by:
dumpFirstEntry in interface ReplSlaveMBean

isCascading

public boolean isCascading()
Specified by:
isCascading in interface ReplSlaveMBean

getCascadedSessionName

public java.lang.String getCascadedSessionName()
Specified by:
getCascadedSessionName in interface ReplSlaveMBean

getCascadedQueueEntries

public long getCascadedQueueEntries()
Specified by:
getCascadedQueueEntries in interface ReplSlaveMBean

getCascadedTransactionSeq

public long getCascadedTransactionSeq()
Specified by:
getCascadedTransactionSeq in interface ReplSlaveMBean

getCascadedStatus

public java.lang.String getCascadedStatus()
Specified by:
getCascadedStatus in interface ReplSlaveMBean

isCascadedActive

public boolean isCascadedActive()
Specified by:
isCascadedActive in interface ReplSlaveMBean

isCascadedConnected

public boolean isCascadedConnected()
Specified by:
isCascadedConnected in interface ReplSlaveMBean

getCascadedVersion

public java.lang.String getCascadedVersion()
Specified by:
getCascadedVersion in interface ReplSlaveMBean

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getConnection

public java.lang.String getConnection()
Returns a string telling in which state the connection is. It can be stalled, connected or disconnected.

Specified by:
getConnection in interface ReplSlaveMBean
Returns:

getMasterConnection

public java.lang.String getMasterConnection()
Specified by:
getMasterConnection in interface ReplSlaveMBean

getCascadedConnection

public java.lang.String getCascadedConnection()
Specified by:
getCascadedConnection in interface ReplSlaveMBean

getCascadedMasterConnection

public java.lang.String getCascadedMasterConnection()
Specified by:
getCascadedMasterConnection in interface ReplSlaveMBean

incrementPtPEntries

public void incrementPtPEntries(long numOfTransactions)
Description copied from interface: I_ReplSlave
Increments the amount of entries in the ptp counter queue

Specified by:
incrementPtPEntries in interface I_ReplSlave

setCountSingleMsg

public void setCountSingleMsg(boolean countSingleMsg)
Specified by:
setCountSingleMsg in interface ReplSlaveMBean

isCountSingleMsg

public boolean isCountSingleMsg()
Specified by:
isCountSingleMsg in interface ReplSlaveMBean

getMaxNumOfEntries

public int getMaxNumOfEntries()
Specified by:
getMaxNumOfEntries in interface I_ReplSlave
Specified by:
getMaxNumOfEntries in interface ReplSlaveMBean

setMaxNumOfEntries

public void setMaxNumOfEntries(int maxNumOfEntries)
Sets the maximum number of entries to be sent in one single message. Entries means here the number of entries retrieved from the callback queue.

Specified by:
setMaxNumOfEntries in interface ReplSlaveMBean

onDeadLetter

public void onDeadLetter(java.util.Map qosClientProperties)
Description copied from interface: I_ReplSlave
Invoked by the ReplManagerPlugin when a deadMessage is published because an error

Specified by:
onDeadLetter in interface I_ReplSlave

xmlBlaster 2.2.0 contributions API

Copyright © 1999-2014 The xmlBlaster.org contributers.