Search in sources :

Example 6 with ExtensionsConfig

use of io.druid.guice.ExtensionsConfig in project druid by druid-io.

the class PullDependenciesTest method setUp.

@Before
public void setUp() throws Exception {
    localRepo = temporaryFolder.newFolder();
    extensionToJars = new HashMap<>();
    extensionToJars.put(extension_A, ImmutableList.of("a.jar", "b.jar", "c.jar"));
    extensionToJars.put(extension_B, ImmutableList.of("d.jar", "e.jar"));
    extensionToJars.put(hadoop_client_2_3_0, ImmutableList.of("f.jar", "g.jar"));
    extensionToJars.put(hadoop_client_2_4_0, ImmutableList.of("h.jar", "i.jar"));
    rootExtensionsDir = new File(temporaryFolder.getRoot(), "extensions");
    rootHadoopDependenciesDir = new File(temporaryFolder.getRoot(), "druid_hadoop_dependencies");
    pullDependencies = new PullDependencies(new DefaultTeslaAether() {

        @Override
        public List<Artifact> resolveArtifacts(DependencyRequest request) throws DependencyResolutionException {
            return getArtifactsForExtension(request.getCollectRequest().getRoot().getArtifact());
        }
    }, new ExtensionsConfig() {

        @Override
        public String getDirectory() {
            return rootExtensionsDir.getAbsolutePath();
        }

        @Override
        public String getHadoopDependenciesDir() {
            return rootHadoopDependenciesDir.getAbsolutePath();
        }
    });
    pullDependencies.coordinates = ImmutableList.of(EXTENSION_A_COORDINATE, EXTENSION_B_COORDINATE);
    pullDependencies.hadoopCoordinates = ImmutableList.of(HADOOP_CLIENT_2_3_0_COORDINATE, HADOOP_CLIENT_2_4_0_COORDINATE);
}
Also used : DependencyRequest(org.eclipse.aether.resolution.DependencyRequest) DefaultTeslaAether(io.tesla.aether.internal.DefaultTeslaAether) ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) Before(org.junit.Before)

Example 7 with ExtensionsConfig

use of io.druid.guice.ExtensionsConfig in project druid by druid-io.

the class Initialization method makeInjectorWithModules.

public static Injector makeInjectorWithModules(final Injector baseInjector, Iterable<? extends Module> modules) {
    final ModuleList defaultModules = new ModuleList(baseInjector);
    defaultModules.addModules(// New modules should be added after Log4jShutterDownerModule
    new Log4jShutterDownerModule(), new DruidAuthModule(), new LifecycleModule(), EmitterModule.class, HttpClientModule.global(), new HttpClientModule("druid.broker.http", Client.class), new CuratorModule(), new AnnouncerModule(), new DruidProcessingModule(), new AWSModule(), new MetricsModule(), new ServerModule(), new StorageNodeModule(), new JettyServerModule(), new QueryableModule(), new QueryRunnerFactoryModule(), new DiscoveryModule(), new ServerViewModule(), new MetadataConfigModule(), new DerbyMetadataStorageDruidModule(), new JacksonConfigManagerModule(), new IndexingServiceDiscoveryModule(), new CoordinatorDiscoveryModule(), new LocalDataStorageDruidModule(), new FirehoseModule(), new ParsersModule(), new JavaScriptModule(), new StartupLoggingModule());
    ModuleList actualModules = new ModuleList(baseInjector);
    actualModules.addModule(DruidSecondaryModule.class);
    for (Object module : modules) {
        actualModules.addModule(module);
    }
    Module intermediateModules = Modules.override(defaultModules.getModules()).with(actualModules.getModules());
    ModuleList extensionModules = new ModuleList(baseInjector);
    final ExtensionsConfig config = baseInjector.getInstance(ExtensionsConfig.class);
    for (DruidModule module : Initialization.getFromExtensions(config, DruidModule.class)) {
        extensionModules.addModule(module);
    }
    return Guice.createInjector(Modules.override(intermediateModules).with(extensionModules.getModules()));
}
Also used : CuratorModule(io.druid.curator.CuratorModule) DiscoveryModule(io.druid.curator.discovery.DiscoveryModule) CoordinatorDiscoveryModule(io.druid.guice.CoordinatorDiscoveryModule) IndexingServiceDiscoveryModule(io.druid.guice.IndexingServiceDiscoveryModule) ServerViewModule(io.druid.guice.ServerViewModule) JettyServerModule(io.druid.server.initialization.jetty.JettyServerModule) JettyServerModule(io.druid.server.initialization.jetty.JettyServerModule) ServerModule(io.druid.guice.ServerModule) FirehoseModule(io.druid.guice.FirehoseModule) AWSModule(io.druid.guice.AWSModule) ParsersModule(io.druid.guice.ParsersModule) LocalDataStorageDruidModule(io.druid.guice.LocalDataStorageDruidModule) DerbyMetadataStorageDruidModule(io.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule) Client(io.druid.guice.annotations.Client) ExtensionsConfig(io.druid.guice.ExtensionsConfig) JacksonConfigManagerModule(io.druid.guice.JacksonConfigManagerModule) LifecycleModule(io.druid.guice.LifecycleModule) IndexingServiceDiscoveryModule(io.druid.guice.IndexingServiceDiscoveryModule) QueryRunnerFactoryModule(io.druid.guice.QueryRunnerFactoryModule) LocalDataStorageDruidModule(io.druid.guice.LocalDataStorageDruidModule) StartupLoggingModule(io.druid.guice.StartupLoggingModule) DerbyMetadataStorageDruidModule(io.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule) QueryableModule(io.druid.guice.QueryableModule) MetadataConfigModule(io.druid.guice.MetadataConfigModule) CoordinatorDiscoveryModule(io.druid.guice.CoordinatorDiscoveryModule) DruidProcessingModule(io.druid.guice.DruidProcessingModule) DruidAuthModule(io.druid.guice.security.DruidAuthModule) MetricsModule(io.druid.server.metrics.MetricsModule) AnnouncerModule(io.druid.guice.AnnouncerModule) StorageNodeModule(io.druid.guice.StorageNodeModule) Module(com.google.inject.Module) ParsersModule(io.druid.guice.ParsersModule) QueryableModule(io.druid.guice.QueryableModule) DiscoveryModule(io.druid.curator.discovery.DiscoveryModule) LocalDataStorageDruidModule(io.druid.guice.LocalDataStorageDruidModule) AnnouncerModule(io.druid.guice.AnnouncerModule) AWSModule(io.druid.guice.AWSModule) CoordinatorDiscoveryModule(io.druid.guice.CoordinatorDiscoveryModule) MetricsModule(io.druid.server.metrics.MetricsModule) FirehoseModule(io.druid.guice.FirehoseModule) DruidAuthModule(io.druid.guice.security.DruidAuthModule) JavaScriptModule(io.druid.guice.JavaScriptModule) EmitterModule(io.druid.server.initialization.EmitterModule) LifecycleModule(io.druid.guice.LifecycleModule) ServerViewModule(io.druid.guice.ServerViewModule) JacksonConfigManagerModule(io.druid.guice.JacksonConfigManagerModule) MetadataConfigModule(io.druid.guice.MetadataConfigModule) CuratorModule(io.druid.curator.CuratorModule) IndexingServiceDiscoveryModule(io.druid.guice.IndexingServiceDiscoveryModule) StartupLoggingModule(io.druid.guice.StartupLoggingModule) DerbyMetadataStorageDruidModule(io.druid.metadata.storage.derby.DerbyMetadataStorageDruidModule) JettyServerModule(io.druid.server.initialization.jetty.JettyServerModule) StorageNodeModule(io.druid.guice.StorageNodeModule) ServerModule(io.druid.guice.ServerModule) HttpClientModule(io.druid.guice.http.HttpClientModule) DruidProcessingModule(io.druid.guice.DruidProcessingModule) QueryRunnerFactoryModule(io.druid.guice.QueryRunnerFactoryModule) DruidSecondaryModule(io.druid.guice.DruidSecondaryModule) HttpClientModule(io.druid.guice.http.HttpClientModule) JavaScriptModule(io.druid.guice.JavaScriptModule)

Example 8 with ExtensionsConfig

use of io.druid.guice.ExtensionsConfig in project druid by druid-io.

the class Main method main.

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    final Cli.CliBuilder<Runnable> builder = Cli.builder("druid");
    builder.withDescription("Druid command-line runner.").withDefaultCommand(Help.class).withCommands(Help.class, Version.class);
    builder.withGroup("server").withDescription("Run one of the Druid server types.").withDefaultCommand(Help.class).withCommands(CliCoordinator.class, CliHistorical.class, CliBroker.class, CliRealtime.class, CliOverlord.class, CliMiddleManager.class, CliRouter.class);
    builder.withGroup("example").withDescription("Run an example").withDefaultCommand(Help.class).withCommands(CliRealtimeExample.class);
    builder.withGroup("tools").withDescription("Various tools for working with Druid").withDefaultCommand(Help.class).withCommands(DruidJsonValidator.class, PullDependencies.class, CreateTables.class, InsertSegment.class, DumpSegment.class, ResetCluster.class, ValidateSegments.class);
    builder.withGroup("index").withDescription("Run indexing for druid").withDefaultCommand(Help.class).withCommands(CliHadoopIndexer.class);
    builder.withGroup("internal").withDescription("Processes that Druid runs \"internally\", you should rarely use these directly").withDefaultCommand(Help.class).withCommands(CliPeon.class, CliInternalHadoopIndexer.class);
    final Injector injector = GuiceInjectors.makeStartupInjector();
    final ExtensionsConfig config = injector.getInstance(ExtensionsConfig.class);
    final Collection<CliCommandCreator> extensionCommands = Initialization.getFromExtensions(config, CliCommandCreator.class);
    for (CliCommandCreator creator : extensionCommands) {
        creator.addCommands(builder);
    }
    final Cli<Runnable> cli = builder.build();
    try {
        final Runnable command = cli.parse(args);
        if (!(command instanceof Help)) {
            // Hack to work around Help not liking being injected
            injector.injectMembers(command);
        }
        command.run();
    } catch (ParseException e) {
        System.out.println("ERROR!!!!");
        System.out.println(e.getMessage());
        System.out.println("===");
        cli.parse(new String[] { "help" }).run();
        System.exit(1);
    }
}
Also used : Cli(io.airlift.airline.Cli) Help(io.airlift.airline.Help) Injector(com.google.inject.Injector) ParseException(io.airlift.airline.ParseException) ExtensionsConfig(io.druid.guice.ExtensionsConfig)

Example 9 with ExtensionsConfig

use of io.druid.guice.ExtensionsConfig in project druid by druid-io.

the class InitializationTest method testGetExtensionFilesToLoad_empty_extensions_dir.

@Test
public void testGetExtensionFilesToLoad_empty_extensions_dir() throws IOException {
    final File extensionsDir = temporaryFolder.newFolder();
    final ExtensionsConfig config = new ExtensionsConfig() {

        @Override
        public String getDirectory() {
            return extensionsDir.getAbsolutePath();
        }
    };
    Assert.assertArrayEquals("Empty root extensionsDir should return an empty array of File", new File[] {}, Initialization.getExtensionFilesToLoad(config));
}
Also used : ExtensionsConfig(io.druid.guice.ExtensionsConfig) File(java.io.File) Test(org.junit.Test)

Example 10 with ExtensionsConfig

use of io.druid.guice.ExtensionsConfig in project druid by druid-io.

the class InitializationTest method testGetExtensionFilesToLoad_with_load_list.

/**
   * druid.extension.load is specified, Initialization.getExtensionFilesToLoad is supposed to return all the extension
   * folders appeared in the load list.
   */
@Test
public void testGetExtensionFilesToLoad_with_load_list() throws IOException {
    final File extensionsDir = temporaryFolder.newFolder();
    final File absolutePathExtension = temporaryFolder.newFolder();
    final ExtensionsConfig config = new ExtensionsConfig() {

        @Override
        public List<String> getLoadList() {
            return Arrays.asList("mysql-metadata-storage", "druid-kafka-eight", absolutePathExtension.getAbsolutePath());
        }

        @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");
    final File random_extension = new File(extensionsDir, "random-extensions");
    mysql_metadata_storage.mkdir();
    druid_kafka_eight.mkdir();
    random_extension.mkdir();
    final File[] expectedFileList = new File[] { mysql_metadata_storage, druid_kafka_eight, absolutePathExtension };
    final File[] actualFileList = Initialization.getExtensionFilesToLoad(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