From 4595b0c128ab12c6154874c9a4627f921ac33610 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Tue, 21 May 2024 14:18:55 +0000 Subject: [PATCH] u[pdate --- ...AsBrokerQueryComponentSupplierWrapper.java | 1 + .../org/apache/druid/quidem/Launcher.java | 2 +- .../druid/quidem/QuidemCaptureModule.java | 2 +- ...apture.java => QuidemCaptureResource.java} | 16 +++++++++------- .../apache/druid/quidem/QuidemRecorder.java | 19 +++++++++++++++++-- .../org/apache/druid/quidem/DruidHook.java | 1 - 6 files changed, 29 insertions(+), 12 deletions(-) rename integration-tests/src/main/java/org/apache/druid/quidem/{QuidemCapture.java => QuidemCaptureResource.java} (82%) diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java b/integration-tests/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java index 329c169aad7..17f30a7d82a 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java @@ -185,6 +185,7 @@ public class ExposedAsBrokerQueryComponentSupplierWrapper implements QueryCompon overrideModules.addAll(ExposedAsBrokerQueryComponentSupplierWrapper.brokerModules()); overrideModules.add(new DiscovertModule()); + builder.add(QuidemCaptureModule.class); } diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java index f63f2bfe9e2..951d59f809d 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java @@ -99,7 +99,7 @@ public class Launcher chk1(); chkStatus(); - lifecycle.stop(); + lifecycle.join(); } else { } diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureModule.java b/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureModule.java index f041bc286b5..17d9009994e 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureModule.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureModule.java @@ -29,6 +29,6 @@ public class QuidemCaptureModule implements Module @Override public void configure(Binder binder) { - Jerseys.addResource(binder, QuidemCapture.class); + Jerseys.addResource(binder, QuidemCaptureResource.class); } } diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCapture.java b/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureResource.java similarity index 82% rename from integration-tests/src/main/java/org/apache/druid/quidem/QuidemCapture.java rename to integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureResource.java index b9719922e04..ded57a3fccf 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCapture.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/QuidemCaptureResource.java @@ -24,10 +24,12 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -@Path("/quidem") -public class QuidemCapture -{ +import java.io.IOException; +import java.io.PrintStream; +@Path("/quidem") +public class QuidemCaptureResource +{ private QuidemRecorder recorder = null; @GET @@ -41,16 +43,16 @@ public class QuidemCapture @GET @Path("/start") @Produces(MediaType.TEXT_PLAIN) - public synchronized String getSome1() + public synchronized String getSome1() throws IOException { stopIfRunning(); start(); - return null; + return recorder.toString(); } - private void start() + private void start() throws IOException { - recorder = new QuidemRecorder(); + recorder = new QuidemRecorder(new PrintStream("/tmp/new.iq")); } private void stopIfRunning() diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/QuidemRecorder.java b/integration-tests/src/main/java/org/apache/druid/quidem/QuidemRecorder.java index 45659722cd0..9df46bd41e2 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/QuidemRecorder.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/QuidemRecorder.java @@ -19,10 +19,16 @@ package org.apache.druid.quidem; +import java.io.PrintStream; + public class QuidemRecorder implements AutoCloseable, DruidHook { - public QuidemRecorder() + private PrintStream printStream; + + public QuidemRecorder(PrintStream printStream) { + this.printStream = printStream; + printStream.println("#started"); DruidHook.register(DruidHook.SQL, this); DruidHook.register(DruidHook.RESULTSET, this); } @@ -37,6 +43,15 @@ public class QuidemRecorder implements AutoCloseable, DruidHook @Override public void dispatch1(HookKey key, T object) { - System.out.println(object); + if(DruidHook.SQL.equals(key)) { + printStream.println(object); + printStream.print(";"); + return; + } + if (DruidHook.RESULTSET.equals(key)) { + printStream.println(object); + printStream.println("!ok"); + return; + } } } diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidHook.java b/sql/src/test/java/org/apache/druid/quidem/DruidHook.java index d9686cb0581..d6322109c59 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidHook.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidHook.java @@ -104,5 +104,4 @@ public interface DruidHook } } } - }