there - with 1 boot

This commit is contained in:
Zoltan Haindrich 2024-05-16 10:31:38 +00:00
parent 28ea884e19
commit 118eb61939
3 changed files with 43 additions and 10 deletions

View File

@ -34,6 +34,7 @@ import com.google.inject.name.Names;
import com.google.inject.util.Modules; import com.google.inject.util.Modules;
import org.apache.calcite.avatica.server.AbstractAvaticaHandler; import org.apache.calcite.avatica.server.AbstractAvaticaHandler;
import org.apache.druid.cli.CliBroker2; import org.apache.druid.cli.CliBroker2;
import org.apache.druid.cli.GuiceRunnable;
import org.apache.druid.curator.CuratorModule; import org.apache.druid.curator.CuratorModule;
import org.apache.druid.curator.discovery.DiscoveryModule; import org.apache.druid.curator.discovery.DiscoveryModule;
import org.apache.druid.guice.AnnouncerModule; import org.apache.druid.guice.AnnouncerModule;
@ -42,6 +43,7 @@ import org.apache.druid.guice.BrokerServiceModule;
import org.apache.druid.guice.CoordinatorDiscoveryModule; import org.apache.druid.guice.CoordinatorDiscoveryModule;
import org.apache.druid.guice.DruidInjectorBuilder; import org.apache.druid.guice.DruidInjectorBuilder;
import org.apache.druid.guice.ExpressionModule; import org.apache.druid.guice.ExpressionModule;
import org.apache.druid.guice.ExtensionsModule;
import org.apache.druid.guice.FirehoseModule; import org.apache.druid.guice.FirehoseModule;
import org.apache.druid.guice.JacksonConfigManagerModule; import org.apache.druid.guice.JacksonConfigManagerModule;
import org.apache.druid.guice.JavaScriptModule; import org.apache.druid.guice.JavaScriptModule;
@ -68,10 +70,13 @@ import org.apache.druid.guice.security.DruidAuthModule;
import org.apache.druid.initialization.CoreInjectorBuilder; import org.apache.druid.initialization.CoreInjectorBuilder;
import org.apache.druid.initialization.DruidModule; import org.apache.druid.initialization.DruidModule;
import org.apache.druid.initialization.Log4jShutterDownerModule; import org.apache.druid.initialization.Log4jShutterDownerModule;
import org.apache.druid.initialization.ServerInjectorBuilder;
import org.apache.druid.initialization.TombstoneDataStorageModule; import org.apache.druid.initialization.TombstoneDataStorageModule;
import org.apache.druid.java.util.common.FileUtils; import org.apache.druid.java.util.common.FileUtils;
import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.java.util.common.lifecycle.Lifecycle;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.emitter.service.ServiceEmitter;
import org.apache.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule; import org.apache.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule;
import org.apache.druid.query.DefaultQueryConfig; import org.apache.druid.query.DefaultQueryConfig;
@ -93,6 +98,7 @@ import org.apache.druid.server.metrics.NoopServiceEmitter;
import org.apache.druid.server.security.AuthenticatorMapper; import org.apache.druid.server.security.AuthenticatorMapper;
import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizerMapper;
import org.apache.druid.server.security.Escalator; import org.apache.druid.server.security.Escalator;
import org.apache.druid.server.security.TLSCertificateCheckerModule;
import org.apache.druid.sql.avatica.AvaticaMonitor; import org.apache.druid.sql.avatica.AvaticaMonitor;
import org.apache.druid.sql.avatica.DruidAvaticaJsonHandler; import org.apache.druid.sql.avatica.DruidAvaticaJsonHandler;
import org.apache.druid.sql.avatica.DruidMeta; import org.apache.druid.sql.avatica.DruidMeta;
@ -141,6 +147,7 @@ public class Launcher
public static final String DEFAULT_URI = URI_PREFIX + "/"; public static final String DEFAULT_URI = URI_PREFIX + "/";
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore(); static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore();
private static Logger log = new Logger(Launcher.class);
public Launcher() public Launcher()
{ {
@ -429,16 +436,22 @@ public class Launcher
} }
private static Module propOverrideModuel1() private static Module propOverrideModuel1()
{
Properties localProps = makeLocalProps();
Module m = binder -> binder.bind(Properties.class).toInstance(localProps);
return m;
}
private static Properties makeLocalProps()
{ {
Properties localProps = new Properties(); Properties localProps = new Properties();
localProps.put("druid.enableTlsPort", "false"); localProps.put("druid.enableTlsPort", "false");
localProps.put("druid.zk.service.enabled", "false"); localProps.put("druid.zk.service.enabled", "false");
localProps.put("druid.plaintextPort","12345"); localProps.put("druid.plaintextPort","12345");
localProps.put("druid.host", "localhost"); localProps.put("druid.host", "localhost");
return localProps;
Module m = binder -> binder.bind(Properties.class).toInstance(localProps);
return m;
} }
static class CustomStartupInjectorBuilder extends StartupInjectorBuilder { static class CustomStartupInjectorBuilder extends StartupInjectorBuilder {
@ -578,10 +591,12 @@ public class Launcher
// builder.addModule(new StorageNodeModule()); // builder.addModule(new StorageNodeModule());
// builder.addModules(new CliBroker2().getmodules2().toArray(new Module[0]));
builder.addModule( builder.addModule(
binder -> { binder -> {
// why need to add this?
// binder.bind(ResponseContextConfig.class).toInstance(ResponseContextConfig.newConfig(false));
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test"); binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0); binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1); binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
@ -607,12 +622,13 @@ public class Launcher
); );
if(true) { if(true) {
builder.addModules(
builder.add(
new Log4jShutterDownerModule(), new Log4jShutterDownerModule(),
new LifecycleModule(), new LifecycleModule(),
// ExtensionsModule.SecondaryModule.class, ExtensionsModule.SecondaryModule.class,
new DruidAuthModule(), new DruidAuthModule(),
// TLSCertificateCheckerModule.class, TLSCertificateCheckerModule.class,
// EmitterModule.class, // EmitterModule.class,
HttpClientModule.global(), HttpClientModule.global(),
HttpClientModule.escalatedGlobal(), HttpClientModule.escalatedGlobal(),
@ -647,7 +663,17 @@ public class Launcher
new ServiceClientModule(), new ServiceClientModule(),
new StorageConnectorModule() new StorageConnectorModule()
); );
// builder.addModules();
// builder.addModules(new CliBroker2().getmodules2().toArray(new Module[0]));
CliBroker2 cliBroker2 = new CliBroker2();
cliBroker2.configure(makeLocalProps(), null);
overrideModules.addAll(cliBroker2.getmodules2());
builder.add(ServerInjectorBuilder.registerNodeRoleModule(ImmutableSet.of()));
} }
} }
@Override @Override
@ -713,7 +739,10 @@ public class Launcher
// SSLContextProvider u = injector.getInstance(SSLContextProvider.class); // SSLContextProvider u = injector.getInstance(SSLContextProvider.class);
// System.out.println(u); // System.out.println(u);
if(true) {
Lifecycle lifecycle = GuiceRunnable.initLifecycle(framework.injector(), log);
lifecycle.join();
}else {
CliBroker2 c = new CliBroker2() { CliBroker2 c = new CliBroker2() {
protected List<? extends Module> getModules() { protected List<? extends Module> getModules() {
List<Module> ret = new ArrayList<>(); List<Module> ret = new ArrayList<>();
@ -735,6 +764,7 @@ public class Launcher
// c.configure(new Properties()); // c.configure(new Properties());
c.run2(); c.run2();
}
} }

View File

@ -198,7 +198,7 @@ public class CliBroker2 extends ServerRunnable
LifecycleModule.registerKey(binder, Key.get(SelfDiscoveryResource.class)); LifecycleModule.registerKey(binder, Key.get(SelfDiscoveryResource.class));
}, },
// new LookupModule(), // new LookupModule(),
new LookylooModule(), // new LookylooModule(),
new SqlModule() new SqlModule()
); );
} }

View File

@ -45,6 +45,9 @@ import java.util.List;
*/ */
public class LookylooModule implements DruidModule public class LookylooModule implements DruidModule
{ {
public LookylooModule() {
int asd1=1;
}
private static final String LOOKYLOO_INJECTIVE = "lookyloo121"; private static final String LOOKYLOO_INJECTIVE = "lookyloo121";
private static final String LOOKYLOO_CHAINED = "lookyloo-chain"; private static final String LOOKYLOO_CHAINED = "lookyloo-chain";