Skip to content

Commit

Permalink
u[pdate
Browse files Browse the repository at this point in the history
  • Loading branch information
kgyrtkirk committed May 21, 2024
1 parent ba09e7d commit 4595b0c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public void configureGuice(CoreInjectorBuilder builder, List<Module> overrideMod

overrideModules.addAll(ExposedAsBrokerQueryComponentSupplierWrapper.brokerModules());
overrideModules.add(new DiscovertModule());
builder.add(QuidemCaptureModule.class);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static void main3(Object object) throws Exception
chk1();
chkStatus();

lifecycle.stop();
lifecycle.join();
} else {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import java.io.IOException;
import java.io.PrintStream;

@Path("/quidem")
public class QuidemCapture
public class QuidemCaptureResource
{

private QuidemRecorder recorder = null;

@GET
Expand All @@ -41,16 +43,16 @@ public String getSome()
@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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -37,6 +43,15 @@ public void close()
@Override
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;
}
}
}
1 change: 0 additions & 1 deletion sql/src/test/java/org/apache/druid/quidem/DruidHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,4 @@ public static <T> void dispatch(HookKey<T> key, T object)
}
}
}

}

0 comments on commit 4595b0c

Please sign in to comment.