diff --git a/docs/content/configuration/index.md b/docs/content/configuration/index.md index 801f620595e2..7ea4de291dd2 100644 --- a/docs/content/configuration/index.md +++ b/docs/content/configuration/index.md @@ -23,7 +23,7 @@ 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.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.|druid classpath and extensions| +|`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.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.|null| |`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| diff --git a/processing/src/test/java/io/druid/guice/ExtensionsConfigTest.java b/processing/src/test/java/io/druid/guice/ExtensionsConfigTest.java new file mode 100644 index 000000000000..7f91911838b3 --- /dev/null +++ b/processing/src/test/java/io/druid/guice/ExtensionsConfigTest.java @@ -0,0 +1,82 @@ +/* + * 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.databind.ObjectMapper; +import com.google.common.collect.ImmutableList; +import io.druid.segment.TestHelper; +import org.junit.Assert; +import org.junit.Test; + +/** + */ +public class ExtensionsConfigTest +{ + @Test + public void testSerdeWithDefaults() throws Exception + { + String json = "{}"; + ObjectMapper mapper = TestHelper.getObjectMapper(); + + ExtensionsConfig config = mapper.readValue( + mapper.writeValueAsString( + mapper.readValue(json, ExtensionsConfig.class) + ), + ExtensionsConfig.class + ); + + Assert.assertTrue(config.searchCurrentClassloader()); + Assert.assertEquals("extensions", config.getDirectory()); + Assert.assertEquals("hadoop-dependencies", config.getHadoopDependenciesDir()); + Assert.assertNull(config.getHadoopContainerDruidClasspath()); + Assert.assertNull(config.getLoadList()); + } + + @Test + public void testSerdeWithNonDefaults() throws Exception + { + String json = "{\n" + + " \"searchCurrentClassloader\": false,\n" + + " \"directory\": \"testExtensions\",\n" + + " \"hadoopDependenciesDir\": \"testHadoopDependenciesDir\",\n" + + " \"hadoopContainerDruidClasspath\": \"testHadoopContainerClasspath\",\n" + + " \"loadList\": [\"a\",\"b\"]\n" + + "}"; + ObjectMapper mapper = TestHelper.getObjectMapper(); + + ExtensionsConfig config = mapper.readValue( + mapper.writeValueAsString( + mapper.readValue(json, ExtensionsConfig.class) + ), + ExtensionsConfig.class + ); + + Assert.assertFalse(config.searchCurrentClassloader()); + Assert.assertEquals("testExtensions", config.getDirectory()); + Assert.assertEquals("testHadoopDependenciesDir", config.getHadoopDependenciesDir()); + Assert.assertEquals("testHadoopContainerClasspath", config.getHadoopContainerDruidClasspath()); + Assert.assertEquals( + ImmutableList.of( + "a", "b" + ), + config.getLoadList() + ); + } +} diff --git a/server/src/main/java/io/druid/initialization/Initialization.java b/server/src/main/java/io/druid/initialization/Initialization.java index acf14014aeab..d1286bd3c292 100644 --- a/server/src/main/java/io/druid/initialization/Initialization.java +++ b/server/src/main/java/io/druid/initialization/Initialization.java @@ -288,7 +288,7 @@ public static List getURLsForClasspath(String cp) File f = new File(paths[i]); if ("*".equals(f.getName())) { File parentDir = f.getParentFile(); - if (parentDir.exists() && parentDir.isDirectory()) { + if (parentDir.isDirectory()) { File[] jars = parentDir.listFiles( new FilenameFilter() {