Search in sources :

Example 1 with MetadataStorageConnectorConfig

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

the class JdbcDataFetcherTest method testSerDesr.

@Test
public void testSerDesr() throws IOException {
    JdbcDataFetcher jdbcDataFetcher = new JdbcDataFetcher(new MetadataStorageConnectorConfig(), "table", "keyColumn", "ValueColumn", 100);
    DefaultObjectMapper mapper = new DefaultObjectMapper();
    String jdbcDataFetcherSer = mapper.writeValueAsString(jdbcDataFetcher);
    Assert.assertEquals(jdbcDataFetcher, mapper.reader(DataFetcher.class).readValue(jdbcDataFetcherSer));
}
Also used : MetadataStorageConnectorConfig(io.druid.metadata.MetadataStorageConnectorConfig) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 2 with MetadataStorageConnectorConfig

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

the class TaskActionTestKit method before.

@Override
public void before() {
    taskStorage = new HeapMemoryTaskStorage(new TaskStorageConfig(new Period("PT24H")));
    taskLockbox = new TaskLockbox(taskStorage);
    testDerbyConnector = new TestDerbyConnector(Suppliers.ofInstance(new MetadataStorageConnectorConfig()), Suppliers.ofInstance(metadataStorageTablesConfig));
    metadataStorageCoordinator = new IndexerSQLMetadataStorageCoordinator(new TestUtils().getTestObjectMapper(), metadataStorageTablesConfig, testDerbyConnector);
    taskActionToolbox = new TaskActionToolbox(taskLockbox, metadataStorageCoordinator, new NoopServiceEmitter(), EasyMock.createMock(SupervisorManager.class));
    testDerbyConnector.createDataSourceTable();
    testDerbyConnector.createPendingSegmentsTable();
    testDerbyConnector.createSegmentTable();
    testDerbyConnector.createRulesTable();
    testDerbyConnector.createConfigTable();
    testDerbyConnector.createTaskTables();
    testDerbyConnector.createAuditTable();
}
Also used : IndexerSQLMetadataStorageCoordinator(io.druid.metadata.IndexerSQLMetadataStorageCoordinator) TestUtils(io.druid.indexing.common.TestUtils) MetadataStorageConnectorConfig(io.druid.metadata.MetadataStorageConnectorConfig) TaskStorageConfig(io.druid.indexing.common.config.TaskStorageConfig) HeapMemoryTaskStorage(io.druid.indexing.overlord.HeapMemoryTaskStorage) Period(org.joda.time.Period) TaskLockbox(io.druid.indexing.overlord.TaskLockbox) NoopServiceEmitter(io.druid.server.metrics.NoopServiceEmitter) TestDerbyConnector(io.druid.metadata.TestDerbyConnector)

Example 3 with MetadataStorageConnectorConfig

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

the class HadoopIngestionSpecTest method testDbUpdaterJobSpec.

@Test
public void testDbUpdaterJobSpec() throws Exception {
    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(io.druid.metadata.MetadataStorageConnectorConfig) MetadataStorageUpdaterJobSpec(io.druid.indexer.updater.MetadataStorageUpdaterJobSpec) Test(org.junit.Test)

Example 4 with MetadataStorageConnectorConfig

use of io.druid.metadata.MetadataStorageConnectorConfig in project hive by apache.

the class DruidStorageHandler method getConnector.

private SQLMetadataConnector getConnector() {
    if (connector != null) {
        return connector;
    }
    final String dbType = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_TYPE);
    final String username = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_USERNAME);
    final String password = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_PASSWORD);
    final String uri = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_URI);
    final Supplier<MetadataStorageConnectorConfig> storageConnectorConfigSupplier = Suppliers.<MetadataStorageConnectorConfig>ofInstance(new MetadataStorageConnectorConfig() {

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

        @Override
        public String getUser() {
            return Strings.emptyToNull(username);
        }

        @Override
        public String getPassword() {
            return Strings.emptyToNull(password);
        }
    });
    if (dbType.equals("mysql")) {
        connector = new MySQLConnector(storageConnectorConfigSupplier, Suppliers.ofInstance(getDruidMetadataStorageTablesConfig()));
    } else if (dbType.equals("postgresql")) {
        connector = new PostgreSQLConnector(storageConnectorConfigSupplier, Suppliers.ofInstance(getDruidMetadataStorageTablesConfig()));
    } else if (dbType.equals("derby")) {
        connector = new DerbyConnector(new DerbyMetadataStorage(storageConnectorConfigSupplier.get()), storageConnectorConfigSupplier, Suppliers.ofInstance(getDruidMetadataStorageTablesConfig()));
    } else {
        throw new IllegalStateException(String.format("Unknown metadata storage type [%s]", dbType));
    }
    return connector;
}
Also used : DerbyConnector(io.druid.metadata.storage.derby.DerbyConnector) MetadataStorageConnectorConfig(io.druid.metadata.MetadataStorageConnectorConfig) MySQLConnector(io.druid.metadata.storage.mysql.MySQLConnector) PostgreSQLConnector(io.druid.metadata.storage.postgresql.PostgreSQLConnector) DerbyMetadataStorage(io.druid.metadata.storage.derby.DerbyMetadataStorage)

Aggregations

MetadataStorageConnectorConfig (io.druid.metadata.MetadataStorageConnectorConfig)4 Test (org.junit.Test)2 MetadataStorageUpdaterJobSpec (io.druid.indexer.updater.MetadataStorageUpdaterJobSpec)1 TestUtils (io.druid.indexing.common.TestUtils)1 TaskStorageConfig (io.druid.indexing.common.config.TaskStorageConfig)1 HeapMemoryTaskStorage (io.druid.indexing.overlord.HeapMemoryTaskStorage)1 TaskLockbox (io.druid.indexing.overlord.TaskLockbox)1 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)1 IndexerSQLMetadataStorageCoordinator (io.druid.metadata.IndexerSQLMetadataStorageCoordinator)1 TestDerbyConnector (io.druid.metadata.TestDerbyConnector)1 DerbyConnector (io.druid.metadata.storage.derby.DerbyConnector)1 DerbyMetadataStorage (io.druid.metadata.storage.derby.DerbyMetadataStorage)1 MySQLConnector (io.druid.metadata.storage.mysql.MySQLConnector)1 PostgreSQLConnector (io.druid.metadata.storage.postgresql.PostgreSQLConnector)1 NoopServiceEmitter (io.druid.server.metrics.NoopServiceEmitter)1 Period (org.joda.time.Period)1