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.
This commit is contained in:
Markus Makela
2016-09-05 07:06:51 +03:00
parent 741ba5e444
commit 4e3de4c56d
11 changed files with 24 additions and 19 deletions

View File

@ -125,3 +125,8 @@ Example:
``` ```
QUERY-TRANSACTION 0-14-1245 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).

View File

@ -21,16 +21,15 @@ password=cdc_password
## Creating new CDC users ## 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 The output of this command should be appended to the _cdcusers_ file at
`/var/lib/maxscale/<service name>/`. `/var/lib/maxscale/<service name>/`.
``` ```
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 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). more details on the format of the _cdcusers_ file, read the [CDC Protocol documentation](CDC.md).

View File

@ -152,16 +152,16 @@ conversion process, delete these two files and restart MaxScale.
# Example Client # 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 This client can connect to a MaxScale configured with the CDC protocol and the
avrorouter. avrorouter.
Before using this client, you will need to install the Python 3 interpreter and 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) the user creation, please refer to the [CDC Protocol](../Protocols/CDC.md)
and [CDC Users](../Protocols/CDC_users.md) documentation. 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. and a short usage description of the client program.
# Avro Schema Generator # Avro Schema Generator
@ -206,27 +206,27 @@ protocol=CDC
port=4001 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. 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 # Building Avrorouter
To build the avrorouter from source, you will need the [Avro C](https://avro.apache.org/docs/current/api/c/) 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 library, liblzma, [the Jansson library](http://www.digip.org/jansson/) and sqlite3 development headers. When
CMake, you will need to add `-DBUILD_AVRO=Y -DBUILD_CDC=Y` to build the configuring MaxScale with CMake, you will need to add `-DBUILD_AVRO=Y
avrorouter and the CDC protocol module. -DBUILD_CDC=Y` to build the avrorouter and the CDC protocol module.
For more details about building MaxScale from source, please refer to the 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. [Building MaxScale from Source Code](../Getting-Started/Building-MaxScale-from-Source-Code.md) document.

View File

@ -34,4 +34,5 @@ if(BUILD_CDC)
target_link_libraries(CDC maxscale-common) target_link_libraries(CDC maxscale-common)
set_target_properties(CDC PROPERTIES VERSION "1.0.1") set_target_properties(CDC PROPERTIES VERSION "1.0.1")
install(TARGETS CDC DESTINATION ${MAXSCALE_LIBDIR}) install(TARGETS CDC DESTINATION ${MAXSCALE_LIBDIR})
add_subdirectory(examples)
endif() endif()

View File

@ -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})

View File

@ -5,11 +5,6 @@ if(AVRO_FOUND)
set_target_properties(avrorouter PROPERTIES LINK_FLAGS -Wl,-z,defs) set_target_properties(avrorouter PROPERTIES LINK_FLAGS -Wl,-z,defs)
target_link_libraries(avrorouter maxscale-common jansson ${AVRO_LIBRARIES} maxavro sqlite3 lzma) target_link_libraries(avrorouter maxscale-common jansson ${AVRO_LIBRARIES} maxavro sqlite3 lzma)
install(TARGETS avrorouter DESTINATION ${MAXSCALE_LIBDIR}) 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() else()
message(STATUS "Avro C libraries were not found, avrorouter will not be built.") message(STATUS "Avro C libraries were not found, avrorouter will not be built.")
endif() endif()