From 3fc03734bffd3d86d7f85345f7bb6e0242a9c542 Mon Sep 17 00:00:00 2001 From: Chris Sandison Date: Fri, 16 Feb 2024 15:04:36 -0500 Subject: [PATCH 01/18] platform/6278: Adding in listener --- .idea/vcs.xml | 6 ++++++ build.gradle | 1 - copy.sh | 5 +++++ .../trino/eventlistener/QueryListener.java | 5 ++++- .../eventlistener/QueryListenerConfig.java | 20 +++++++++++++++++++ .../eventlistener/QueryListenerFactory.java | 19 ++++++++++++++++++ 6 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml create mode 100755 copy.sh create mode 100644 src/main/java/com/tdw/trino/eventlistener/QueryListenerConfig.java create mode 100644 src/main/java/com/tdw/trino/eventlistener/QueryListenerFactory.java diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 09faaa6..4e7c27c 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,6 @@ buildscript { apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'java' - def version = '1.0.0' // Output to build/libs/shadow.jar diff --git a/copy.sh b/copy.sh new file mode 100755 index 0000000..27e02a8 --- /dev/null +++ b/copy.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Deploying trino-event-listener plugin" +rm -rf ../tdw-catalog-platform/tools/shared-services/docker/trino_event_listeners/platform/trino-event-lsitener +cp ./build/trino-event-listener.jar ../tdw-catalog-platform/tools/shared-services/docker/trino_event_listeners/platform \ No newline at end of file diff --git a/src/main/java/com/tdw/trino/eventlistener/QueryListener.java b/src/main/java/com/tdw/trino/eventlistener/QueryListener.java index 6790fce..a1a8fc9 100644 --- a/src/main/java/com/tdw/trino/eventlistener/QueryListener.java +++ b/src/main/java/com/tdw/trino/eventlistener/QueryListener.java @@ -7,7 +7,10 @@ public class QueryListener implements EventListener { private static final Logger LOGGER = LogManager.getLogger(QueryListener.class); - public QueryListener() { + private final QueryListenerConfig config; + + public QueryListener(QueryListenerConfig config) { + this.config = config; } @Override diff --git a/src/main/java/com/tdw/trino/eventlistener/QueryListenerConfig.java b/src/main/java/com/tdw/trino/eventlistener/QueryListenerConfig.java new file mode 100644 index 0000000..20ee006 --- /dev/null +++ b/src/main/java/com/tdw/trino/eventlistener/QueryListenerConfig.java @@ -0,0 +1,20 @@ +package com.tdw.trino.eventlistener; + +import java.util.Map; + +public class QueryListenerConfig { + // TODO require not null on url + + private String rabbitMQUrl; + + private static final String RABBIT_MQ_SERVER_URL = "rabbit-mq-server-url"; + + public QueryListenerConfig(String rabbitMQUrl) { + this.rabbitMQUrl = rabbitMQUrl; + } + + public static QueryListenerConfig create(Map config) { + return new QueryListenerConfig(config.get(RABBIT_MQ_SERVER_URL)); + } + +} diff --git a/src/main/java/com/tdw/trino/eventlistener/QueryListenerFactory.java b/src/main/java/com/tdw/trino/eventlistener/QueryListenerFactory.java new file mode 100644 index 0000000..bc13226 --- /dev/null +++ b/src/main/java/com/tdw/trino/eventlistener/QueryListenerFactory.java @@ -0,0 +1,19 @@ +package com.tdw.trino.eventlistener; + +import io.trino.spi.eventlistener.EventListener; +import io.trino.spi.eventlistener.EventListenerFactory; + +import java.util.Map; + +public class QueryListenerFactory implements EventListenerFactory { + @Override + public String getName() { + return "tdwplatform"; + } + + @Override + public EventListener create(Map config) { + var listenerConfig = QueryListenerConfig.create(config); + return new QueryListener(listenerConfig); + } +} From 0c39a53fdf70434187caf743a5c135164d4b3963 Mon Sep 17 00:00:00 2001 From: Chris Sandison Date: Tue, 20 Feb 2024 10:04:18 -0500 Subject: [PATCH 02/18] platform/6278: Adding in base classes --- .idea/.name | 1 + .idea/gradle.xml | 1 + Dockerfile | 4 +-- build.gradle | 2 +- build.sh | 10 +++--- copy.sh | 6 ++-- settings.gradle | 2 +- .../trino/eventlistener/QueryListener.java | 20 ----------- .../eventlistener/QueryListenerConfig.java | 20 ----------- .../eventlistener/RabbitmqEventListener.java | 33 +++++++++++++++++++ .../RabbitmqEventListenerConfig.java | 20 +++++++++++ ...java => RabbitmqEventListenerFactory.java} | 8 ++--- .../RabbitmqEventListenerPlugin.java | 13 ++++++++ 13 files changed, 84 insertions(+), 56 deletions(-) create mode 100644 .idea/.name delete mode 100644 src/main/java/com/tdw/trino/eventlistener/QueryListener.java delete mode 100644 src/main/java/com/tdw/trino/eventlistener/QueryListenerConfig.java create mode 100644 src/main/java/com/tdw/trino/eventlistener/RabbitmqEventListener.java create mode 100644 src/main/java/com/tdw/trino/eventlistener/RabbitmqEventListenerConfig.java rename src/main/java/com/tdw/trino/eventlistener/{QueryListenerFactory.java => RabbitmqEventListenerFactory.java} (56%) create mode 100644 src/main/java/com/tdw/trino/eventlistener/RabbitmqEventListenerPlugin.java diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..6ebcf4b --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +trino-event-listener \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 509e2ba..6497cda 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,5 +1,6 @@ +