This commit is contained in:
Zoltan Haindrich 2024-06-17 13:05:11 +00:00
parent 7a65938fd6
commit 47696a6108
3 changed files with 31 additions and 3 deletions

View File

@ -19,6 +19,9 @@
package org.apache.druid.quidem;
import com.google.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@ -26,10 +29,19 @@ import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
@Path("/quidem")
public class QuidemCaptureResource
{
private URI quidemURI;
@Inject
public QuidemCaptureResource(@Named("quidem") URI quidemURI)
{
this.quidemURI = quidemURI;
}
private QuidemRecorder recorder = null;
@GET
@ -52,7 +64,7 @@ public class QuidemCaptureResource
private void start() throws IOException
{
recorder = new QuidemRecorder(new PrintStream("/tmp/new.iq"));
recorder = new QuidemRecorder(quidemURI, new PrintStream("/tmp/new.iq"));
}
private void stopIfRunning()

View File

@ -22,16 +22,17 @@ package org.apache.druid.quidem;
import org.apache.druid.sql.calcite.run.DruidHook;
import java.io.PrintStream;
import java.net.URI;
public class QuidemRecorder implements AutoCloseable, DruidHook<String>
{
private PrintStream printStream;
public QuidemRecorder(PrintStream printStream)
public QuidemRecorder(URI quidemURI, PrintStream printStream)
{
this.printStream = printStream;
printStream.println("#started");
printStream.println("!connect druidtest:///");
printStream.println("!connect " + quidemURI.toString());
DruidHook.register(DruidHook.SQL, this);
}

View File

@ -70,6 +70,8 @@ import org.apache.druid.sql.calcite.view.InProcessViewManager;
import org.apache.druid.sql.calcite.view.ViewManager;
import org.apache.druid.timeline.DataSegment;
import javax.inject.Named;
import java.io.Closeable;
import java.io.IOException;
import java.net.URI;
@ -628,6 +630,19 @@ public class SqlTestFramework
);
return rootSchema;
}
@Provides
SqlTestFrameworkConfig getTestConfig()
{
return builder.config;
}
@Provides
@Named("quidem")
public URI getDruidTestURI()
{
return getTestConfig().getDruidTestURI();
}
}
public static final DruidViewMacroFactory DRUID_VIEW_MACRO_FACTORY = new TestDruidViewMacroFactory();