Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vdesabou committed Dec 15, 2023
1 parent 783e8c8 commit 8c7099c
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions connect/connect-graphdb-sink/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip
14 changes: 14 additions & 0 deletions connect/connect-graphdb-sink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GraphDb sink connector

## Objective

Quickly test [kafka-sink-graphdb](https://github.com/Ontotext-AD/kafka-sink-graphdb/tree/main) connector using self-managed version.

## How to run


### No Authentication

```bash
$ playground run -f http-source-no-auth<use tab key to activate fzf completion (see https://kafka-docker-playground.io/#/cli?id=%e2%9a%a1-setup-completion), otherwise use full path, or correct relative path>
```
15 changes: 15 additions & 0 deletions connect/connect-graphdb-sink/docker-compose.plaintext.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
version: '3.5'
services:
graphdb:
image: ontotext/graphdb:10.2.0
hostname: graphdb
container_name: graphdb
ports:
- 7200:7200

connect:
environment:
#CONNECT_PLUGIN_PATH: /usr/share/confluent-hub-components/confluentinc-kafka-connect-http
CONNECT_PLUGIN_PATH: /usr/share/confluent-hub-components/ontotext-kafka-sink-graphdb

69 changes: 69 additions & 0 deletions connect/connect-graphdb-sink/graphdb-sink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

GRAPHDB_SINK_CONNECTOR_ZIP="kafka-sink-graphdb-plugin.zip"
export CONNECTOR_ZIP="$PWD/$GRAPHDB_SINK_CONNECTOR_ZIP"

source ${DIR}/../../scripts/utils.sh


get_3rdparty_file "$GRAPHDB_SINK_CONNECTOR_ZIP"

if [ ! -f ${PWD}/$GRAPHDB_SINK_CONNECTOR_ZIP ]
then
logerror "ERROR: ${PWD}/$GRAPHDB_SINK_CONNECTOR_ZIP is missing. You must be a Confluent Employee to run this example !"
exit 1
fi

function wait_service {
printf "waiting for $1"
until curl -s --fail -m 1 "$1" &> /dev/null; do
sleep 1
printf '.'
done
echo
}

function create_graphdb_repo {
if ! curl --fail -X GET --header 'Accept: application/json' http://localhost:7200/rest/repositories/test &> /dev/null; then
curl 'http://localhost:7200/rest/repositories' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{"id": "test", "params": {"imports": {"name": "imports", "label": "Imported RDF files('\'';'\'' delimited)", "value": ""}, "defaultNS": {"name": "defaultNS", "label": "Default namespaces for imports('\'';'\'' delimited)", "value": ""}}, "title": "", "type": "graphdb", "location": ""}'
fi
}


${DIR}/../../environment/plaintext/start.sh "${PWD}/docker-compose.plaintext.no-auth.yml"

wait_service 'http://localhost:7200/protocol'


log "Creating http-source connector"
playground connector create-or-update --connector http-source << EOF
{
"connector.class":"com.ontotext.kafka.GraphDBSinkConnector",
"key.converter": "com.ontotext.kafka.convert.DirectRDFConverter",
"value.converter": "com.ontotext.kafka.convert.DirectRDFConverter",
"value.converter.schemas.enable": "false",
"topics":"test",
"tasks.max":"1",
"_offset.storage.file.filename": "/tmp/storage",
"graphdb.server.url": "http://graphdb:7200",
"graphdb.server.repository": "test",
"graphdb.batch.size": 64,
"graphdb.batch.commit.limit.ms": 1000,
"graphdb.auth.type": "NONE",
"graphdb.update.type": "ADD",
"graphdb.update.rdf.format": "nq"
}
EOF

playground topic produce -t test --nb-messages 10 << 'EOF'
<urn:a> <urn:b> <urn:c> .
EOF



8 changes: 8 additions & 0 deletions connect/connect-graphdb-sink/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash



DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR}/../../scripts/utils.sh

stop_all "$DIR"

0 comments on commit 8c7099c

Please sign in to comment.