Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ Many of Druid's external dependencies can be plugged in as modules. Extensions c
|`druid.extensions.directory`|The root extension directory where user can put extensions related files. Druid will load extensions stored under this directory.|`extensions` (This is a relative path to Druid's working directory)|
|`druid.extensions.hadoopDependenciesDir`|The root hadoop dependencies directory where user can put hadoop related dependencies files. Druid will load the dependencies based on the hadoop coordinate specified in the hadoop index task.|`hadoop-dependencies` (This is a relative path to Druid's working directory|
|`druid.extensions.loadList`|A JSON array of extensions to load from extension directories by Druid. If it is not specified, its value will be `null` and Druid will load all the extensions under `druid.extensions.directory`. If its value is empty list `[]`, then no extensions will be loaded at all. It is also allowed to specify absolute path of other custom extensions not stored in the common extensions directory.|null|
|`druid.extensions.moduleExcludeList`|A JSON array of canonical class names (e. g. `"io.druid.somepackage.SomeModule"`) of module classes which shouldn't be loaded, even if they are found in extensions specified by `druid.extensions.loadList`. Useful when some useful extension contains some module, which shouldn't be loaded on some Druid node type because some dependencies of that module couldn't be satisfied.|[]|
|`druid.extensions.searchCurrentClassloader`|This is a boolean flag that determines if Druid will search the main classloader for extensions. It defaults to true but can be turned off if you have reason to not automatically add all modules on the classpath.|true|
|`druid.extensions.hadoopContainerDruidClasspath`|Hadoop Indexing launches hadoop jobs and this configuration provides way to explicitly set the user classpath for the hadoop job. By default this is computed automatically by druid based on the druid process classpath and set of extensions. However, sometimes you might want to be explicit to resolve dependency conflicts between druid and hadoop.|null|
|`druid.extensions.addExtensionsToHadoopContainer`|Only applicable if `druid.extensions.hadoopContainerDruidClasspath` is provided. If set to true, then extensions specified in the loadList are added to hadoop container classpath. Note that when `druid.extensions.hadoopContainerDruidClasspath` is not provided then extensions are always added to hadoop container classpath.|false|

### Modules

|Property|Description|Default|
|--------|-----------|-------|
|`druid.modules.excludeList`|A JSON array of canonical class names (e. g. `"io.druid.somepackage.SomeModule"`) of module classes which shouldn't be loaded, even if they are found in extensions specified by `druid.extensions.loadList`, or in the list of core modules specified to be loaded on a particular Druid node type. Useful when some useful extension contains some module, which shouldn't be loaded on some Druid node type because some dependencies of that module couldn't be satisfied.|[]|

### Zookeeper
We recommend just setting the base ZK path and the ZK service host, but all ZK paths that Druid uses can be overwritten to absolute paths.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ public void close()
new TestDataSegmentAnnouncer(),
EasyMock.createNiceMock(DataSegmentServerAnnouncer.class),
handoffNotifierFactory,
makeTimeseriesOnlyConglomerate(),
this::makeTimeseriesOnlyConglomerate,
MoreExecutors.sameThreadExecutor(), // queryExecutorService
EasyMock.createMock(MonitorScheduler.class),
new SegmentLoaderFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.inject.Provider;
import com.metamx.emitter.service.ServiceEmitter;
import com.metamx.metrics.MonitorScheduler;
import io.druid.client.cache.Cache;
import io.druid.client.cache.CacheConfig;
import io.druid.indexing.common.actions.SegmentInsertAction;
import io.druid.indexing.common.actions.TaskActionClient;
import io.druid.indexing.common.config.TaskConfig;
import io.druid.indexing.common.task.Task;
import io.druid.query.QueryRunnerFactoryConglomerate;
import io.druid.segment.IndexIO;
import io.druid.segment.IndexMergerV9;
Expand Down Expand Up @@ -62,7 +62,6 @@
public class TaskToolbox
{
private final TaskConfig config;
private final Task task;
private final TaskActionClient taskActionClient;
private final ServiceEmitter emitter;
private final DataSegmentPusher segmentPusher;
Expand All @@ -72,7 +71,12 @@ public class TaskToolbox
private final DataSegmentAnnouncer segmentAnnouncer;
private final DataSegmentServerAnnouncer serverAnnouncer;
private final SegmentHandoffNotifierFactory handoffNotifierFactory;
private final QueryRunnerFactoryConglomerate queryRunnerFactoryConglomerate;
/**
* Using Provider, not {@link QueryRunnerFactoryConglomerate} directly, to not require {@link
* io.druid.indexing.overlord.TaskRunner} implementations that create TaskToolboxes to inject query stuff eagerly,
* because it may be unavailable, e. g. for batch tasks running in Spark or Hadoop.
*/
private final Provider<QueryRunnerFactoryConglomerate> queryRunnerFactoryConglomerateProvider;
private final MonitorScheduler monitorScheduler;
private final ExecutorService queryExecutorService;
private final SegmentLoader segmentLoader;
Expand All @@ -85,7 +89,6 @@ public class TaskToolbox

public TaskToolbox(
TaskConfig config,
Task task,
TaskActionClient taskActionClient,
ServiceEmitter emitter,
DataSegmentPusher segmentPusher,
Expand All @@ -95,7 +98,7 @@ public TaskToolbox(
DataSegmentAnnouncer segmentAnnouncer,
DataSegmentServerAnnouncer serverAnnouncer,
SegmentHandoffNotifierFactory handoffNotifierFactory,
QueryRunnerFactoryConglomerate queryRunnerFactoryConglomerate,
Provider<QueryRunnerFactoryConglomerate> queryRunnerFactoryConglomerateProvider,
ExecutorService queryExecutorService,
MonitorScheduler monitorScheduler,
SegmentLoader segmentLoader,
Expand All @@ -108,7 +111,6 @@ public TaskToolbox(
)
{
this.config = config;
this.task = task;
this.taskActionClient = taskActionClient;
this.emitter = emitter;
this.segmentPusher = segmentPusher;
Expand All @@ -118,7 +120,7 @@ public TaskToolbox(
this.segmentAnnouncer = segmentAnnouncer;
this.serverAnnouncer = serverAnnouncer;
this.handoffNotifierFactory = handoffNotifierFactory;
this.queryRunnerFactoryConglomerate = queryRunnerFactoryConglomerate;
this.queryRunnerFactoryConglomerateProvider = queryRunnerFactoryConglomerateProvider;
this.queryExecutorService = queryExecutorService;
this.monitorScheduler = monitorScheduler;
this.segmentLoader = segmentLoader;
Expand Down Expand Up @@ -182,7 +184,7 @@ public SegmentHandoffNotifierFactory getSegmentHandoffNotifierFactory()

public QueryRunnerFactoryConglomerate getQueryRunnerFactoryConglomerate()
{
return queryRunnerFactoryConglomerate;
return queryRunnerFactoryConglomerateProvider.get();
}

public ExecutorService getQueryExecutorService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.metamx.emitter.service.ServiceEmitter;
import com.metamx.metrics.MonitorScheduler;
import io.druid.client.cache.Cache;
Expand Down Expand Up @@ -59,7 +60,7 @@ public class TaskToolboxFactory
private final DataSegmentAnnouncer segmentAnnouncer;
private final DataSegmentServerAnnouncer serverAnnouncer;
private final SegmentHandoffNotifierFactory handoffNotifierFactory;
private final QueryRunnerFactoryConglomerate queryRunnerFactoryConglomerate;
private final Provider<QueryRunnerFactoryConglomerate> queryRunnerFactoryConglomerateProvider;
private final ExecutorService queryExecutorService;
private final MonitorScheduler monitorScheduler;
private final SegmentLoaderFactory segmentLoaderFactory;
Expand All @@ -81,7 +82,7 @@ public TaskToolboxFactory(
DataSegmentAnnouncer segmentAnnouncer,
DataSegmentServerAnnouncer serverAnnouncer,
SegmentHandoffNotifierFactory handoffNotifierFactory,
QueryRunnerFactoryConglomerate queryRunnerFactoryConglomerate,
Provider<QueryRunnerFactoryConglomerate> queryRunnerFactoryConglomerateProvider,
@Processing ExecutorService queryExecutorService,
MonitorScheduler monitorScheduler,
SegmentLoaderFactory segmentLoaderFactory,
Expand All @@ -102,7 +103,7 @@ public TaskToolboxFactory(
this.segmentAnnouncer = segmentAnnouncer;
this.serverAnnouncer = serverAnnouncer;
this.handoffNotifierFactory = handoffNotifierFactory;
this.queryRunnerFactoryConglomerate = queryRunnerFactoryConglomerate;
this.queryRunnerFactoryConglomerateProvider = queryRunnerFactoryConglomerateProvider;
this.queryExecutorService = queryExecutorService;
this.monitorScheduler = monitorScheduler;
this.segmentLoaderFactory = segmentLoaderFactory;
Expand All @@ -118,7 +119,6 @@ public TaskToolbox build(Task task)
final File taskWorkDir = config.getTaskWorkDir(task.getId());
return new TaskToolbox(
config,
task,
taskActionClientFactory.create(task),
emitter,
segmentPusher,
Expand All @@ -128,7 +128,7 @@ public TaskToolbox build(Task task)
segmentAnnouncer,
serverAnnouncer,
handoffNotifierFactory,
queryRunnerFactoryConglomerate,
queryRunnerFactoryConglomerateProvider,
queryExecutorService,
monitorScheduler,
segmentLoaderFactory.manufacturate(taskWorkDir),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void setUp() throws IOException
mockSegmentAnnouncer,
EasyMock.createNiceMock(DataSegmentServerAnnouncer.class),
mockHandoffNotifierFactory,
mockQueryRunnerFactoryConglomerate,
() -> mockQueryRunnerFactoryConglomerate,
mockQueryExecutorService,
mockMonitorScheduler,
new SegmentLoaderFactory(mockSegmentLoaderLocalCacheManager),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private final List<DataSegment> runTask(final IndexTask indexTask) throws Except

indexTask.run(
new TaskToolbox(
null, null, new TaskActionClient()
null, new TaskActionClient()
{
@Override
public <RetType> RetType submit(TaskAction<RetType> taskAction) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ Map<SegmentDescriptor, Pair<Executor, Runnable>> getHandOffCallbacks()
new TestDataSegmentAnnouncer(),
EasyMock.createNiceMock(DataSegmentServerAnnouncer.class),
handoffNotifierFactory,
conglomerate,
() -> conglomerate,
MoreExecutors.sameThreadExecutor(), // queryExecutorService
EasyMock.createMock(MonitorScheduler.class),
new SegmentLoaderFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public <RetType> RetType submit(TaskAction<RetType> taskAction) throws IOExcepti

mergeTask.run(
new TaskToolbox(
null, null, new TaskActionClient()
null, new TaskActionClient()
{
@Override
public <RetType> RetType submit(TaskAction<RetType> taskAction) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public void unannounceSegments(Iterable<DataSegment> segments) throws IOExceptio
}, // segment announcer
EasyMock.createNiceMock(DataSegmentServerAnnouncer.class),
handoffNotifierFactory,
queryRunnerFactoryConglomerate, // query runner factory conglomerate corporation unionized collective
() -> queryRunnerFactoryConglomerate, // query runner factory conglomerate corporation unionized collective
MoreExecutors.sameThreadExecutor(), // query executor service
monitorScheduler, // monitor scheduler
new SegmentLoaderFactory(
Expand Down
14 changes: 0 additions & 14 deletions processing/src/main/java/io/druid/guice/ExtensionsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -49,13 +48,6 @@ public class ExtensionsConfig
@JsonProperty
private List<String> loadList;

/**
* Canonical class names of modules, which should not be loaded despite they are founded in extensions from {@link
* #loadList}.
*/
@JsonProperty
private List<String> moduleExcludeList = Collections.emptyList();

public boolean searchCurrentClassloader()
{
return searchCurrentClassloader;
Expand Down Expand Up @@ -86,11 +78,6 @@ public List<String> getLoadList()
return loadList;
}

public List<String> getModuleExcludeList()
{
return moduleExcludeList;
}

@Override
public String toString()
{
Expand All @@ -101,7 +88,6 @@ public String toString()
", hadoopContainerDruidClasspath='" + hadoopContainerDruidClasspath + '\'' +
", addExtensionsToHadoopContainer=" + addExtensionsToHadoopContainer +
", loadList=" + loadList +
", moduleExcludeList=" + moduleExcludeList +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void configure(Binder binder)
{
binder.bind(DruidSecondaryModule.class);
JsonConfigProvider.bind(binder, "druid.extensions", ExtensionsConfig.class);
JsonConfigProvider.bind(binder, "druid.modules", ModulesConfig.class);
}
}
);
Expand Down
49 changes: 49 additions & 0 deletions processing/src/main/java/io/druid/guice/ModulesConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.druid.guice;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Collections;
import java.util.List;

public class ModulesConfig
{
/**
* Canonical class names of modules, which should not be loaded despite they are founded in extensions from {@link
* io.druid.guice.ExtensionsConfig#loadList} or the standard list of modules loaded by some node type, e. g. {@code
* CliPeon}.
*/
@JsonProperty
private List<String> excludeList = Collections.emptyList();

public List<String> getExcludeList()
{
return excludeList;
}

@Override
public String toString()
{
return "ModulesConfig{" +
"excludeList=" + excludeList +
'}';
}
}
24 changes: 22 additions & 2 deletions server/src/main/java/io/druid/initialization/Initialization.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import io.druid.guice.LifecycleModule;
import io.druid.guice.LocalDataStorageDruidModule;
import io.druid.guice.MetadataConfigModule;
import io.druid.guice.ModulesConfig;
import io.druid.guice.ParsersModule;
import io.druid.guice.ServerModule;
import io.druid.guice.ServerViewModule;
Expand Down Expand Up @@ -185,8 +186,6 @@ private void tryAdd(T serviceImpl, String extensionType)
+ "is it a local or anonymous class?",
serviceImpl.getClass().getName()
);
} else if (extensionsConfig.getModuleExcludeList().contains(serviceImplName)) {
log.info("Not loading module [%s] because it is present in moduleExcludeList", serviceImplName);
} else if (!implClassNamesToLoad.contains(serviceImplName)) {
log.info(
"Adding implementation [%s] for class [%s] from %s extension",
Expand Down Expand Up @@ -390,13 +389,15 @@ public static Injector makeInjectorWithModules(final Injector baseInjector, Iter
private static class ModuleList
{
private final Injector baseInjector;
private final ModulesConfig modulesConfig;
private final ObjectMapper jsonMapper;
private final ObjectMapper smileMapper;
private final List<Module> modules;

public ModuleList(Injector baseInjector)
{
this.baseInjector = baseInjector;
this.modulesConfig = baseInjector.getInstance(ModulesConfig.class);
this.jsonMapper = baseInjector.getInstance(Key.get(ObjectMapper.class, Json.class));
this.smileMapper = baseInjector.getInstance(Key.get(ObjectMapper.class, Smile.class));
this.modules = Lists.newArrayList();
Expand All @@ -410,12 +411,21 @@ private List<Module> getModules()
public void addModule(Object input)
{
if (input instanceof DruidModule) {
if (!checkModuleClass(input.getClass())) {
return;
}
baseInjector.injectMembers(input);
modules.add(registerJacksonModules(((DruidModule) input)));
} else if (input instanceof Module) {
if (!checkModuleClass(input.getClass())) {
return;
}
baseInjector.injectMembers(input);
modules.add((Module) input);
} else if (input instanceof Class) {
if (!checkModuleClass((Class<?>) input)) {
return;
}
if (DruidModule.class.isAssignableFrom((Class) input)) {
modules.add(registerJacksonModules(baseInjector.getInstance((Class<? extends DruidModule>) input)));
} else if (Module.class.isAssignableFrom((Class) input)) {
Expand All @@ -429,6 +439,16 @@ public void addModule(Object input)
}
}

private boolean checkModuleClass(Class<?> moduleClass)
{
String moduleClassName = moduleClass.getCanonicalName();
if (moduleClassName != null && modulesConfig.getExcludeList().contains(moduleClassName)) {
log.info("Not loading module [%s] because it is present in excludeList", moduleClassName);
return false;
}
return true;
}

public void addModules(Object... object)
{
for (Object o : object) {
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/java/io/druid/server/QueryResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.metamx.emitter.EmittingLogger;
import com.metamx.emitter.service.ServiceEmitter;
import io.druid.client.DirectDruidClient;
import io.druid.guice.LazySingleton;
import io.druid.guice.annotations.Json;
import io.druid.guice.annotations.Smile;
import io.druid.java.util.common.ISE;
Expand Down Expand Up @@ -85,6 +86,7 @@

/**
*/
@LazySingleton
@Path("/druid/v2/")
public class QueryResource implements QueryCountStatsProvider
{
Expand Down
Loading