Skip to content

Getting started and Examples

Santosh Patil edited this page Aug 20, 2014 · 47 revisions

This page is a quick introduction to get you started running your first Relay on Aesop. Also has details on more involved examples.

Aesop Examples

The examples that follow explore the various change propagation implementations of Aesop.

Example: Memory Relay in 5 minutes

This is the simplest example and requires no coding effort. Please refer to Maven Dependencies to setup the requisite repository location in your Maven build settings. The sample Memory Relay employs an Event producer that generates a series of events simulating fictitious data change events.

Follow these steps to setup and run your first Memory based Relay:

  • git clone aesop (ignore if done already)
  • Run mvn clean install in sample-memory-relay directory. This might take a while to download Aesop, Trooper and their dependencies from the various Maven repositories.
  • Start the Relay in sample-memory-relay directory:
java -cp "./target/sample-memory-relay-1.0.7-SNAPSHOT.jar:\
./target/lib/*" org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher \ 
./src/main/resources/external/bootstrap.xml
  • A successful start will display a message like below on the console:
*************************************************************************
 Trooper __
      __/  \         Runtime Nature : SERVER
   __/  \__/         Component Container : com.flipkart.aesop.runtime.spring.RelayRuntimeComponentContainer
  /  \__/  \         Startup Time : 2,771 ms
  \__/  \__/         Host Name: Regu.local
     \__/
*************************************************************************
18:28:20.899 [main] INFO  o.t.p.r.i.bootstrap.spring.Bootstrap - ** Trooper Bootstrap complete **
  • Point your browser to http://localhost:9090. You should see the Aesop relays console: Aesop relays console

The next step is to run a Consumer for this Memory based Relay. Do the following:

  • Run mvn clean install in sample-client directory. This might take a while to download Aesop, Trooper and their dependencies from the various Maven repositories.
  • Start the Consumer in sample-client directory:
java -cp "./target/sample-client-1.0.7-SNAPSHOT.jar:\
./target/lib/*" org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher \ 
./src/main/resources/external/bootstrap.xml
  • A successful start will display a message like below on the console:
*************************************************************************
 Trooper __
      __/  \         Runtime Nature : SERVER
   __/  \__/         Component Container : com.flipkart.aesop.runtime.spring.ClientRuntimeComponentContainer
  /  \__/  \         Startup Time : 2,278 ms
  \__/  \__/         Host Name: Regu.local
     \__/
*************************************************************************
17:23:46.443 [main] INFO  o.t.p.r.i.bootstrap.spring.Bootstrap - ** Trooper Bootstrap complete **
  • Now refresh the Aesop relays console at http://localhost:9090. You should see the newly registered localhost Consumer and the SCN of last consumed change event. The Metrics link in the dashboard shows live stats for event generation and consumption: Aesop Metrics

More Aesop Examples

This information is for more involved use cases of Aesop - for e.g. sourcing changes from a real database and applying it on downstream data sources.

Example : MySQL Relay

Follow these steps to run the MySql Relay:

  • This examples assumes a running MySql setup. It also assumes the user root with no password.
  • git clone aesop (ignore if done already)
  • Run mvn clean install in sample-mysql-relay directory. This might take a while to download Aesop, Trooper and their dependencies from the various Maven repositories.
  • A distribution directory will be created in the sample-mysql-relay directory. This directory is the distribution which contains the built sample.
  • Run the script create_person.sh present in distribution/sample-db directory. This will create the sample database, users, tables and data required for this sample to run.
  • Now run the script start.sh present in distribution directory.
  • Sample MySql relay will now start.
  • A successful start will display a message like below on the console:
01:36:07.548 [main] INFO  o.t.p.c.impl.logging.SLF4jLogWrapper.info 59 c.f.a.r.producer.MysqlEventProducer - Open Replicator has been started successfully for the file mysql-bin.000001
01:36:07.550 [main] INFO  c.l.d.c.c.netty.ServerContainer.start 372 c.l.d.c.c.netty.ServerContainer - Databus service started!
01:36:07.552 [binlog-parser-1] WARN  o.t.p.c.impl.logging.SLF4jLogWrapper.warn 77 c.f.a.r.p.e.OpenReplicationListener - Received Unsupported Event! FormatDescriptionEvent[header=BinlogEventV4HeaderImpl[timestamp=1406836599000,eventType=15,serverId=1,eventLength=116,nextPosition=120,flags=0,timestampOfReceipt=1406837167549],binlogVersion=4,serverVersion=5.6.16-log,createTimestamp=1406836599000,headerLength=19,eventTypes={56,13,0,8,0,18,0,4,4,4,4,18,0,0,92,0,4,26,8,0,0,0,8,8,8,2,0,0,0,10,10,10,25,25,0,0,-105,-47,-74,-20}]
01:36:07.553 [main] INFO  o.t.p.c.impl.logging.SLF4jLogWrapper.info 59 c.f.a.r.s.

Example : Avro Schema Generator

Follow these steps to generate schema using avro schema generator:

  • This examples assumes a running MySql setup. It also assumes the user root with no password.
  • git clone aesop (ignore if done already)
  • Run mvn clean install in sample-mysql-relay directory. This might take a while to download Aesop, Trooper and their dependencies from the various Maven repositories.
  • A distribution directory will be created in the sample-mysql-relay directory. This directory is the distribution which contains the built sample.
  • To display help about schema generator, execute following command
java -cp "lib/*" com.flipkart.aesop.avro.schemagenerator.main.SchemaGeneratorCli -help
  • Following command generates avro schema of all tables in database or_test and saves the .avro files of each table in a folder at path ~/Desktop/schema
java -cp "lib/*" com.flipkart.aesop.avro.schemagenerator.main.SchemaGeneratorCli -d or_test -f ~/Desktop/schema -v 1
  • Successful execution of command will print a lot of log messages on terminal followed by following success message:
**********************************************************************************

********* Written Schema to folder /Users/<username>/Desktop/schema ***********

**********************************************************************************