diff --git a/client/pom.xml b/client/pom.xml
index 10268136193..14632df35df 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -164,7 +164,7 @@
javax.servlet
- servlet-api
+ javax.servlet-api
org.slf4j
diff --git a/client/src/main/java/com/metamx/druid/initialization/EmitterModule.java b/client/src/main/java/com/metamx/druid/initialization/EmitterModule.java
index 578f8e3ea16..7b2602efb3a 100644
--- a/client/src/main/java/com/metamx/druid/initialization/EmitterModule.java
+++ b/client/src/main/java/com/metamx/druid/initialization/EmitterModule.java
@@ -98,11 +98,10 @@ public class EmitterModule implements Module
{
final List> emitterBindings = injector.findBindingsByType(new TypeLiteral(){});
- for (Binding binding : emitterBindings) {
- if (Names.named(emitterType).equals(binding.getKey().getAnnotation())) {
- emitter = binding.getProvider().get();
- break;
- }
+ emitter = findEmitter(emitterType, emitterBindings);
+
+ if (emitter == null) {
+ emitter = findEmitter(LogEmitterModule.EMITTER_TYPE, emitterBindings);
}
if (emitter == null) {
@@ -117,6 +116,16 @@ public class EmitterModule implements Module
}
}
+ private Emitter findEmitter(String emitterType, List> emitterBindings)
+ {
+ for (Binding binding : emitterBindings) {
+ if (Names.named(emitterType).equals(binding.getKey().getAnnotation())) {
+ return binding.getProvider().get();
+ }
+ }
+ return null;
+ }
+
@Override
public Emitter get()
diff --git a/client/src/main/java/com/metamx/druid/initialization/LogEmitterModule.java b/client/src/main/java/com/metamx/druid/initialization/LogEmitterModule.java
index 237a87ec1b6..e64c259098b 100644
--- a/client/src/main/java/com/metamx/druid/initialization/LogEmitterModule.java
+++ b/client/src/main/java/com/metamx/druid/initialization/LogEmitterModule.java
@@ -34,13 +34,15 @@ import com.metamx.emitter.core.LoggingEmitterConfig;
*/
public class LogEmitterModule implements Module
{
+ public static final String EMITTER_TYPE = "logging";
+
@Override
public void configure(Binder binder)
{
JsonConfigProvider.bind(binder, "druid.emitter.logging", LoggingEmitterConfig.class);
}
- @Provides @LazySingleton @Named("logging")
+ @Provides @LazySingleton @Named(EMITTER_TYPE)
public Emitter makeEmitter(LoggingEmitterConfig config, ObjectMapper jsonMapper)
{
return new LoggingEmitter(config, jsonMapper);
diff --git a/common/src/main/java/com/metamx/druid/db/DbTablesConfig.java b/common/src/main/java/com/metamx/druid/db/DbTablesConfig.java
index 54567b3fe74..9065f0d1bf2 100644
--- a/common/src/main/java/com/metamx/druid/db/DbTablesConfig.java
+++ b/common/src/main/java/com/metamx/druid/db/DbTablesConfig.java
@@ -2,7 +2,6 @@ package com.metamx.druid.db;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.metamx.common.ISE;
import javax.validation.constraints.NotNull;
@@ -18,22 +17,16 @@ public class DbTablesConfig
@NotNull
private final String base;
- @NotNull
private final String segmentsTable;
- @NotNull
private final String rulesTable;
- @NotNull
private final String configTable;
- @NotNull
private final String tasksTable;
- @NotNull
private final String taskLogTable;
- @NotNull
private final String taskLockTable;
@JsonCreator
@@ -60,7 +53,7 @@ public class DbTablesConfig
{
if (explicitTableName == null) {
if (base == null) {
- throw new ISE("table[%s] unknown! Both base and %s were null!", defaultSuffix, defaultSuffix);
+ return null;
}
return String.format("%s_%s", base, defaultSuffix);
}
diff --git a/common/src/main/java/com/metamx/druid/guice/JsonConfigProvider.java b/common/src/main/java/com/metamx/druid/guice/JsonConfigProvider.java
index 8c633060333..855ab742ff3 100644
--- a/common/src/main/java/com/metamx/druid/guice/JsonConfigProvider.java
+++ b/common/src/main/java/com/metamx/druid/guice/JsonConfigProvider.java
@@ -52,6 +52,8 @@ public class JsonConfigProvider implements Provider>
private Properties props;
private JsonConfigurator configurator;
+ private Supplier retVal = null;
+
public JsonConfigProvider(
String propertyBase,
Class classToProvide
@@ -74,7 +76,22 @@ public class JsonConfigProvider implements Provider>
@Override
public Supplier get()
{
- final T config = configurator.configurate(props, propertyBase, classToProvide);
- return Suppliers.ofInstance(config);
+ if (retVal != null) {
+ return retVal;
+ }
+
+ try {
+ final T config = configurator.configurate(props, propertyBase, classToProvide);
+ retVal = Suppliers.ofInstance(config);
+ }
+ catch (RuntimeException e) {
+ // When a runtime exception gets thrown out, this provider will get called again if the object is asked for again.
+ // This will have the same failed result, 'cause when it's called no parameters will have actually changed. For
+ // Guice will then report the same error multiple times, which is pretty annoying. Cache a null supplier and
+ // return that instead. This is technically enforcing a singleton, but such is life.
+ retVal = Suppliers.ofInstance(null);
+ throw e;
+ }
+ return retVal;
}
}
diff --git a/common/src/main/java/com/metamx/druid/guice/LifecycleModule.java b/common/src/main/java/com/metamx/druid/guice/LifecycleModule.java
index b31bbaddd11..7e0588449ed 100644
--- a/common/src/main/java/com/metamx/druid/guice/LifecycleModule.java
+++ b/common/src/main/java/com/metamx/druid/guice/LifecycleModule.java
@@ -60,14 +60,29 @@ public class LifecycleModule implements Module
}
@Provides @LazySingleton
- public Lifecycle getLifecycle(Injector injector)
+ public Lifecycle getLifecycle(final Injector injector)
{
Lifecycle lifecycle = new Lifecycle();
scope.setLifecycle(lifecycle);
- for (Key> key : eagerClasses) {
- injector.getInstance(key); // Pull the key so as to "eagerly" load up the class.
- }
+ lifecycle.addHandler(
+ new Lifecycle.Handler()
+ {
+ @Override
+ public void start() throws Exception
+ {
+ for (Key> key : eagerClasses) {
+ injector.getInstance(key); // Pull the key so as to "eagerly" load up the class.
+ }
+ }
+
+ @Override
+ public void stop()
+ {
+
+ }
+ }
+ );
return lifecycle;
}
diff --git a/pom.xml b/pom.xml
index b5767dcdbb6..a5a570ff1d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -302,8 +302,8 @@
javax.servlet
- servlet-api
- 3.0
+ javax.servlet-api
+ 3.0.1
org.slf4j
diff --git a/server/pom.xml b/server/pom.xml
index 0ae6ac0560f..48289cca972 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -163,7 +163,7 @@
javax.servlet
- servlet-api
+ javax.servlet-api
org.slf4j
diff --git a/server/src/main/java/com/metamx/druid/http/MasterMain.java b/server/src/main/java/com/metamx/druid/http/MasterMain.java
index f4c3841f1a1..9f43e482d69 100644
--- a/server/src/main/java/com/metamx/druid/http/MasterMain.java
+++ b/server/src/main/java/com/metamx/druid/http/MasterMain.java
@@ -76,9 +76,8 @@ public class MasterMain
final ServiceAnnouncer serviceAnnouncer = injector.getInstance(ServiceAnnouncer.class);
try {
- lifecycle.start();
-
Initialization.announceDefaultService(nodeConfig, serviceAnnouncer, lifecycle);
+ lifecycle.start();
}
catch (Throwable t) {
log.error(t, "Error when starting up. Failing.");