xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.replication
Class ReplicationAgent

java.lang.Object
  extended by org.xmlBlaster.contrib.replication.ReplicationAgent
All Implemented Interfaces:
I_InitialUpdateListener

public class ReplicationAgent
extends java.lang.Object
implements I_InitialUpdateListener

Test basic functionality.

To run most of the tests you need to have a database (for example Postgres).

The connection configuration (url, password etc.) is configured as JVM property or in #createTest(I_Info, Map) and #setUpDbPool(I_Info)

Author:
Michele Laghi

Nested Class Summary
 class ReplicationAgent.OwnGlobalInfo
           
 
Field Summary
private  java.lang.String[] cmdLineArgs
           
private  I_ChangeListener dbWatcher
           
private  DbWriter dbWriter
           
private  boolean hasDbWatcher
           
private static java.util.logging.Logger log
           
private  boolean running
           
private  java.lang.String slaveName
           
private  boolean stopWatcherOnIU
           
 
Fields inherited from interface org.xmlBlaster.contrib.replication.I_InitialUpdateListener
INITIAL_UPDATE_LISTENER_KEY
 
Constructor Summary
ReplicationAgent()
          Default ctor.
 
Method Summary
private  GlobalInfo createOwnGlobalInfo(Global global, I_Info additionalInfo, java.lang.String infoId)
           
private  I_Info createReaderInfo(GlobalInfo cfgInfo)
           
 I_Info createWriterInfo(GlobalInfo cfgInfo)
           
private  void displayHelp(I_Info readerInfo, I_Info writerInfo)
           
private  boolean fillInfoWithCommandLine(java.lang.String[] args, GlobalInfo cfgInfo)
           
private static java.util.Map getCommonDefaultMap(I_Info subInfo)
           
 I_ChangeListener getDbWatcher()
           
 DbWriter getDbWriter()
           
private static java.io.InputStream getFileFromClasspath(java.lang.String filename)
           
private static java.util.Map getReaderDefaultMap(I_Info readerInfo)
           
private static java.util.Map getWriterDefaultMap(I_Info writerInfo)
           
 void init(I_Info readerInfo, I_Info writerInfo)
          Initializes the necessary stuff (encapsulated DbWatcher and DbWriter) and starts the DbWriter.
private static DbWatcher initializeDbWatcher(I_Info readerInfo, DbWriter dbWriter)
           
 boolean isRunning()
           
static void main(java.lang.String[] args)
          Keys are the info objects and values are maps containing the used properties as key/value pairs.
private static boolean needsHelp(java.lang.String[] args)
           
 GlobalInfo prepare(java.lang.String[] args)
           
 void process(I_Info readerInfo, I_Info writerInfo)
           
 void registerForUpdates(I_Update registeredForUpdates)
           
private static void showSubHelp(I_Info info, java.util.Map defaultMap, java.io.PrintStream out)
           
 void shutdown()
           
private  void shutdownDbWatcher()
           
private  void startDbWatcher(I_Info readerInfo)
           
 void startInitialUpdate()
           
 void stopInitialUpdate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

dbWatcher

private I_ChangeListener dbWatcher

dbWriter

private DbWriter dbWriter

slaveName

private java.lang.String slaveName

cmdLineArgs

private java.lang.String[] cmdLineArgs

hasDbWatcher

private boolean hasDbWatcher

stopWatcherOnIU

private boolean stopWatcherOnIU

running

private boolean running
Constructor Detail

ReplicationAgent

public ReplicationAgent()
Default ctor.

Method Detail

createOwnGlobalInfo

private GlobalInfo createOwnGlobalInfo(Global global,
                                       I_Info additionalInfo,
                                       java.lang.String infoId)
                                throws java.lang.Exception
Throws:
java.lang.Exception

prepare

public GlobalInfo prepare(java.lang.String[] args)
                   throws java.lang.Exception
Throws:
java.lang.Exception

isRunning

public boolean isRunning()

main

public static void main(java.lang.String[] args)
Keys are the info objects and values are maps containing the used properties as key/value pairs.


getDbWatcher

public I_ChangeListener getDbWatcher()

getDbWriter

public DbWriter getDbWriter()

getCommonDefaultMap

private static final java.util.Map getCommonDefaultMap(I_Info subInfo)

getReaderDefaultMap

private static final java.util.Map getReaderDefaultMap(I_Info readerInfo)

getWriterDefaultMap

private static final java.util.Map getWriterDefaultMap(I_Info writerInfo)

showSubHelp

private static final void showSubHelp(I_Info info,
                                      java.util.Map defaultMap,
                                      java.io.PrintStream out)

createReaderInfo

private I_Info createReaderInfo(GlobalInfo cfgInfo)
                         throws java.lang.Exception
Throws:
java.lang.Exception

createWriterInfo

public I_Info createWriterInfo(GlobalInfo cfgInfo)
                        throws java.lang.Exception
Throws:
java.lang.Exception

getFileFromClasspath

private static java.io.InputStream getFileFromClasspath(java.lang.String filename)
                                                 throws java.io.IOException
Throws:
java.io.IOException

startDbWatcher

private void startDbWatcher(I_Info readerInfo)
                     throws java.lang.Exception
Throws:
java.lang.Exception

init

public void init(I_Info readerInfo,
                 I_Info writerInfo)
          throws java.lang.Exception
Initializes the necessary stuff (encapsulated DbWatcher and DbWriter) and starts the DbWriter. Note that the DbWatcher is only started if used, i.e. if the readerInfo is not null.

Parameters:
readerInfo -
writerInfo -
Throws:
java.lang.Exception

startInitialUpdate

public void startInitialUpdate()
                        throws java.lang.Exception
Specified by:
startInitialUpdate in interface I_InitialUpdateListener
Throws:
java.lang.Exception

stopInitialUpdate

public void stopInitialUpdate()
                       throws java.lang.Exception
Specified by:
stopInitialUpdate in interface I_InitialUpdateListener
Throws:
java.lang.Exception

initializeDbWatcher

private static DbWatcher initializeDbWatcher(I_Info readerInfo,
                                             DbWriter dbWriter)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

shutdownDbWatcher

private final void shutdownDbWatcher()
                              throws java.lang.Exception
Throws:
java.lang.Exception

shutdown

public void shutdown()

needsHelp

private static boolean needsHelp(java.lang.String[] args)

fillInfoWithCommandLine

private boolean fillInfoWithCommandLine(java.lang.String[] args,
                                        GlobalInfo cfgInfo)

displayHelp

private void displayHelp(I_Info readerInfo,
                         I_Info writerInfo)
                  throws java.lang.Exception
Throws:
java.lang.Exception

process

public final void process(I_Info readerInfo,
                          I_Info writerInfo)
                   throws java.lang.Exception
Throws:
java.lang.Exception

registerForUpdates

public void registerForUpdates(I_Update registeredForUpdates)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.