mirror of https://github.com/apache/druid.git
fix style; emitter
This commit is contained in:
parent
a9952292f2
commit
e06e54631e
|
@ -77,7 +77,6 @@ import org.apache.druid.initialization.Log4jShutterDownerModule;
|
|||
import org.apache.druid.initialization.ServerInjectorBuilder;
|
||||
import org.apache.druid.initialization.TombstoneDataStorageModule;
|
||||
import org.apache.druid.java.util.common.io.Closer;
|
||||
import org.apache.druid.java.util.emitter.service.ServiceEmitter;
|
||||
import org.apache.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule;
|
||||
import org.apache.druid.query.QueryRunnerFactoryConglomerate;
|
||||
import org.apache.druid.query.QuerySegmentWalker;
|
||||
|
@ -96,6 +95,7 @@ import org.apache.druid.server.SpecificSegmentsQuerySegmentWalker;
|
|||
import org.apache.druid.server.SubqueryGuardrailHelper;
|
||||
import org.apache.druid.server.SubqueryGuardrailHelperProvider;
|
||||
import org.apache.druid.server.coordination.ServerType;
|
||||
import org.apache.druid.server.emitter.EmitterModule;
|
||||
import org.apache.druid.server.http.BrokerResource;
|
||||
import org.apache.druid.server.http.SelfDiscoveryResource;
|
||||
import org.apache.druid.server.initialization.AuthorizerMapperModule;
|
||||
|
@ -104,7 +104,6 @@ import org.apache.druid.server.initialization.jetty.JettyServerInitializer;
|
|||
import org.apache.druid.server.initialization.jetty.JettyServerModule;
|
||||
import org.apache.druid.server.log.NoopRequestLogger;
|
||||
import org.apache.druid.server.log.RequestLogger;
|
||||
import org.apache.druid.server.metrics.NoopServiceEmitter;
|
||||
import org.apache.druid.server.metrics.QueryCountStatsProvider;
|
||||
import org.apache.druid.server.metrics.SubqueryCountStatsProvider;
|
||||
import org.apache.druid.server.router.TieredBrokerConfig;
|
||||
|
@ -226,7 +225,6 @@ public class ExposedAsBrokerQueryComponentSupplierWrapper implements QueryCompon
|
|||
bind(String.class)
|
||||
.annotatedWith(DruidSchemaName.class)
|
||||
.toInstance(CalciteTests.DRUID_SCHEMA_NAME);
|
||||
bind(ServiceEmitter.class).to(NoopServiceEmitter.class);
|
||||
bind(QuerySchedulerProvider.class).in(LazySingleton.class);
|
||||
bind(CalciteRulesManager.class).toInstance(new CalciteRulesManager(ImmutableSet.of()));
|
||||
bind(CatalogResolver.class).toInstance(CatalogResolver.NULL_RESOLVER);
|
||||
|
@ -282,7 +280,7 @@ public class ExposedAsBrokerQueryComponentSupplierWrapper implements QueryCompon
|
|||
ExtensionsModule.SecondaryModule.class,
|
||||
new DruidAuthModule(),
|
||||
TLSCertificateCheckerModule.class,
|
||||
// EmitterModule.class,
|
||||
EmitterModule.class,
|
||||
HttpClientModule.global(),
|
||||
HttpClientModule.escalatedGlobal(),
|
||||
new HttpClientModule("druid.broker.http", Client.class, true),
|
||||
|
|
|
@ -27,8 +27,8 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.URI;
|
||||
|
||||
@Path("/quidem")
|
||||
|
@ -62,7 +62,10 @@ public class QuidemCaptureResource
|
|||
public synchronized String start() throws IOException
|
||||
{
|
||||
stopIfRunning();
|
||||
recorder = new QuidemRecorder(quidemURI, new PrintStream("/tmp/new.iq"));
|
||||
recorder = new QuidemRecorder(
|
||||
quidemURI,
|
||||
new FileOutputStream("/tmp/new.iq")
|
||||
);
|
||||
return recorder.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,16 +21,24 @@ package org.apache.druid.quidem;
|
|||
|
||||
import org.apache.druid.sql.calcite.run.DruidHook;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class QuidemRecorder implements AutoCloseable, DruidHook<String>
|
||||
{
|
||||
private PrintStream printStream;
|
||||
|
||||
public QuidemRecorder(URI quidemURI, PrintStream printStream)
|
||||
public QuidemRecorder(URI quidemURI, FileOutputStream fileOutputStream)
|
||||
{
|
||||
this.printStream = printStream;
|
||||
try {
|
||||
this.printStream = new PrintStream(fileOutputStream, true, StandardCharsets.UTF_8.name());
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
printStream.println("#started");
|
||||
printStream.println("!connect " + quidemURI.toString());
|
||||
DruidHook.register(DruidHook.SQL, this);
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
@FunctionalInterface
|
||||
|
||||
public interface DruidHook<T>
|
||||
{
|
||||
static class HookKey<T>
|
||||
|
@ -73,14 +72,14 @@ public interface DruidHook<T>
|
|||
|
||||
void invoke(HookKey<T> key, T object);
|
||||
|
||||
static Map<HookKey<?>, List<DruidHook>> GLOBAL = new HashMap<>();
|
||||
static Map<HookKey<?>, List<DruidHook<?>>> GLOBAL = new HashMap<>();
|
||||
|
||||
public static void register(HookKey<?> label, DruidHook hook)
|
||||
static void register(HookKey<?> label, DruidHook<?> hook)
|
||||
{
|
||||
GLOBAL.computeIfAbsent(label, k -> new ArrayList<>()).add(hook);
|
||||
}
|
||||
|
||||
public static void unregister(HookKey<?> key, DruidHook hook)
|
||||
static void unregister(HookKey<?> key, DruidHook<?> hook)
|
||||
{
|
||||
GLOBAL.get(key).remove(hook);
|
||||
}
|
||||
|
@ -100,7 +99,7 @@ public interface DruidHook<T>
|
|||
|
||||
public static <T> void dispatch(HookKey<T> key, T object)
|
||||
{
|
||||
List<DruidHook> hooks = GLOBAL.get(key);
|
||||
List<DruidHook<?>> hooks = GLOBAL.get(key);
|
||||
if (hooks != null) {
|
||||
for (DruidHook hook : hooks) {
|
||||
hook.invoke(key, object);
|
||||
|
|
Loading…
Reference in New Issue