diff --git a/common/pom.xml b/common/pom.xml
index 6a481899484..b46929f30d2 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -59,14 +59,6 @@
org.skife.config
config-magic
-
- org.apache.curator
- curator-recipes
-
-
- org.apache.curator
- curator-x-discovery
-
org.hibernate
hibernate-validator
@@ -75,10 +67,6 @@
javax.validation
validation-api
-
- it.uniroma3.mat
- extendedset
-
com.google.guava
guava
@@ -127,16 +115,6 @@
log4j
log4j
-
- mysql
- mysql-connector-java
- 5.1.18
-
-
- org.mozilla
- rhino
- 1.7R4
-
diff --git a/indexing-service/pom.xml b/indexing-service/pom.xml
index 78447097bbe..82166796035 100644
--- a/indexing-service/pom.xml
+++ b/indexing-service/pom.xml
@@ -47,95 +47,10 @@
druid-indexing-hadoop
${project.parent.version}
-
- com.metamx
- emitter
-
-
- com.metamx
- http-client
-
-
- com.metamx
- java-util
-
-
- com.metamx
- server-metrics
-
-
-
- commons-codec
- commons-codec
-
-
- commons-io
- commons-io
-
-
- org.skife.config
- config-magic
-
-
- org.apache.curator
- curator-framework
-
-
- org.apache.curator
- curator-recipes
-
-
- com.google.guava
- guava
-
-
- com.google.inject
- guice
-
-
- com.google.inject.extensions
- guice-servlet
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- javax.inject
- javax.inject
-
-
- org.jdbi
- jdbi
-
-
- com.sun.jersey
- jersey-core
-
-
- com.sun.jersey.contribs
- jersey-guice
-
-
- org.eclipse.jetty
- jetty-server
-
-
- joda-time
- joda-time
-
-
- com.google.code.findbugs
- jsr305
+ mysql
+ mysql-connector-java
+ 5.1.18
diff --git a/pom.xml b/pom.xml
index 66ab8a1daf7..2756303acef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -289,6 +289,16 @@
com.sun.jersey.contribs
jersey-guice
1.17.1
+
+
+ com.google.inject
+ guice
+
+
+ com.google.inject.extensions
+ guice-servlet
+
+
com.sun.jersey
@@ -409,7 +419,7 @@
junit
junit
- 4.8.1
+ 4.11
test
diff --git a/processing/pom.xml b/processing/pom.xml
index 6344bb65d91..21f35318569 100644
--- a/processing/pom.xml
+++ b/processing/pom.xml
@@ -37,10 +37,6 @@
druid-common
${project.parent.version}
-
- com.metamx
- java-util
-
com.metamx
bytebuffer-collections
@@ -49,8 +45,6 @@
com.metamx
emitter
-
-
com.ning
compress-lzf
@@ -63,34 +57,6 @@
it.uniroma3.mat
extendedset
-
- com.google.guava
- guava
-
-
- com.google.inject
- guice
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- javax.inject
- javax.inject
-
-
- joda-time
- joda-time
-
-
- log4j
- log4j
-
org.slf4j
slf4j-log4j12
@@ -107,6 +73,11 @@
com.ibm.icu
icu4j
+
+ org.mozilla
+ rhino
+ 1.7R4
+
diff --git a/server/pom.xml b/server/pom.xml
index e58278a173a..eda8a93fcb4 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -37,24 +37,14 @@
druid-processing
${project.parent.version}
-
-
- com.metamx
- emitter
-
com.metamx
http-client
-
- com.metamx
- java-util
-
com.metamx
server-metrics
-
commons-cli
commons-cli
@@ -64,21 +54,13 @@
commons-lang
- commons-io
- commons-io
+ javax.inject
+ javax.inject
com.amazonaws
aws-java-sdk
-
- com.ning
- compress-lzf
-
-
- org.skife.config
- config-magic
-
org.apache.curator
curator-framework
@@ -87,42 +69,14 @@
org.apache.curator
curator-x-discovery
-
- it.uniroma3.mat
- extendedset
-
-
- com.google.guava
- guava
-
-
- com.google.inject
- guice
-
-
- com.fasterxml.jackson.core
- jackson-core
-
com.fasterxml.jackson.jaxrs
jackson-jaxrs-json-provider
-
- com.fasterxml.jackson.core
- jackson-databind
-
com.fasterxml.jackson.dataformat
jackson-dataformat-smile
-
- javax.inject
- javax.inject
-
-
- org.jdbi
- jdbi
-
com.sun.jersey
jersey-server
@@ -131,6 +85,10 @@
com.sun.jersey
jersey-core
+
+ com.google.inject.extensions
+ guice-servlet
+
com.sun.jersey.contribs
jersey-guice
@@ -139,22 +97,10 @@
org.eclipse.jetty
jetty-server
-
- joda-time
- joda-time
-
com.google.code.findbugs
jsr305
-
- log4j
- log4j
-
-
- org.slf4j
- slf4j-log4j12
-
io.tesla.aether
tesla-aether
diff --git a/server/src/main/java/io/druid/server/StatusResource.java b/server/src/main/java/io/druid/server/StatusResource.java
index 643d4d4fd74..44aa50a0ee7 100644
--- a/server/src/main/java/io/druid/server/StatusResource.java
+++ b/server/src/main/java/io/druid/server/StatusResource.java
@@ -28,8 +28,8 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
-import java.util.Set;
/**
*/
@@ -40,7 +40,7 @@ public class StatusResource
@Produces("application/json")
public Status doGet()
{
- return new Status();
+ return new Status(Initialization.getLoadedModules(DruidModule.class));
}
public static class Status
@@ -49,13 +49,18 @@ public class StatusResource
final List modules;
final Memory memory;
- public Status()
+ public Status(Collection modules)
{
- this.version = Status.class.getPackage().getImplementationVersion();
- this.modules = getExtensionVersions();
+ this.version = getDruidVersion();
+ this.modules = getExtensionVersions(modules);
this.memory = new Memory(Runtime.getRuntime());
}
+ private String getDruidVersion()
+ {
+ return Status.class.getPackage().getImplementationVersion();
+ }
+
@JsonProperty
public String getVersion()
{
@@ -98,9 +103,8 @@ public class StatusResource
*
* @return map of extensions loaded with their respective implementation versions.
*/
- private List getExtensionVersions()
+ private List getExtensionVersions(Collection druidModules)
{
- final Set druidModules = Initialization.getLoadedModules(DruidModule.class);
List moduleVersions = new ArrayList<>();
for (DruidModule module : druidModules) {
String artifact = module.getClass().getPackage().getImplementationTitle();
@@ -110,7 +114,6 @@ public class StatusResource
}
return moduleVersions;
}
-
}
@JsonInclude(JsonInclude.Include.NON_NULL)
diff --git a/server/src/test/java/io/druid/initialization/InitializationTest.java b/server/src/test/java/io/druid/initialization/InitializationTest.java
new file mode 100644
index 00000000000..d1cb0afd0c5
--- /dev/null
+++ b/server/src/test/java/io/druid/initialization/InitializationTest.java
@@ -0,0 +1,152 @@
+/*
+ * Druid - a distributed column store.
+ * Copyright (C) 2012, 2013 Metamarkets Group Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package io.druid.initialization;
+
+import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Injector;
+import io.druid.server.initialization.ExtensionsConfig;
+import junit.framework.Assert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import javax.annotation.Nullable;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class InitializationTest
+{
+ private String oldService;
+ private String oldHost;
+ private String oldPort;
+
+ @Before
+ public void messWithSystemProperties()
+ {
+ // required to test Initialization.makeInjectorWithModules
+ oldService = System.setProperty("druid.service", "test-service");
+ oldHost = System.setProperty("druid.host", "test-host");
+ oldPort = System.setProperty("druid.port", "8080");
+ }
+
+ @After
+ public void cleanup()
+ {
+ System.setProperty("druid.service", oldService == null ? "" : oldService);
+ System.setProperty("druid.host", oldHost == null ? "" : oldHost);
+ System.setProperty("druid.port", oldPort == null ? "" : oldPort);
+ }
+
+ @Test
+ public void test01InitialModulesEmpty() throws Exception
+ {
+ Assert.assertEquals(
+ "Initial set of loaded modules must be empty",
+ 0,
+ Initialization.getLoadedModules(DruidModule.class).size()
+ );
+ }
+
+ @Test
+ public void test02MakeStartupInjector() throws Exception
+ {
+ Injector startupInjector = Initialization.makeStartupInjector();
+ Assert.assertNotNull(startupInjector);
+ Assert.assertNotNull(startupInjector.getInstance(ObjectMapper.class));
+ }
+
+ @Test
+ public void test03ClassLoaderExtensionsLoading()
+ {
+ Injector startupInjector = Initialization.makeStartupInjector();
+
+ Function fnClassName = new Function()
+ {
+ @Nullable
+ @Override
+ public String apply(@Nullable DruidModule input)
+ {
+ return input.getClass().getCanonicalName();
+ }
+ };
+
+ Assert.assertFalse(
+ "modules does not contain TestDruidModule",
+ Collections2.transform(Initialization.getLoadedModules(DruidModule.class), fnClassName)
+ .contains("io.druid.initialization.InitializationTest.TestDruidModule")
+ );
+
+ Collection modules = Initialization.getFromExtensions(
+ startupInjector.getInstance(ExtensionsConfig.class),
+ DruidModule.class
+ );
+
+ Assert.assertTrue(
+ "modules contains TestDruidModule",
+ Collections2.transform(modules, fnClassName)
+ .contains("io.druid.initialization.InitializationTest.TestDruidModule")
+ );
+ }
+
+ @Test
+ public void test04MakeInjectorWithModules() throws Exception
+ {
+ Injector startupInjector = Initialization.makeStartupInjector();
+ Injector injector = Initialization.makeInjectorWithModules(startupInjector, ImmutableList.of());
+ Assert.assertNotNull(injector);
+ }
+
+ @Test
+ public void testGetLoadedModules()
+ {
+
+ Set modules = Initialization.getLoadedModules(DruidModule.class);
+
+ Set loadedModules = Initialization.getLoadedModules(DruidModule.class);
+ Assert.assertEquals("Set from loaded modules #1 should be same!", modules, loadedModules);
+
+ Set loadedModules2 = Initialization.getLoadedModules(DruidModule.class);
+ Assert.assertEquals("Set from loaded modules #2 should be same!", modules, loadedModules2);
+ }
+
+ public static class TestDruidModule implements DruidModule
+ {
+ @Override
+ public List extends Module> getJacksonModules()
+ {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public void configure(Binder binder)
+ {
+ // Do nothing
+ }
+ }
+}
diff --git a/server/src/test/java/io/druid/server/StatusResourceTest.java b/server/src/test/java/io/druid/server/StatusResourceTest.java
index cff0fb4618e..9075f97ce81 100644
--- a/server/src/test/java/io/druid/server/StatusResourceTest.java
+++ b/server/src/test/java/io/druid/server/StatusResourceTest.java
@@ -19,19 +19,14 @@
package io.druid.server;
-import com.fasterxml.jackson.databind.Module;
import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Injector;
import io.druid.initialization.DruidModule;
-import io.druid.initialization.Initialization;
-import io.druid.server.initialization.ExtensionsConfig;
+import io.druid.initialization.InitializationTest;
import junit.framework.Assert;
import org.junit.Test;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
import static io.druid.server.StatusResource.ModuleVersion;
@@ -39,29 +34,14 @@ import static io.druid.server.StatusResource.ModuleVersion;
*/
public class StatusResourceTest
{
-
- private Collection loadTestModule()
- {
- Injector baseInjector = Initialization.makeStartupInjector();
- return Initialization.getFromExtensions(baseInjector.getInstance(ExtensionsConfig.class), DruidModule.class);
- }
-
@Test
public void testLoadedModules()
{
- final StatusResource resource = new StatusResource();
- List statusResourceModuleList;
- statusResourceModuleList = resource.doGet().getModules();
- Assert.assertEquals(
- "No Modules should be loaded currently! " + statusResourceModuleList,
- statusResourceModuleList.size(), 0
- );
+ Collection modules = ImmutableList.of((DruidModule)new InitializationTest.TestDruidModule());
+ List statusResourceModuleList = new StatusResource.Status(modules).getModules();
- Collection modules = loadTestModule();
- statusResourceModuleList = resource.doGet().getModules();
-
- Assert.assertEquals("Status should have all modules loaded!", statusResourceModuleList.size(), modules.size());
+ Assert.assertEquals("Status should have all modules loaded!", modules.size(), statusResourceModuleList.size());
for (DruidModule module : modules) {
String moduleName = module.getClass().getCanonicalName();
@@ -74,30 +54,6 @@ public class StatusResourceTest
}
Assert.assertTrue("Status resource should contain module " + moduleName, contains);
}
-
- /*
- * StatusResource only uses Initialization.getLoadedModules
- */
- for (int i = 0; i < 5; i++) {
- Set loadedModules = Initialization.getLoadedModules(DruidModule.class);
- Assert.assertEquals("Set from loaded module should be same!", loadedModules, modules);
- }
}
-
- public static class TestDruidModule implements DruidModule
- {
- @Override
- public List extends Module> getJacksonModules()
- {
- return ImmutableList.of();
- }
-
- @Override
- public void configure(Binder binder)
- {
- // Do nothing
- }
- }
-
}
diff --git a/server/src/test/resources/META-INF/services/io.druid.initialization.DruidModule b/server/src/test/resources/META-INF/services/io.druid.initialization.DruidModule
index 09678a839eb..b5bc03d5265 100644
--- a/server/src/test/resources/META-INF/services/io.druid.initialization.DruidModule
+++ b/server/src/test/resources/META-INF/services/io.druid.initialization.DruidModule
@@ -1 +1 @@
-io.druid.server.StatusResourceTest$TestDruidModule
+io.druid.initialization.InitializationTest$TestDruidModule
diff --git a/services/src/main/java/io/druid/cli/Version.java b/services/src/main/java/io/druid/cli/Version.java
index 210591e81e6..45c258de803 100644
--- a/services/src/main/java/io/druid/cli/Version.java
+++ b/services/src/main/java/io/druid/cli/Version.java
@@ -20,6 +20,8 @@
package io.druid.cli;
import io.airlift.command.Command;
+import io.druid.initialization.DruidModule;
+import io.druid.initialization.Initialization;
import io.druid.server.StatusResource;
@Command(
@@ -31,6 +33,6 @@ public class Version implements Runnable
@Override
public void run()
{
- System.out.println(new StatusResource.Status());
+ System.out.println(new StatusResource.Status(Initialization.getLoadedModules(DruidModule.class)));
}
}