xmlBlaster 2.2.0 contributions API

org.xmlBlaster.contrib.dbwatcher.detector
Class TimestampChangeDetector

java.lang.Object
  extended by org.xmlBlaster.contrib.dbwatcher.detector.TimestampChangeDetector
All Implemented Interfaces:
I_ChangeDetector, TimestampChangeDetectorMBean, org.xmlBlaster.util.I_ReplaceVariable

public class TimestampChangeDetector
extends java.lang.Object
implements I_ChangeDetector, TimestampChangeDetectorMBean, org.xmlBlaster.util.I_ReplaceVariable

Check the database and compare the change timestamp of a table to the previous one.

Configuration

Limitations

The nature of this plugin is based on a timestamp comparison, as such it does not detect DELETE changes of database rows, as this will not create a new timestamp. All other commands (CREATE, INSERT, UPDATE) will touch the timestamp and are therefor detected. Additionally a DROP is detected.

DB statement Reported change Comment
CREATE CREATE -
INSERT UPDATE SQL INSERT statement are reported as UPDATE
UPDATE UPDATE -
DELETE - Is not detected
DROP DROP see mom.eraseOnDrop configuration

Note that the previous timestamp value is hold in RAM only, after plugin restart it is lost and a complete set of data is send again.

Author:
Marcel Ruff, Michele Laghi

Field Summary
protected  java.lang.String changeCommand
           
protected  java.lang.String changeDetectStatement
           
protected  I_ChangeListener changeListener
           
protected  I_DataConverter dataConverter
           
protected  I_DbPool dbPool
           
protected  java.lang.String groupColName
           
protected  boolean ignoreExistingDataOnStartup
           
protected  I_Info info
           
protected  java.lang.String newTimestamp
           
protected  java.lang.String oldTimestamp
           
protected  boolean poolOwner
           
protected  java.lang.String queryMeatStatement
           
protected  boolean tableExists
           
protected  int timestampColNum
           
protected  java.lang.String tmpOldTimestamp
           
protected  boolean useGroupCol
           
 
Constructor Summary
TimestampChangeDetector()
           
 
Method Summary
 void activateDetection()
           
 int checkAgain(java.util.Map attrMap)
          Check the observed data for changes.
 java.lang.String get(java.lang.String key)
          Enforced by I_ReplaceVariable
 java.lang.String getChangeCommand()
           
 java.lang.String getChangeDetectStatement()
           
 java.lang.String getGroupColName()
           
 java.lang.String getNewTimestamp()
           
 java.lang.String getOldTimestamp()
           
 java.lang.String getQueryMeatStatement()
           
 int getTimestampColNum()
           
 void init(I_Info info, I_ChangeListener changeListener, I_DataConverter dataConverter)
          Needs to be called after construction.
 boolean isIgnoreDetection()
           
 boolean isIgnoreExistingDataOnStartup()
           
 boolean isPoolOwner()
           
 boolean isTableExists()
           
 boolean isUseGroupCol()
           
static java.lang.String modifyMinStrIfDate(java.lang.String in, long time)
           
 java.lang.String modifyMinStrIfDateWithPersistence(java.lang.String in, long time)
          Modifies a string if it contains the special token '${currentDate}'.
 void setChangeCommand(java.lang.String changeCommand)
           
 void setChangeDetectStatement(java.lang.String changeDetectStatement)
           
 void setGroupColName(java.lang.String groupColName)
           
 void setOldTimestamp(java.lang.String oldTimestamp)
           
 void setPoolOwner(boolean poolOwner)
           
 void setQueryMeatStatement(java.lang.String queryMeatStatement)
           
 void setTimestampColNum(int timestampColNum)
           
 void setUseGroupCol(boolean useGroupCol)
           
 void shutdown()
          Cleanup resources.
 void stopDetection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

info

protected I_Info info

changeListener

protected I_ChangeListener changeListener

dataConverter

protected I_DataConverter dataConverter

dbPool

protected I_DbPool dbPool

poolOwner

protected boolean poolOwner

changeDetectStatement

protected java.lang.String changeDetectStatement

timestampColNum

protected int timestampColNum

groupColName

protected java.lang.String groupColName

useGroupCol

protected boolean useGroupCol

tableExists

protected boolean tableExists

ignoreExistingDataOnStartup

protected boolean ignoreExistingDataOnStartup

changeCommand

protected java.lang.String changeCommand

oldTimestamp

protected java.lang.String oldTimestamp

tmpOldTimestamp

protected java.lang.String tmpOldTimestamp

newTimestamp

protected java.lang.String newTimestamp

queryMeatStatement

protected java.lang.String queryMeatStatement
Constructor Detail

TimestampChangeDetector

public TimestampChangeDetector()
Method Detail

modifyMinStrIfDateWithPersistence

public java.lang.String modifyMinStrIfDateWithPersistence(java.lang.String in,
                                                          long time)
                                                   throws java.lang.Exception
Modifies a string if it contains the special token '${currentDate}'. The correct syntax would be : ${currentDate}=yyyy-MM-dd HH:mm:ss.0 Note that spaces after the equality sign count. If you only specify ${currentDate} without equality Sign, then the current time returned as System.getCurrentTime() is returned. This method is made public for testing.

Parameters:
in -
Returns:
Throws:
java.lang.Exception

modifyMinStrIfDate

public static java.lang.String modifyMinStrIfDate(java.lang.String in,
                                                  long time)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

init

public void init(I_Info info,
                 I_ChangeListener changeListener,
                 I_DataConverter dataConverter)
          throws java.lang.Exception
Description copied from interface: I_ChangeDetector
Needs to be called after construction.

Specified by:
init in interface I_ChangeDetector
Parameters:
info -
changeListener -
dataConverter -
Throws:
java.lang.Exception
See Also:
I_ChangeDetector.init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter)

checkAgain

public int checkAgain(java.util.Map attrMap)
               throws java.lang.Exception
Check the observed data for changes.

Specified by:
checkAgain in interface I_ChangeDetector
Parameters:
attrMap - Currently "oldTimestamp" can be passed to force a specific scan
Returns:
true if the observed data has changed
Throws:
java.lang.Exception - Can be of any type
See Also:
I_ChangeDetector.checkAgain(java.util.Map)

shutdown

public void shutdown()
              throws java.lang.Exception
Description copied from interface: I_ChangeDetector
Cleanup resources.

Specified by:
shutdown in interface I_ChangeDetector
Throws:
java.lang.Exception - Can be of any type
See Also:
I_ChangeDetector.shutdown()

getChangeCommand

public java.lang.String getChangeCommand()
Specified by:
getChangeCommand in interface TimestampChangeDetectorMBean

getChangeDetectStatement

public java.lang.String getChangeDetectStatement()
Specified by:
getChangeDetectStatement in interface TimestampChangeDetectorMBean

getGroupColName

public java.lang.String getGroupColName()
Specified by:
getGroupColName in interface TimestampChangeDetectorMBean

getNewTimestamp

public java.lang.String getNewTimestamp()
Specified by:
getNewTimestamp in interface TimestampChangeDetectorMBean

getOldTimestamp

public java.lang.String getOldTimestamp()
Specified by:
getOldTimestamp in interface TimestampChangeDetectorMBean

getQueryMeatStatement

public java.lang.String getQueryMeatStatement()
Specified by:
getQueryMeatStatement in interface TimestampChangeDetectorMBean

getTimestampColNum

public int getTimestampColNum()
Specified by:
getTimestampColNum in interface TimestampChangeDetectorMBean

isIgnoreExistingDataOnStartup

public boolean isIgnoreExistingDataOnStartup()
Specified by:
isIgnoreExistingDataOnStartup in interface TimestampChangeDetectorMBean

isPoolOwner

public boolean isPoolOwner()
Specified by:
isPoolOwner in interface TimestampChangeDetectorMBean

isTableExists

public boolean isTableExists()
Specified by:
isTableExists in interface TimestampChangeDetectorMBean

isUseGroupCol

public boolean isUseGroupCol()
Specified by:
isUseGroupCol in interface TimestampChangeDetectorMBean

setChangeCommand

public void setChangeCommand(java.lang.String changeCommand)
Specified by:
setChangeCommand in interface TimestampChangeDetectorMBean

setChangeDetectStatement

public void setChangeDetectStatement(java.lang.String changeDetectStatement)
Specified by:
setChangeDetectStatement in interface TimestampChangeDetectorMBean

setGroupColName

public void setGroupColName(java.lang.String groupColName)
Specified by:
setGroupColName in interface TimestampChangeDetectorMBean

setOldTimestamp

public void setOldTimestamp(java.lang.String oldTimestamp)
Specified by:
setOldTimestamp in interface TimestampChangeDetectorMBean

setPoolOwner

public void setPoolOwner(boolean poolOwner)
Specified by:
setPoolOwner in interface TimestampChangeDetectorMBean

setQueryMeatStatement

public void setQueryMeatStatement(java.lang.String queryMeatStatement)
Specified by:
setQueryMeatStatement in interface TimestampChangeDetectorMBean

setTimestampColNum

public void setTimestampColNum(int timestampColNum)
Specified by:
setTimestampColNum in interface TimestampChangeDetectorMBean

setUseGroupCol

public void setUseGroupCol(boolean useGroupCol)
Specified by:
setUseGroupCol in interface TimestampChangeDetectorMBean

stopDetection

public void stopDetection()
Specified by:
stopDetection in interface TimestampChangeDetectorMBean

activateDetection

public void activateDetection()
Specified by:
activateDetection in interface TimestampChangeDetectorMBean

isIgnoreDetection

public boolean isIgnoreDetection()
Specified by:
isIgnoreDetection in interface TimestampChangeDetectorMBean

get

public java.lang.String get(java.lang.String key)
Enforced by I_ReplaceVariable

Specified by:
get in interface org.xmlBlaster.util.I_ReplaceVariable
Returns:
value

xmlBlaster 2.2.0 contributions API

Copyright © 1999-2014 The xmlBlaster.org contributers.