diff --git a/server/src/main/java/io/druid/curator/discovery/DiscoveryModule.java b/server/src/main/java/io/druid/curator/discovery/DiscoveryModule.java
index 88fcdb3c299..ca5340d9565 100644
--- a/server/src/main/java/io/druid/curator/discovery/DiscoveryModule.java
+++ b/server/src/main/java/io/druid/curator/discovery/DiscoveryModule.java
@@ -59,7 +59,7 @@ import java.util.concurrent.ThreadFactory;
/**
* The DiscoveryModule allows for the registration of Keys of DruidNode objects, which it intends to be
* automatically announced at the end of the lifecycle start.
- *
+ *
* In order for this to work a ServiceAnnouncer instance *must* be injected and instantiated first.
* This can often be achieved by registering ServiceAnnouncer.class with the LifecycleModule.
*/
@@ -69,19 +69,25 @@ public class DiscoveryModule implements Module
/**
* Requests that the un-annotated DruidNode instance be injected and published as part of the lifecycle.
- *
+ *
* That is, this module will announce the DruidNode instance returned by
* injector.getInstance(Key.get(DruidNode.class)) automatically.
* Announcement will happen in the LAST stage of the Lifecycle
*/
public static void registerDefault(Binder binder)
{
- registerKey(binder, Key.get(new TypeLiteral(){}));
+ registerKey(
+ binder, Key.get(
+ new TypeLiteral()
+ {
+ }
+ )
+ );
}
/**
* Requests that the annotated DruidNode instance be injected and published as part of the lifecycle.
- *
+ *
* That is, this module will announce the DruidNode instance returned by
* injector.getInstance(Key.get(DruidNode.class, annotation)) automatically.
* Announcement will happen in the LAST stage of the Lifecycle
@@ -90,12 +96,18 @@ public class DiscoveryModule implements Module
*/
public static void register(Binder binder, Annotation annotation)
{
- registerKey(binder, Key.get(new TypeLiteral(){}, annotation));
+ registerKey(
+ binder, Key.get(
+ new TypeLiteral()
+ {
+ }, annotation
+ )
+ );
}
/**
* Requests that the annotated DruidNode instance be injected and published as part of the lifecycle.
- *
+ *
* That is, this module will announce the DruidNode instance returned by
* injector.getInstance(Key.get(DruidNode.class, annotation)) automatically.
* Announcement will happen in the LAST stage of the Lifecycle
@@ -104,12 +116,18 @@ public class DiscoveryModule implements Module
*/
public static void register(Binder binder, Class extends Annotation> annotation)
{
- registerKey(binder, Key.get(new TypeLiteral(){}, annotation));
+ registerKey(
+ binder, Key.get(
+ new TypeLiteral()
+ {
+ }, annotation
+ )
+ );
}
/**
* Requests that the keyed DruidNode instance be injected and published as part of the lifecycle.
- *
+ *
* That is, this module will announce the DruidNode instance returned by
* injector.getInstance(Key.get(DruidNode.class, annotation)) automatically.
* Announcement will happen in the LAST stage of the Lifecycle
@@ -137,7 +155,9 @@ public class DiscoveryModule implements Module
.asEagerSingleton();
}
- @Provides @LazySingleton @Named(NAME)
+ @Provides
+ @LazySingleton
+ @Named(NAME)
public CuratorServiceAnnouncer getServiceAnnouncer(
final CuratorServiceAnnouncer announcer,
final Injector injector,
@@ -181,7 +201,8 @@ public class DiscoveryModule implements Module
return announcer;
}
- @Provides @LazySingleton
+ @Provides
+ @LazySingleton
public ServiceDiscovery getServiceDiscovery(
CuratorFramework curator,
CuratorDiscoveryConfig config,
@@ -217,14 +238,14 @@ public class DiscoveryModule implements Module
throw Throwables.propagate(e);
}
}
- },
- Lifecycle.Stage.LAST
+ }
);
return serviceDiscovery;
}
- @Provides @LazySingleton
+ @Provides
+ @LazySingleton
public ServerDiscoveryFactory getServerDiscoveryFactory(
ServiceDiscovery serviceDiscovery
)
diff --git a/server/src/main/java/io/druid/server/initialization/ExtensionsConfig.java b/server/src/main/java/io/druid/server/initialization/ExtensionsConfig.java
index 0973a249434..46403358758 100644
--- a/server/src/main/java/io/druid/server/initialization/ExtensionsConfig.java
+++ b/server/src/main/java/io/druid/server/initialization/ExtensionsConfig.java
@@ -29,6 +29,10 @@ import java.util.List;
*/
public class ExtensionsConfig
{
+ @JsonProperty
+ @NotNull
+ private boolean searchCurrentClassloader = true;
+
@JsonProperty
@NotNull
private List coordinates = ImmutableList.of();
@@ -44,6 +48,11 @@ public class ExtensionsConfig
"https://metamx.artifactoryonline.com/metamx/pub-libs-releases-local"
);
+ public boolean searchCurrentClassloader()
+ {
+ return searchCurrentClassloader;
+ }
+
public List getCoordinates()
{
return coordinates;
diff --git a/services/src/main/java/io/druid/cli/Initialization.java b/services/src/main/java/io/druid/cli/Initialization.java
index 8b1f1fa7640..f983762ccb0 100644
--- a/services/src/main/java/io/druid/cli/Initialization.java
+++ b/services/src/main/java/io/druid/cli/Initialization.java
@@ -139,14 +139,13 @@ public class
for (Artifact artifact : artifacts) {
if (!exclusions.contains(artifact.getGroupId())) {
urls.add(artifact.getFile().toURI().toURL());
- }
- else {
+ } else {
log.error("Skipped Artifact[%s]", artifact);
}
}
for (URL url : urls) {
- log.error("Added URL[%s]", url);
+ log.info("Added URL[%s]", url);
}
loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), Initialization.class.getClassLoader());
@@ -165,6 +164,13 @@ public class
}
}
+ if (config.searchCurrentClassloader()) {
+ for (T module : ServiceLoader.load(clazz, Initialization.class.getClassLoader())) {
+ log.info("Adding local module[%s]", module.getClass());
+ retVal.add(module);
+ }
+ }
+
return retVal;
}
@@ -243,7 +249,8 @@ public class
private final ObjectMapper smileMapper;
private final List modules;
- public ModuleList(Injector baseInjector) {
+ public ModuleList(Injector baseInjector)
+ {
this.baseInjector = baseInjector;
this.jsonMapper = baseInjector.getInstance(Key.get(ObjectMapper.class, Json.class));
this.smileMapper = baseInjector.getInstance(Key.get(ObjectMapper.class, Smile.class));
@@ -260,24 +267,19 @@ public class
if (input instanceof DruidModule) {
baseInjector.injectMembers(input);
modules.add(registerJacksonModules(((DruidModule) input)));
- }
- else if (input instanceof Module) {
+ } else if (input instanceof Module) {
baseInjector.injectMembers(input);
modules.add((Module) input);
- }
- else if (input instanceof Class) {
+ } else if (input instanceof Class) {
if (DruidModule.class.isAssignableFrom((Class) input)) {
modules.add(registerJacksonModules(baseInjector.getInstance((Class extends DruidModule>) input)));
- }
- else if (Module.class.isAssignableFrom((Class) input)) {
+ } else if (Module.class.isAssignableFrom((Class) input)) {
modules.add(baseInjector.getInstance((Class extends Module>) input));
return;
- }
- else {
+ } else {
throw new ISE("Class[%s] does not implement %s", input.getClass(), Module.class);
}
- }
- else {
+ } else {
throw new ISE("Unknown module type[%s]", input.getClass());
}
}