From 4e3de4c56d17fd56333c9c032a1d94f94c771a30 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 5 Sep 2016 07:06:51 +0300 Subject: [PATCH] Rename and relocate CDC Python examples Moved the CDC example scripts into the protocol directory and added the .py suffix. Fixed all references to these scripts. --- Documentation/Protocols/CDC.md | 5 +++++ Documentation/Protocols/CDC_users.md | 5 ++--- Documentation/Routers/Avrorouter.md | 22 +++++++++---------- server/modules/protocol/CMakeLists.txt | 1 + .../modules/protocol/examples/CMakeLists.txt | 5 +++++ .../avro/cdc => protocol/examples/cdc.py} | 0 .../examples/cdc_kafka_producer.py} | 0 .../examples/cdc_last_transaction.py} | 0 .../avro => protocol/examples}/cdc_schema.go | 0 .../examples/cdc_users.py} | 0 server/modules/routing/avro/CMakeLists.txt | 5 ----- 11 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 server/modules/protocol/examples/CMakeLists.txt rename server/modules/{routing/avro/cdc => protocol/examples/cdc.py} (100%) rename server/modules/{routing/avro/cdc_kafka_producer => protocol/examples/cdc_kafka_producer.py} (100%) rename server/modules/{routing/avro/cdc_last_transaction => protocol/examples/cdc_last_transaction.py} (100%) rename server/modules/{routing/avro => protocol/examples}/cdc_schema.go (100%) rename server/modules/{routing/avro/cdc_users => protocol/examples/cdc_users.py} (100%) diff --git a/Documentation/Protocols/CDC.md b/Documentation/Protocols/CDC.md index 45cbe26f4..a20cf0e1c 100644 --- a/Documentation/Protocols/CDC.md +++ b/Documentation/Protocols/CDC.md @@ -125,3 +125,8 @@ Example: ``` QUERY-TRANSACTION 0-14-1245 ``` + +## Example Client + +MaxScale includes an example CDC client application written in Python 3. You can +find the source code for it [in the MaxScale repository](https://github.com/mariadb-corporation/MaxScale/tree/2.0/server/modules/protocol/examples/cdc.py). diff --git a/Documentation/Protocols/CDC_users.md b/Documentation/Protocols/CDC_users.md index bd9b25eec..2272885dd 100644 --- a/Documentation/Protocols/CDC_users.md +++ b/Documentation/Protocols/CDC_users.md @@ -21,16 +21,15 @@ password=cdc_password ## Creating new CDC users ``` -bash$ cdc_users [-h] USER PASSWORD +bash$ cdc_users.py [-h] USER PASSWORD ``` The output of this command should be appended to the _cdcusers_ file at `/var/lib/maxscale//`. ``` -bash$ cdc_users user1 pass1 >> /var/lib/maxscale/avro-service/cdcusers +bash$ cdc_users.py user1 pass1 >> /var/lib/maxscale/avro-service/cdcusers ``` Users can be deleted by removing the related rows in 'cdcusers' file. For more details on the format of the _cdcusers_ file, read the [CDC Protocol documentation](CDC.md). - diff --git a/Documentation/Routers/Avrorouter.md b/Documentation/Routers/Avrorouter.md index bc79731f7..f9e376ab7 100644 --- a/Documentation/Routers/Avrorouter.md +++ b/Documentation/Routers/Avrorouter.md @@ -152,16 +152,16 @@ conversion process, delete these two files and restart MaxScale. # Example Client -The avrorouter comes with an example client program, _cdc_, written in Python 3. +The avrorouter comes with an example client program, _cdc.py_, written in Python 3. This client can connect to a MaxScale configured with the CDC protocol and the avrorouter. Before using this client, you will need to install the Python 3 interpreter and -add users to the service with the _cdc_users_ script. Fore more details about +add users to the service with the _cdc_users.py_ script. Fore more details about the user creation, please refer to the [CDC Protocol](../Protocols/CDC.md) and [CDC Users](../Protocols/CDC_users.md) documentation. -Read the output of `cdc --help` for a full list of supported options +Read the output of `cdc.py --help` for a full list of supported options and a short usage description of the client program. # Avro Schema Generator @@ -206,27 +206,27 @@ protocol=CDC port=4001 ``` -Here is an example how you can query for data in JSON format using the _cdc_ Python script. +Here is an example how you can query for data in JSON format using the _cdc.py_ Python script. It queries the table _test.mytable_ for all change records. ``` -cdc --user=myuser --password=mypasswd --host=127.0.0.1 --port=4001 test.mytable +cdc.py --user=myuser --password=mypasswd --host=127.0.0.1 --port=4001 test.mytable ``` -You can then combine it with the _cdc_kafka_producer_ to publish these change records to a Kafka broker. +You can then combine it with the _cdc_kafka_producer.py_ to publish these change records to a Kafka broker. ``` -cdc --user=myuser --password=mypasswd --host=127.0.0.1 --port=4001 test.mytable | cdc_kafka_producer --kafka-broker 127.0.0.1:9092 --kafka-topic test.mytable +cdc.py --user=myuser --password=mypasswd --host=127.0.0.1 --port=4001 test.mytable | cdc_kafka_producer.py --kafka-broker 127.0.0.1:9092 --kafka-topic test.mytable ``` -For more information on how to use these scripts, see the output of `cdc -h` and `cdc_kafka_producer -h`. +For more information on how to use these scripts, see the output of `cdc.py -h` and `cdc_kafka_producer.py -h`. # Building Avrorouter To build the avrorouter from source, you will need the [Avro C](https://avro.apache.org/docs/current/api/c/) -library, liblzma and sqlite3 development headers. When configuring MaxScale with -CMake, you will need to add `-DBUILD_AVRO=Y -DBUILD_CDC=Y` to build the -avrorouter and the CDC protocol module. +library, liblzma, [the Jansson library](http://www.digip.org/jansson/) and sqlite3 development headers. When +configuring MaxScale with CMake, you will need to add `-DBUILD_AVRO=Y +-DBUILD_CDC=Y` to build the avrorouter and the CDC protocol module. For more details about building MaxScale from source, please refer to the [Building MaxScale from Source Code](../Getting-Started/Building-MaxScale-from-Source-Code.md) document. diff --git a/server/modules/protocol/CMakeLists.txt b/server/modules/protocol/CMakeLists.txt index ff8f765ec..e7da598bd 100644 --- a/server/modules/protocol/CMakeLists.txt +++ b/server/modules/protocol/CMakeLists.txt @@ -34,4 +34,5 @@ if(BUILD_CDC) target_link_libraries(CDC maxscale-common) set_target_properties(CDC PROPERTIES VERSION "1.0.1") install(TARGETS CDC DESTINATION ${MAXSCALE_LIBDIR}) + add_subdirectory(examples) endif() diff --git a/server/modules/protocol/examples/CMakeLists.txt b/server/modules/protocol/examples/CMakeLists.txt new file mode 100644 index 000000000..63ffb2ed4 --- /dev/null +++ b/server/modules/protocol/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +install(PROGRAMS cdc.py DESTINATION ${MAXSCALE_BINDIR}) +install(PROGRAMS cdc_users.py DESTINATION ${MAXSCALE_BINDIR}) +install(PROGRAMS cdc_last_transaction.py DESTINATION ${MAXSCALE_BINDIR}) +install(PROGRAMS cdc_kafka_producer.py DESTINATION ${MAXSCALE_BINDIR}) +install(FILES cdc_schema.go DESTINATION ${MAXSCALE_SHAREDIR}) diff --git a/server/modules/routing/avro/cdc b/server/modules/protocol/examples/cdc.py similarity index 100% rename from server/modules/routing/avro/cdc rename to server/modules/protocol/examples/cdc.py diff --git a/server/modules/routing/avro/cdc_kafka_producer b/server/modules/protocol/examples/cdc_kafka_producer.py similarity index 100% rename from server/modules/routing/avro/cdc_kafka_producer rename to server/modules/protocol/examples/cdc_kafka_producer.py diff --git a/server/modules/routing/avro/cdc_last_transaction b/server/modules/protocol/examples/cdc_last_transaction.py similarity index 100% rename from server/modules/routing/avro/cdc_last_transaction rename to server/modules/protocol/examples/cdc_last_transaction.py diff --git a/server/modules/routing/avro/cdc_schema.go b/server/modules/protocol/examples/cdc_schema.go similarity index 100% rename from server/modules/routing/avro/cdc_schema.go rename to server/modules/protocol/examples/cdc_schema.go diff --git a/server/modules/routing/avro/cdc_users b/server/modules/protocol/examples/cdc_users.py similarity index 100% rename from server/modules/routing/avro/cdc_users rename to server/modules/protocol/examples/cdc_users.py diff --git a/server/modules/routing/avro/CMakeLists.txt b/server/modules/routing/avro/CMakeLists.txt index 379045ece..b793795f2 100644 --- a/server/modules/routing/avro/CMakeLists.txt +++ b/server/modules/routing/avro/CMakeLists.txt @@ -5,11 +5,6 @@ if(AVRO_FOUND) set_target_properties(avrorouter PROPERTIES LINK_FLAGS -Wl,-z,defs) target_link_libraries(avrorouter maxscale-common jansson ${AVRO_LIBRARIES} maxavro sqlite3 lzma) install(TARGETS avrorouter DESTINATION ${MAXSCALE_LIBDIR}) - install(PROGRAMS cdc DESTINATION ${MAXSCALE_BINDIR}) - install(PROGRAMS cdc_users DESTINATION ${MAXSCALE_BINDIR}) - install(PROGRAMS cdc_last_transaction DESTINATION ${MAXSCALE_BINDIR}) - install(PROGRAMS cdc_kafka_producer DESTINATION ${MAXSCALE_BINDIR}) - install(FILES cdc_schema.go DESTINATION ${MAXSCALE_SHAREDIR}) else() message(STATUS "Avro C libraries were not found, avrorouter will not be built.") endif()