This commit is contained in:
Zoltan Haindrich 2024-05-21 14:18:55 +00:00
parent ba09e7d1de
commit 4595b0c128
6 changed files with 29 additions and 12 deletions

View File

@ -185,6 +185,7 @@ public class ExposedAsBrokerQueryComponentSupplierWrapper implements QueryCompon
overrideModules.addAll(ExposedAsBrokerQueryComponentSupplierWrapper.brokerModules()); overrideModules.addAll(ExposedAsBrokerQueryComponentSupplierWrapper.brokerModules());
overrideModules.add(new DiscovertModule()); overrideModules.add(new DiscovertModule());
builder.add(QuidemCaptureModule.class);
} }

View File

@ -99,7 +99,7 @@ public class Launcher
chk1(); chk1();
chkStatus(); chkStatus();
lifecycle.stop(); lifecycle.join();
} else { } else {
} }

View File

@ -29,6 +29,6 @@ public class QuidemCaptureModule implements Module
@Override @Override
public void configure(Binder binder) public void configure(Binder binder)
{ {
Jerseys.addResource(binder, QuidemCapture.class); Jerseys.addResource(binder, QuidemCaptureResource.class);
} }
} }

View File

@ -24,10 +24,12 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@Path("/quidem") import java.io.IOException;
public class QuidemCapture import java.io.PrintStream;
{
@Path("/quidem")
public class QuidemCaptureResource
{
private QuidemRecorder recorder = null; private QuidemRecorder recorder = null;
@GET @GET
@ -41,16 +43,16 @@ public class QuidemCapture
@GET @GET
@Path("/start") @Path("/start")
@Produces(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN)
public synchronized String getSome1() public synchronized String getSome1() throws IOException
{ {
stopIfRunning(); stopIfRunning();
start(); 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() private void stopIfRunning()

View File

@ -19,10 +19,16 @@
package org.apache.druid.quidem; package org.apache.druid.quidem;
import java.io.PrintStream;
public class QuidemRecorder implements AutoCloseable, DruidHook 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.SQL, this);
DruidHook.register(DruidHook.RESULTSET, this); DruidHook.register(DruidHook.RESULTSET, this);
} }
@ -37,6 +43,15 @@ public class QuidemRecorder implements AutoCloseable, DruidHook
@Override @Override
public <T> void dispatch1(HookKey<T> key, T object) public <T> void dispatch1(HookKey<T> 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;
}
} }
} }

View File

@ -104,5 +104,4 @@ public interface DruidHook
} }
} }
} }
} }