Search in sources :

Example 21 with MetadataStorageConnectorConfig

use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.

the class MySQLFirehoseDatabaseConnectorTest method testFailWhenNoAllowlistAndHaveProperty.

@Test
public void testFailWhenNoAllowlistAndHaveProperty() {
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:mysql://localhost:3306/test?user=maytas&password=secret&keyonly";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of(""));
    expectedException.expectMessage("The property [password] is not in the allowed list");
    expectedException.expect(IllegalArgumentException.class);
    new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 22 with MetadataStorageConnectorConfig

use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.

the class MySQLFirehoseDatabaseConnectorTest method testFindPropertyKeysFromInvalidConnectUrl.

@Test
public void testFindPropertyKeysFromInvalidConnectUrl() {
    final String url = "jdbc:mysql:/invalid-url::3006";
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return url;
        }
    };
    expectedException.expect(RuntimeException.class);
    expectedException.expectMessage(StringUtils.format("Invalid URL format for MySQL: [%s]", url));
    new MySQLFirehoseDatabaseConnector(connectorConfig, null, new JdbcAccessSecurityConfig(), mySQLConnectorDriverConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 23 with MetadataStorageConnectorConfig

use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.

the class MySQLFirehoseDatabaseConnectorTest method testSuccessOnlyValidProperty.

@Test
public void testSuccessOnlyValidProperty() {
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:mysql://localhost:3306/test?user=maytas&password=secret&keyonly";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("user", "password", "keyonly", "etc"));
    new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 24 with MetadataStorageConnectorConfig

use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.

the class HadoopIngestionSpecTest method testDbUpdaterJobSpec.

@Test
public void testDbUpdaterJobSpec() {
    final HadoopIngestionSpec schema;
    schema = jsonReadWriteRead("{\n" + "    \"ioConfig\": {\n" + "        \"type\": \"hadoop\",\n" + "        \"metadataUpdateSpec\": {\n" + "            \"type\": \"db\",\n" + "            \"connectURI\": \"jdbc:mysql://localhost/druid\",\n" + "            \"user\": \"rofl\",\n" + "            \"password\": \"p4ssw0rd\",\n" + "            \"segmentTable\": \"segments\"\n" + "        }\n" + "    }\n" + "}", HadoopIngestionSpec.class);
    final MetadataStorageUpdaterJobSpec spec = schema.getIOConfig().getMetadataUpdateSpec();
    final MetadataStorageConnectorConfig connectorConfig = spec.get();
    Assert.assertEquals("segments", spec.getSegmentTable());
    Assert.assertEquals("jdbc:mysql://localhost/druid", connectorConfig.getConnectURI());
    Assert.assertEquals("rofl", connectorConfig.getUser());
    Assert.assertEquals("p4ssw0rd", connectorConfig.getPassword());
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) MetadataStorageUpdaterJobSpec(org.apache.druid.indexer.updater.MetadataStorageUpdaterJobSpec) Test(org.junit.Test)

Example 25 with MetadataStorageConnectorConfig

use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.

the class CreateTables method getModules.

@Override
protected List<? extends Module> getModules() {
    return ImmutableList.of(// See https://github.com/apache/druid/pull/4429#discussion_r123602930
    new DruidProcessingModule(), new QueryableModule(), new QueryRunnerFactoryModule(), binder -> {
        JsonConfigProvider.bindInstance(binder, Key.get(MetadataStorageConnectorConfig.class), new MetadataStorageConnectorConfig() {

            @Override
            public String getConnectURI() {
                return connectURI;
            }

            @Override
            public String getUser() {
                return user;
            }

            @Override
            public String getPassword() {
                return password;
            }
        });
        JsonConfigProvider.bindInstance(binder, Key.get(MetadataStorageTablesConfig.class), MetadataStorageTablesConfig.fromBase(base));
        JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), new DruidNode("tools", "localhost", false, -1, null, true, false));
    });
}
Also used : MetadataStorageTablesConfig(org.apache.druid.metadata.MetadataStorageTablesConfig) MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) QueryableModule(org.apache.druid.guice.QueryableModule) DruidProcessingModule(org.apache.druid.guice.DruidProcessingModule) QueryRunnerFactoryModule(org.apache.druid.guice.QueryRunnerFactoryModule) DruidNode(org.apache.druid.server.DruidNode) Self(org.apache.druid.guice.annotations.Self)

Aggregations

MetadataStorageConnectorConfig (org.apache.druid.metadata.MetadataStorageConnectorConfig)26 Test (org.junit.Test)21 JdbcAccessSecurityConfig (org.apache.druid.server.initialization.JdbcAccessSecurityConfig)17 MetadataStorageTablesConfig (org.apache.druid.metadata.MetadataStorageTablesConfig)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DruidProcessingModule (org.apache.druid.guice.DruidProcessingModule)2 QueryRunnerFactoryModule (org.apache.druid.guice.QueryRunnerFactoryModule)2 QueryableModule (org.apache.druid.guice.QueryableModule)2 Self (org.apache.druid.guice.annotations.Self)2 MetadataStorageUpdaterJobSpec (org.apache.druid.indexer.updater.MetadataStorageUpdaterJobSpec)2 IndexerSQLMetadataStorageCoordinator (org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator)2 DruidNode (org.apache.druid.server.DruidNode)2 InjectableValues (com.fasterxml.jackson.databind.InjectableValues)1 TypeLiteral (com.google.inject.TypeLiteral)1 TestUtils (org.apache.druid.indexing.common.TestUtils)1 TaskStorageConfig (org.apache.druid.indexing.common.config.TaskStorageConfig)1 HeapMemoryTaskStorage (org.apache.druid.indexing.overlord.HeapMemoryTaskStorage)1 TaskLockbox (org.apache.druid.indexing.overlord.TaskLockbox)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 SegmentsMetadataManagerConfig (org.apache.druid.metadata.SegmentsMetadataManagerConfig)1