|
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.dbwatcher.detector.MD5ChangeDetector
public class MD5ChangeDetector
Check the database and compare the MD5 of the result set to the previous one.
Configuration:
If the table does not exist in the DB no event is triggered, if an empty table comes to existence an empty event with untouched topic name is triggered:
topic='db.change.event.${ICAO_ID}' <?xml version='1.0' encoding='UTF-8' ?> <sql> </sql>
Note that the previous MD5 values are hold in RAM only, after plugin restart they are lost and a complete set of data is send again.
DB statement | Reported change | Comment |
---|---|---|
CREATE | CREATE | - |
INSERT | INSERT | On multiple table entries for a changeDetector.groupColName the change is reported as UPDATE |
UPDATE | UPDATE | - |
DELETE | DELETE | - |
DROP | DROP | see mom.eraseOnDrop configuration |
Field Summary | |
---|---|
protected int |
changeCount
|
protected java.lang.String |
changeDetectStatement
|
protected I_ChangeListener |
changeListener
|
protected I_DataConverter |
dataConverter
|
protected I_DbPool |
dbPool
|
protected java.security.MessageDigest |
digest
|
protected java.lang.String |
groupColName
|
protected I_Info |
info
|
private static java.util.logging.Logger |
log
|
protected java.util.Map |
md5Map
|
protected boolean |
poolOwner
|
protected java.lang.String |
queryMeatStatement
|
protected boolean |
tableExists
|
protected java.util.Set |
touchSet
|
protected boolean |
useGroupCol
|
Constructor Summary | |
---|---|
MD5ChangeDetector()
Default constructor, you need to call init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter) thereafter. |
|
MD5ChangeDetector(I_Info info,
I_ChangeListener changeListener,
I_DataConverter dataConverter)
Convenience constructor which calls init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter) . |
Method Summary | |
---|---|
int |
checkAgain(java.util.Map attrMap)
Check the observed data for changes. |
private int |
checkComplete(java.sql.Connection conn,
java.sql.ResultSet rs)
The select statement contains no grouping. |
private int |
checkWithGroupCol(java.sql.Connection conn,
java.sql.ResultSet rs)
The select statement with grouping. |
private java.lang.String |
getMD5(java.lang.String value)
Calculate the MD5 value. |
void |
init(I_Info info,
I_ChangeListener changeListener,
I_DataConverter dataConverter)
Needs to be called after construction. |
void |
shutdown()
Cleanup resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.util.logging.Logger log
protected I_Info info
protected I_ChangeListener changeListener
protected I_DataConverter dataConverter
protected I_DbPool dbPool
protected boolean poolOwner
protected boolean tableExists
protected java.security.MessageDigest digest
protected final java.util.Map md5Map
protected final java.util.Set touchSet
protected java.lang.String changeDetectStatement
protected java.lang.String groupColName
protected boolean useGroupCol
protected int changeCount
protected java.lang.String queryMeatStatement
Constructor Detail |
---|
public MD5ChangeDetector()
init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter)
thereafter.
public MD5ChangeDetector(I_Info info, I_ChangeListener changeListener, I_DataConverter dataConverter) throws java.lang.Exception
init(org.xmlBlaster.contrib.I_Info, org.xmlBlaster.contrib.dbwatcher.I_ChangeListener, org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter)
.
info
- The configuration environmentchangeListener
- The listener to notify if something has changeddataConverter
- A converter or null
java.lang.Exception
Method Detail |
---|
public void init(I_Info info, I_ChangeListener changeListener, I_DataConverter dataConverter) throws java.lang.Exception
init
in interface I_ChangeDetector
info
- The configurationchangeListener
- The listener to notify if something has changeddataConverter
- If not null the data will be transformed immediately during change detection
java.lang.Exception
public int checkAgain(java.util.Map attrMap) throws java.lang.Exception
checkAgain
in interface I_ChangeDetector
attrMap
- This map can be null. The event source can transport
some specific information to help the changeDetector doing its work
efficiently.
java.lang.Exception
- Can be of any typeI_ChangeDetector.checkAgain(Map)
private int checkComplete(java.sql.Connection conn, java.sql.ResultSet rs) throws java.lang.Exception
rs
- The JDBC query result
java.lang.Exception
- of any typeprivate int checkWithGroupCol(java.sql.Connection conn, java.sql.ResultSet rs) throws java.lang.Exception
"CREATE" and "DROP" are reliable, all other changes "UPDATE", "INSERT" and "DELETE" are guessed and not reliable.
Note that for each removed groupColValue a "DROP" is issued even so the table still may exist.
rs
- The JDBC query result
java.lang.Exception
- of any typeprivate java.lang.String getMD5(java.lang.String value)
value
- The accumulated string to check
public void shutdown() throws java.lang.Exception
I_ChangeDetector
shutdown
in interface I_ChangeDetector
java.lang.Exception
- Typicall XmlBlasterExceptionorg.xmlBlaster.contrib.dbwatcher.db.I_DbPool#shutdown
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |