use of io.druid.guice.ExtensionsConfig in project druid by druid-io.
the class InitializationTest method test04DuplicateClassLoaderExtensions.
@Test
public void test04DuplicateClassLoaderExtensions() throws Exception {
final File extensionDir = temporaryFolder.newFolder();
Initialization.getLoadersMap().put(extensionDir, (URLClassLoader) Initialization.class.getClassLoader());
Collection<DruidModule> modules = Initialization.getFromExtensions(new ExtensionsConfig(), DruidModule.class);
Set<String> loadedModuleNames = Sets.newHashSet();
for (DruidModule module : modules) {
Assert.assertFalse("Duplicate extensions are loaded", loadedModuleNames.contains(module.getClass().getName()));
loadedModuleNames.add(module.getClass().getName());
}
Initialization.getLoadersMap().clear();
}
use of io.druid.guice.ExtensionsConfig in project druid by druid-io.
the class InitializationTest method testGetHadoopDependencyFilesToLoad_non_exist_version_dir.
@Test(expected = ISE.class)
public void testGetHadoopDependencyFilesToLoad_non_exist_version_dir() throws IOException {
final File rootHadoopDependenciesDir = temporaryFolder.newFolder();
final ExtensionsConfig config = new ExtensionsConfig() {
@Override
public String getHadoopDependenciesDir() {
return rootHadoopDependenciesDir.getAbsolutePath();
}
};
final File hadoopClient = new File(rootHadoopDependenciesDir, "hadoop-client");
hadoopClient.mkdir();
Initialization.getHadoopDependencyFilesToLoad(ImmutableList.of("org.apache.hadoop:hadoop-client:2.3.0"), config);
}
use of io.druid.guice.ExtensionsConfig in project druid by druid-io.
the class InitializationTest method testGetExtensionFilesToLoad_null_load_list.
/**
* If druid.extension.load is not specified, Initialization.getExtensionFilesToLoad is supposed to return all the
* extension folders under root extensions directory.
*/
@Test
public void testGetExtensionFilesToLoad_null_load_list() throws IOException {
final File extensionsDir = temporaryFolder.newFolder();
final ExtensionsConfig config = new ExtensionsConfig() {
@Override
public String getDirectory() {
return extensionsDir.getAbsolutePath();
}
};
final File mysql_metadata_storage = new File(extensionsDir, "mysql-metadata-storage");
final File druid_kafka_eight = new File(extensionsDir, "druid-kafka-eight");
mysql_metadata_storage.mkdir();
druid_kafka_eight.mkdir();
final File[] expectedFileList = new File[] { druid_kafka_eight, mysql_metadata_storage };
final File[] actualFileList = Initialization.getExtensionFilesToLoad(config);
Arrays.sort(actualFileList);
Assert.assertArrayEquals(expectedFileList, actualFileList);
}
use of io.druid.guice.ExtensionsConfig in project druid by druid-io.
the class InitializationTest method testGetExtensionFilesToLoad_with_non_exist_item_in_load_list.
/**
* druid.extension.load is specified, but contains an extension that is not prepared under root extension directory.
* Initialization.getExtensionFilesToLoad is supposed to throw ISE.
*/
@Test(expected = ISE.class)
public void testGetExtensionFilesToLoad_with_non_exist_item_in_load_list() throws IOException {
final File extensionsDir = temporaryFolder.newFolder();
final ExtensionsConfig config = new ExtensionsConfig() {
@Override
public List<String> getLoadList() {
return Arrays.asList("mysql-metadata-storage", "druid-kafka-eight");
}
@Override
public String getDirectory() {
return extensionsDir.getAbsolutePath();
}
};
final File druid_kafka_eight = new File(extensionsDir, "druid-kafka-eight");
final File random_extension = new File(extensionsDir, "random-extensions");
druid_kafka_eight.mkdir();
random_extension.mkdir();
Initialization.getExtensionFilesToLoad(config);
}
use of io.druid.guice.ExtensionsConfig in project druid by druid-io.
the class InitializationTest method testGetHadoopDependencyFilesToLoad_with_hadoop_coordinates.
@Test
public void testGetHadoopDependencyFilesToLoad_with_hadoop_coordinates() throws IOException {
final File rootHadoopDependenciesDir = temporaryFolder.newFolder();
final ExtensionsConfig config = new ExtensionsConfig() {
@Override
public String getHadoopDependenciesDir() {
return rootHadoopDependenciesDir.getAbsolutePath();
}
};
final File hadoopClient = new File(rootHadoopDependenciesDir, "hadoop-client");
final File versionDir = new File(hadoopClient, "2.3.0");
hadoopClient.mkdir();
versionDir.mkdir();
final File[] expectedFileList = new File[] { versionDir };
final File[] actualFileList = Initialization.getHadoopDependencyFilesToLoad(ImmutableList.of("org.apache.hadoop:hadoop-client:2.3.0"), config);
Assert.assertArrayEquals(expectedFileList, actualFileList);
}
Aggregations