You are here: Replication With VOD > Creating the Event Schema

Setup Event Processing

The replication system needs to know which objects have been changed in order to replicate these changes. To do so it uses VOD's event system. You need to setup the event processing and keep it running for this purpose.

Note: Replication with VOD requires at least VOD version 8.0.1.3 with JVI installed.

The Classpath

For the replication operations some additional libraries are required besides the JDO ones. This includes the db4o related libraries and additional VOD libraries.

From the VOD distribution

From the db4o / dRS distribution

Creating the Event Schema

The event processing needs special schema's to work correctly. Therefore you need to setup the event schema. You can do this by running the CreateEventSchema-class which does this for you. Pass the database name as argument to that class. You can execute this from the command line, where the classpath contains the libraries from above.

Windows:

java -classpath %CLASSPATH% com.db4o.drs.versant.eventprocessor.CreateEventSchema %DATABASE_NAME%

Unix/Linux:

java -classpath $CLASSPATH com.db4o.drs.versant.eventprocessor.CreateEventSchema $DATABASE_NAME

Running The Event Driver

The next step is to run the VOD event driver. The event driver is a small service application for processing database events. You need to keep the event driver running all the time when you're using replication. Without a running event driver modifications are not replicated. You need to create a configuration file for the event driver.

Windows config.ved.win:

ChannelServicePort	4000
LogFile eventdb.log
LogLevel 2
<EngineLibs>
vedse.dll
</EngineLibs>

Unix/Linux config.ved.linux:

ChannelServicePort	4000
LogFile eventdb.log
LogLevel 2
<EngineLibs>
libvedse.so
</EngineLibs>

With this configuration you can run the event driver. Execute the veddriver command where the first argument is the database name and the second argument is the configuration-file:

veddriver %DATABASE_NAME% %VED_CONFIGFILE%

When veddriver executable is in the 'bin'-subdirectory of your VOD installation.

Running The Event Processor

After the event driver is up and running we finally can start to process the events. This event processing is there to maintain additional meta-information for the replication process. Ensure that the event processor it always up and running. If it isn't running changes are not replicated.

The event processor is part of the db4o replication system. It's in the EventProcessorApplication-class. This class needs these parameters:

-database   The name of the database which is replicated
-server Optional The host name of the machine where the VOD event driver is running.This a optional parameter. If it's not specified it assumes that the event driver is running on the localhost.
-servertport   The port of the VOD event driver. It's the port specified in the event driver configuration. In this example it's 4000
-client Optional The VOD event driver contacts the event processor on certain events. With this parameter you specify the host-name on which the event processor runs. It this parameter is not set localhost will be used.
-clientport   The port which is used for the client. It can be any free port.
-eventProcessorPort   The port on which the event processor listens for replication processes. The replication process connects to this port.
-logfile   Specifies the log file.
-verbose Optional Enable the verbose messages

To start the event processor you can use this command. Use the classpath-variable refers to the classpath listed above.

Windows:

java -cp %CLASSPATH% com.db4o.drs.versant.eventprocessor.EventProcessorApplication -clientport 4100 -database %DATABASE_NAME% -eventProcessorPort 4088 -logfile %LOG_FILE% -serverport 4000

Linux:

java -cp $CLASSPATH com.db4o.drs.versant.eventprocessor.EventProcessorApplication -clientport 4100 -database $DATABASE_NAME -eventProcessorPort 4088 -logfile $LOG_FILE  -serverport 4000

Example Scripts

You can use scripts to do this tasks described above. Download the example scripts for Windows or Linux/Unix.

You need to adopt the setEnviroment-script to you environment. Specify the path where dRS and db4o jars are. Additionally it expects that the JAVA_HOME and the VERSANT_ROOT environment variables are set. The JAVA_HOME should point to your java-installation. The VERSANT_ROOT should point to the VOD installation directory.

Windows:

REM Specify the directory where the DRS and db4o jars are
REM This directory should contain the dRS distribution.
REM Or more specific it needs the dRS-X.XX-core.jar, 
REM db4o-X.XX-core-java5.jar or db4o-X.XX-core-java5.jar, commons-cli-1.2.jar
SET LIB_DIR=./lib

REM Specify the VOD database name
SET DATABASE_NAME=dRSVodExample

REM Set the directory where VOD is installed. For example "C:\Program Files\Versant\8"
SET VERSANT_ROOT=%VERSANT_ROOT%

REM This should work if the JAVA_HOME variable is set. 
REM Otherwise change the command to point to the java executatble or set the JAVA_HOME variable
SET JAVA=java
JAVA_HOME=$JAVA_HOME
setEnvironment.bat: The imporatent configuration items

Linux:

# Specify the directory where the DRS and db4o jars are
# This directory should contain the dRS distribution.
# Or more specific it needs the dRS-X.XX-core.jar, 
# db4o-X.XX-core-java5.jar or db4o-X.XX-core-java5.jar, commons-cli-1.2.jar
LIB_DIR=./lib

# Specify the VOD database name
DATABASE_NAME=dRSVodExample

# Set the directory where VOD is installed. For example "C:\Program Files\Versant\8"
VERSANT_ROOT=$VERSANT_ROOT

# This should work if the JAVA_HOME variable is set. 
# Otherwise change the command to point to the java executatble or set the JAVA_HOME variable
JAVA=java.exe
JAVA_HOME=$JAVA_HOME
setEnvironment.sh: The imporatent configuration items

After that you can use the provided scripts to do the steps above.

Start the Event Driver and Event Processor With Your Database

In a production environment the event driver and event processor have to run all the time. Therefore it makes sense to start up these two processes together with your database.

You can do this by adding startup entries to your database configuration.

First copy the scripts for starting the event processor to your VOD database directory. Edit the script so that it works from the new location. In the example scripts you probably have to change the directory where the libraries reside.

Second add two new configuration entries to the profile.be file:

event_daemon veddriver  the/path/to/config.ved.win
startup_script startEventProcessor.bat

Then restart the database. These configuration entries should ensure that the event driver and processor are started together with the VOD database.