mirror of https://github.com/apache/druid.git
This commit is contained in:
parent
074161dfde
commit
5f552a2997
|
@ -41,8 +41,14 @@ import org.apache.druid.discovery.DiscoveryDruidNode;
|
||||||
import org.apache.druid.discovery.DruidNodeDiscovery;
|
import org.apache.druid.discovery.DruidNodeDiscovery;
|
||||||
import org.apache.druid.discovery.DruidNodeDiscoveryProvider;
|
import org.apache.druid.discovery.DruidNodeDiscoveryProvider;
|
||||||
import org.apache.druid.discovery.NodeRole;
|
import org.apache.druid.discovery.NodeRole;
|
||||||
|
import org.apache.druid.guice.BrokerProcessingModule;
|
||||||
|
import org.apache.druid.guice.BrokerServiceModule;
|
||||||
import org.apache.druid.guice.DruidInjectorBuilder;
|
import org.apache.druid.guice.DruidInjectorBuilder;
|
||||||
|
import org.apache.druid.guice.JoinableFactoryModule;
|
||||||
import org.apache.druid.guice.LazySingleton;
|
import org.apache.druid.guice.LazySingleton;
|
||||||
|
import org.apache.druid.guice.LegacyBrokerParallelMergeConfigModule;
|
||||||
|
import org.apache.druid.guice.QueryRunnerFactoryModule;
|
||||||
|
import org.apache.druid.guice.SegmentWranglerModule;
|
||||||
import org.apache.druid.guice.StartupInjectorBuilder;
|
import org.apache.druid.guice.StartupInjectorBuilder;
|
||||||
import org.apache.druid.guice.annotations.Json;
|
import org.apache.druid.guice.annotations.Json;
|
||||||
import org.apache.druid.initialization.DruidModule;
|
import org.apache.druid.initialization.DruidModule;
|
||||||
|
@ -403,7 +409,7 @@ public class Launcher
|
||||||
@Test
|
@Test
|
||||||
public void runIt() throws Exception
|
public void runIt() throws Exception
|
||||||
{
|
{
|
||||||
Launcher.main1(null);
|
Launcher.main3(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Module propOverrideModuel()
|
private static Module propOverrideModuel()
|
||||||
|
@ -612,4 +618,175 @@ public class Launcher
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static ConfigurationInstance getCI2() throws SQLException, Exception
|
||||||
|
{
|
||||||
|
SqlTestFrameworkConfig config = buildConfigfromURIParams("druidtest:///");
|
||||||
|
|
||||||
|
ConfigurationInstance ci = CONFIG_STORE.getConfigurationInstance(
|
||||||
|
config,
|
||||||
|
x -> new AvaticaBasedTestConnectionSupplier2(x)
|
||||||
|
);
|
||||||
|
return ci;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class AvaticaBasedTestConnectionSupplier2 implements QueryComponentSupplier
|
||||||
|
{
|
||||||
|
private QueryComponentSupplier delegate;
|
||||||
|
private AvaticaBasedConnectionModule connectionModule;
|
||||||
|
|
||||||
|
public AvaticaBasedTestConnectionSupplier2(QueryComponentSupplier delegate)
|
||||||
|
{
|
||||||
|
this.delegate = delegate;
|
||||||
|
this.connectionModule = new AvaticaBasedConnectionModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gatherProperties(Properties properties)
|
||||||
|
{
|
||||||
|
delegate.gatherProperties(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureGuice(DruidInjectorBuilder builder)
|
||||||
|
{
|
||||||
|
delegate.configureGuice(builder);
|
||||||
|
TestRequestLogger testRequestLogger = new TestRequestLogger();
|
||||||
|
// builder.addModule(connectionModule);
|
||||||
|
|
||||||
|
builder.addModule(discoverModule());
|
||||||
|
builder.addModule(binder -> binder.bind(BrokerSegmentMetadataCache.class).toProvider(Providers.of(null)));
|
||||||
|
|
||||||
|
// builder.addModule(propOverrideModuel());
|
||||||
|
|
||||||
|
if(false) {
|
||||||
|
builder.addModule(new LegacyBrokerParallelMergeConfigModule());
|
||||||
|
builder.addModule(new BrokerProcessingModule());
|
||||||
|
// new QueryableModule(),
|
||||||
|
builder.addModule(new QueryRunnerFactoryModule());
|
||||||
|
builder.addModule(new SegmentWranglerModule());
|
||||||
|
builder.addModule(new JoinableFactoryModule());
|
||||||
|
builder.addModule(new BrokerServiceModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
// builder.addModule(new StorageNodeModule());
|
||||||
|
|
||||||
|
// builder.addModules(new CliBroker2().getmodules2().toArray(new Module[0]));
|
||||||
|
|
||||||
|
builder.addModule(
|
||||||
|
binder -> {
|
||||||
|
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test");
|
||||||
|
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
|
||||||
|
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
|
||||||
|
binder.bind(AuthenticatorMapper.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_MAPPER);
|
||||||
|
binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
|
||||||
|
binder.bind(Escalator.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR);
|
||||||
|
binder.bind(RequestLogger.class).toInstance(testRequestLogger);
|
||||||
|
binder.bind(String.class)
|
||||||
|
.annotatedWith(DruidSchemaName.class)
|
||||||
|
.toInstance(CalciteTests.DRUID_SCHEMA_NAME);
|
||||||
|
binder.bind(ServiceEmitter.class).to(NoopServiceEmitter.class);
|
||||||
|
binder.bind(QuerySchedulerProvider.class).in(LazySingleton.class);
|
||||||
|
binder.bind(QueryScheduler.class)
|
||||||
|
.toProvider(QuerySchedulerProvider.class)
|
||||||
|
.in(LazySingleton.class);
|
||||||
|
binder.install(new SqlModule.SqlStatementFactoryModule());
|
||||||
|
binder.bind(new TypeLiteral<Supplier<DefaultQueryConfig>>()
|
||||||
|
{
|
||||||
|
}).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(ImmutableMap.of())));
|
||||||
|
binder.bind(CalciteRulesManager.class).toInstance(new CalciteRulesManager(ImmutableSet.of()));
|
||||||
|
binder.bind(CatalogResolver.class).toInstance(CatalogResolver.NULL_RESOLVER);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryRunnerFactoryConglomerate createCongolmerate(Builder builder, Closer closer)
|
||||||
|
{
|
||||||
|
return delegate.createCongolmerate(builder, closer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpecificSegmentsQuerySegmentWalker createQuerySegmentWalker(QueryRunnerFactoryConglomerate conglomerate,
|
||||||
|
JoinableFactoryWrapper joinableFactory, Injector injector)
|
||||||
|
{
|
||||||
|
return delegate.createQuerySegmentWalker(conglomerate, joinableFactory, injector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SqlEngine createEngine(QueryLifecycleFactory qlf, ObjectMapper objectMapper, Injector injector)
|
||||||
|
{
|
||||||
|
return delegate.createEngine(qlf, objectMapper, injector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureJsonMapper(ObjectMapper mapper)
|
||||||
|
{
|
||||||
|
delegate.configureJsonMapper(mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JoinableFactoryWrapper createJoinableFactoryWrapper(LookupExtractorFactoryContainerProvider lookupProvider)
|
||||||
|
{
|
||||||
|
return delegate.createJoinableFactoryWrapper(lookupProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finalizeTestFramework(SqlTestFramework sqlTestFramework)
|
||||||
|
{
|
||||||
|
delegate.finalizeTestFramework(sqlTestFramework);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException
|
||||||
|
{
|
||||||
|
connectionModule.close();
|
||||||
|
delegate.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlannerComponentSupplier getPlannerComponentSupplier()
|
||||||
|
{
|
||||||
|
return delegate.getPlannerComponentSupplier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void main3(Object object) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
SqlTestFramework framework = getCI2().framework
|
||||||
|
// builder.addModule(propOverrideModuel());
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
// SSLContextProvider u = injector.getInstance(SSLContextProvider.class);
|
||||||
|
// System.out.println(u);
|
||||||
|
|
||||||
|
|
||||||
|
CliBroker2 c = new CliBroker2() {
|
||||||
|
protected List<? extends Module> getModules() {
|
||||||
|
List<Module> ret = new ArrayList<>();
|
||||||
|
ret.add(discoverModule());
|
||||||
|
ret.add(propOverrideModuel());
|
||||||
|
ret.add(framework.testSetupModule());
|
||||||
|
// ret.add(new AvaticaBasedConnectionModule());
|
||||||
|
ret.add(binder -> binder.bind(RequestLogger.class).toInstance(new TestRequestLogger()));
|
||||||
|
ret.add(CacheTestHelperModule.ResultCacheMode.DISABLED.makeModule());
|
||||||
|
ret.add(new QuidemCaptureModule());
|
||||||
|
ret.addAll(super.getModules());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
framework.injector().injectMembers(c);
|
||||||
|
// c.configure(new Properties());
|
||||||
|
|
||||||
|
c.run2();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,4 @@ public class QuidemCaptureModule implements Module
|
||||||
{
|
{
|
||||||
Jerseys.addResource(binder, QuidemCapture.class);
|
Jerseys.addResource(binder, QuidemCapture.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,10 @@
|
||||||
package org.apache.druid.cli;
|
package org.apache.druid.cli;
|
||||||
|
|
||||||
import com.github.rvesse.airline.annotations.Command;
|
import com.github.rvesse.airline.annotations.Command;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
@ -36,7 +37,6 @@ import org.apache.druid.client.cache.CacheConfig;
|
||||||
import org.apache.druid.client.selector.CustomTierSelectorStrategyConfig;
|
import org.apache.druid.client.selector.CustomTierSelectorStrategyConfig;
|
||||||
import org.apache.druid.client.selector.ServerSelectorStrategy;
|
import org.apache.druid.client.selector.ServerSelectorStrategy;
|
||||||
import org.apache.druid.client.selector.TierSelectorStrategy;
|
import org.apache.druid.client.selector.TierSelectorStrategy;
|
||||||
import org.apache.druid.curator.ZkEnablementConfig;
|
|
||||||
import org.apache.druid.discovery.NodeRole;
|
import org.apache.druid.discovery.NodeRole;
|
||||||
import org.apache.druid.guice.BrokerProcessingModule;
|
import org.apache.druid.guice.BrokerProcessingModule;
|
||||||
import org.apache.druid.guice.BrokerServiceModule;
|
import org.apache.druid.guice.BrokerServiceModule;
|
||||||
|
@ -52,6 +52,8 @@ import org.apache.druid.guice.QueryRunnerFactoryModule;
|
||||||
import org.apache.druid.guice.QueryableModule;
|
import org.apache.druid.guice.QueryableModule;
|
||||||
import org.apache.druid.guice.SegmentWranglerModule;
|
import org.apache.druid.guice.SegmentWranglerModule;
|
||||||
import org.apache.druid.guice.ServerTypeConfig;
|
import org.apache.druid.guice.ServerTypeConfig;
|
||||||
|
import org.apache.druid.initialization.ServerInjectorBuilder;
|
||||||
|
import org.apache.druid.java.util.common.lifecycle.Lifecycle;
|
||||||
import org.apache.druid.java.util.common.logger.Logger;
|
import org.apache.druid.java.util.common.logger.Logger;
|
||||||
import org.apache.druid.query.QuerySegmentWalker;
|
import org.apache.druid.query.QuerySegmentWalker;
|
||||||
import org.apache.druid.query.RetryQueryRunnerConfig;
|
import org.apache.druid.query.RetryQueryRunnerConfig;
|
||||||
|
@ -93,7 +95,7 @@ public class CliBroker2 extends ServerRunnable
|
||||||
{
|
{
|
||||||
private static final Logger log = new Logger(CliBroker2.class);
|
private static final Logger log = new Logger(CliBroker2.class);
|
||||||
|
|
||||||
private boolean isZkEnabled = true;
|
private boolean isZkEnabled = false;
|
||||||
|
|
||||||
public CliBroker2()
|
public CliBroker2()
|
||||||
{
|
{
|
||||||
|
@ -101,17 +103,11 @@ public class CliBroker2 extends ServerRunnable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<? extends Module> getmodules2()
|
public List<? extends Module> getmodules2()
|
||||||
{
|
{
|
||||||
return getModules();
|
return getModules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
|
||||||
public void configure(Properties properties)
|
|
||||||
{
|
|
||||||
isZkEnabled = ZkEnablementConfig.isEnabled(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<NodeRole> getNodeRoles(Properties properties)
|
protected Set<NodeRole> getNodeRoles(Properties properties)
|
||||||
{
|
{
|
||||||
|
@ -283,4 +279,43 @@ public class CliBroker2 extends ServerRunnable
|
||||||
new SqlModule()
|
new SqlModule()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void run2()
|
||||||
|
{
|
||||||
|
final Injector injector = makeInjector2(getNodeRoles(getProperties()));
|
||||||
|
final Lifecycle lifecycle = initLifecycle(injector);
|
||||||
|
|
||||||
|
try {
|
||||||
|
lifecycle.join();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Injector makeInjector2(Set<NodeRole> nodeRoles)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return makeServerInjector11(baseInjector, nodeRoles, getModules());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public static Injector makeServerInjector11(
|
||||||
|
final Injector baseInjector,
|
||||||
|
final Set<NodeRole> nodeRoles,
|
||||||
|
final Iterable<? extends Module> modules
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return new ServerInjectorBuilder(baseInjector)
|
||||||
|
.nodeRoles(nodeRoles)
|
||||||
|
.serviceModules(modules)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public abstract class GuiceRunnable implements Runnable
|
||||||
private final Logger log;
|
private final Logger log;
|
||||||
|
|
||||||
private Properties properties;
|
private Properties properties;
|
||||||
private Injector baseInjector;
|
protected Injector baseInjector;
|
||||||
|
|
||||||
public GuiceRunnable(Logger log)
|
public GuiceRunnable(Logger log)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue