From 604910ceadd7ef9b4c0b5cdf87c51032ff16563c Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Thu, 20 Jun 2024 14:26:48 +0000 Subject: [PATCH] cleanup --- ...ExposedAsBrokerQueryComponentSupplierWrapper.java | 2 +- .../java/org/apache/druid/quidem/QuidemRecorder.java | 11 ++++++++++- .../org/apache/druid/quidem/LauncherSmokeTest.java | 6 ++---- .../org/apache/druid/sql/calcite/run/DruidHook.java | 12 ++++++------ .../druid/sql/calcite/SqlTestFrameworkConfig.java | 8 ++------ 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/quidem-it/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java b/quidem-it/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java index c727de32248..b7ae4b7decb 100644 --- a/quidem-it/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java +++ b/quidem-it/src/main/java/org/apache/druid/quidem/ExposedAsBrokerQueryComponentSupplierWrapper.java @@ -214,7 +214,7 @@ public class ExposedAsBrokerQueryComponentSupplierWrapper implements QueryCompon return delegate.getPlannerComponentSupplier(); } - public class BrokerTestModule extends AbstractModule + public static class BrokerTestModule extends AbstractModule { @Override protected void configure() diff --git a/quidem-it/src/main/java/org/apache/druid/quidem/QuidemRecorder.java b/quidem-it/src/main/java/org/apache/druid/quidem/QuidemRecorder.java index d87edc25089..f40a9f55e01 100644 --- a/quidem-it/src/main/java/org/apache/druid/quidem/QuidemRecorder.java +++ b/quidem-it/src/main/java/org/apache/druid/quidem/QuidemRecorder.java @@ -33,9 +33,11 @@ import java.util.Date; public class QuidemRecorder implements AutoCloseable, DruidHook { private PrintStream printStream; + private File file; public QuidemRecorder(URI quidemURI, File file) { + this.file = file; try { this.printStream = new PrintStream(new FileOutputStream(file), true, StandardCharsets.UTF_8.name()); } @@ -43,7 +45,7 @@ public class QuidemRecorder implements AutoCloseable, DruidHook throw new RuntimeException(e); } printStream.println("#started " + new Date()); - printStream.println("!use " + quidemURI.toString()); + printStream.println("!use " + quidemURI); printStream.println("!set outputformat mysql"); DruidHook.register(DruidHook.SQL, this); } @@ -64,4 +66,11 @@ public class QuidemRecorder implements AutoCloseable, DruidHook return; } } + + @Override + public String toString() + { + return "QuidemRecorder [file=" + file + "]"; + } + } diff --git a/quidem-it/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java b/quidem-it/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java index c00f72b7fe3..6402cd63e43 100644 --- a/quidem-it/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java +++ b/quidem-it/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java @@ -32,8 +32,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import java.io.IOException; - import static org.junit.Assert.assertEquals; public class LauncherSmokeTest @@ -54,7 +52,7 @@ public class LauncherSmokeTest } @Test - public void chkSelectFromFoo() throws IOException, InterruptedException + public void chkSelectFromFoo() throws Exception { CloseableHttpClient client = HttpClients.createDefault(); HttpPost request = new HttpPost("http://localhost:12345/druid/v2/sql"); @@ -65,7 +63,7 @@ public class LauncherSmokeTest } @Test - public void chkStatusWorks() throws IOException, InterruptedException + public void chkStatusWorks() throws Exception { CloseableHttpClient client = HttpClients.createDefault(); HttpGet request = new HttpGet("http://localhost:12345/status"); diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/run/DruidHook.java b/sql/src/main/java/org/apache/druid/sql/calcite/run/DruidHook.java index 8802ccdec97..1a1f8e09bfe 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/run/DruidHook.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/run/DruidHook.java @@ -30,7 +30,7 @@ import java.util.Objects; @FunctionalInterface public interface DruidHook { - static class HookKey + class HookKey { private String label; private Class type; @@ -65,14 +65,14 @@ public interface DruidHook } - public static final HookKey CONVERTED_PLAN = new HookKey<>("converted", RelNode.class); - public static final HookKey LOGICAL_PLAN = new HookKey<>("logicalPlan", RelNode.class); - public static final HookKey DRUID_PLAN = new HookKey<>("druidPlan", RelNode.class); - public static final HookKey SQL = new HookKey<>("sql", String.class); + final HookKey CONVERTED_PLAN = new HookKey<>("converted", RelNode.class); + final HookKey LOGICAL_PLAN = new HookKey<>("logicalPlan", RelNode.class); + final HookKey DRUID_PLAN = new HookKey<>("druidPlan", RelNode.class); + final HookKey SQL = new HookKey<>("sql", String.class); void invoke(HookKey key, T object); - static Map, List>> GLOBAL = new HashMap<>(); + Map, List>> GLOBAL = new HashMap<>(); static void register(HookKey label, DruidHook hook) { diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java b/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java index f2b529a2e6a..7880cea33e2 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java @@ -27,7 +27,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import com.google.inject.Module; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.topn.TopNQueryConfig; @@ -45,6 +44,7 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.reflections.Configuration; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; +import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; import org.reflections.util.FilterBuilder; @@ -356,16 +356,12 @@ public class SqlTestFrameworkConfig ConfigurationInstance(SqlTestFrameworkConfig config, QueryComponentSupplier testHost) { - Module[] modules = {}; SqlTestFramework.Builder builder = new SqlTestFramework.Builder(testHost) .withConfig(config) .catalogResolver(testHost.createCatalogResolver()) .minTopNThreshold(config.minTopNThreshold) .mergeBufferCount(config.numMergeBuffers) .withOverrideModule(config.resultCache.makeModule()); - for (Module m : modules) { - builder.withOverrideModule(m); - } framework = builder.build(); } @@ -515,7 +511,7 @@ public class SqlTestFrameworkConfig { Configuration cfg = new ConfigurationBuilder() .setScanners(new SubTypesScanner(true)) - .setUrls(org.reflections.util.ClasspathHelper.forJavaClassPath()) + .setUrls(ClasspathHelper.forJavaClassPath()) .filterInputsBy( new FilterBuilder() .includePackage(pkg)