Search in sources :

Example 1 with ExtensionsConfig

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();
}
Also used : ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) Test(org.junit.Test)

Example 2 with ExtensionsConfig

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);
}
Also used : ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) Test(org.junit.Test)

Example 3 with ExtensionsConfig

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);
}
Also used : ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) Test(org.junit.Test)

Example 4 with ExtensionsConfig

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);
}
Also used : ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) Test(org.junit.Test)

Example 5 with ExtensionsConfig

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);
}
Also used : ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) Test(org.junit.Test)

Aggregations

ExtensionsConfig (io.druid.guice.ExtensionsConfig)13 File (java.io.File)11 Test (org.junit.Test)10 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 Cli (io.airlift.airline.Cli)1 Help (io.airlift.airline.Help)1 ParseException (io.airlift.airline.ParseException)1 CuratorModule (io.druid.curator.CuratorModule)1 DiscoveryModule (io.druid.curator.discovery.DiscoveryModule)1 AWSModule (io.druid.guice.AWSModule)1 AnnouncerModule (io.druid.guice.AnnouncerModule)1 CoordinatorDiscoveryModule (io.druid.guice.CoordinatorDiscoveryModule)1 DruidProcessingModule (io.druid.guice.DruidProcessingModule)1 DruidSecondaryModule (io.druid.guice.DruidSecondaryModule)1 FirehoseModule (io.druid.guice.FirehoseModule)1 IndexingServiceDiscoveryModule (io.druid.guice.IndexingServiceDiscoveryModule)1 JacksonConfigManagerModule (io.druid.guice.JacksonConfigManagerModule)1 JavaScriptModule (io.druid.guice.JavaScriptModule)1 LifecycleModule (io.druid.guice.LifecycleModule)1