Search in sources :

Example 1 with SQLMetadataConnector

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

the class ExportMetadata method run.

@Override
public void run() {
    InjectableValues.Std injectableValues = new InjectableValues.Std();
    injectableValues.addValue(ObjectMapper.class, JSON_MAPPER);
    injectableValues.addValue(PruneSpecsHolder.class, PruneSpecsHolder.DEFAULT);
    JSON_MAPPER.setInjectableValues(injectableValues);
    if (hadoopStorageDirectory != null && newLocalPath != null) {
        throw new IllegalArgumentException("Only one of s3Bucket, hadoopStorageDirectory, and newLocalPath can be set.");
    }
    if (s3Bucket != null && (hadoopStorageDirectory != null || newLocalPath != null)) {
        throw new IllegalArgumentException("Only one of s3Bucket, hadoopStorageDirectory, and newLocalPath can be set.");
    }
    if (s3Bucket != null && s3baseKey == null) {
        throw new IllegalArgumentException("s3baseKey must be set if s3Bucket is set.");
    }
    final Injector injector = makeInjector();
    SQLMetadataConnector dbConnector = injector.getInstance(SQLMetadataConnector.class);
    MetadataStorageTablesConfig metadataStorageTablesConfig = injector.getInstance(MetadataStorageTablesConfig.class);
    // We export a raw CSV first, and then apply some conversions for easier imports:
    // Boolean strings are rewritten as 1 and 0
    // hexadecimal BLOB columns are rewritten with rewriteHexPayloadAsEscapedJson()
    log.info("Exporting datasource table: " + metadataStorageTablesConfig.getDataSourceTable());
    exportTable(dbConnector, metadataStorageTablesConfig.getDataSourceTable(), true);
    rewriteDatasourceExport(metadataStorageTablesConfig.getDataSourceTable());
    log.info("Exporting segments table: " + metadataStorageTablesConfig.getSegmentsTable());
    exportTable(dbConnector, metadataStorageTablesConfig.getSegmentsTable(), true);
    rewriteSegmentsExport(metadataStorageTablesConfig.getSegmentsTable());
    log.info("Exporting rules table: " + metadataStorageTablesConfig.getRulesTable());
    exportTable(dbConnector, metadataStorageTablesConfig.getRulesTable(), true);
    rewriteRulesExport(metadataStorageTablesConfig.getRulesTable());
    log.info("Exporting config table: " + metadataStorageTablesConfig.getConfigTable());
    exportTable(dbConnector, metadataStorageTablesConfig.getConfigTable(), true);
    rewriteConfigExport(metadataStorageTablesConfig.getConfigTable());
    log.info("Exporting supervisor table: " + metadataStorageTablesConfig.getSupervisorTable());
    exportTable(dbConnector, metadataStorageTablesConfig.getSupervisorTable(), true);
    rewriteSupervisorExport(metadataStorageTablesConfig.getSupervisorTable());
}
Also used : MetadataStorageTablesConfig(org.apache.druid.metadata.MetadataStorageTablesConfig) Injector(com.google.inject.Injector) SQLMetadataConnector(org.apache.druid.metadata.SQLMetadataConnector) InjectableValues(com.fasterxml.jackson.databind.InjectableValues)

Example 2 with SQLMetadataConnector

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

the class IngestionTestBase method setUpIngestionTestBase.

@Before
public void setUpIngestionTestBase() throws IOException {
    EmittingLogger.registerEmitter(new NoopServiceEmitter());
    temporaryFolder.create();
    final SQLMetadataConnector connector = derbyConnectorRule.getConnector();
    connector.createTaskTables();
    connector.createSegmentTable();
    taskStorage = new HeapMemoryTaskStorage(new TaskStorageConfig(null));
    storageCoordinator = new IndexerSQLMetadataStorageCoordinator(objectMapper, derbyConnectorRule.metadataTablesConfigSupplier().get(), derbyConnectorRule.getConnector());
    segmentsMetadataManager = new SqlSegmentsMetadataManager(objectMapper, SegmentsMetadataManagerConfig::new, derbyConnectorRule.metadataTablesConfigSupplier(), derbyConnectorRule.getConnector());
    lockbox = new TaskLockbox(taskStorage, storageCoordinator);
    segmentCacheManagerFactory = new SegmentCacheManagerFactory(getObjectMapper());
}
Also used : IndexerSQLMetadataStorageCoordinator(org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator) TaskStorageConfig(org.apache.druid.indexing.common.config.TaskStorageConfig) HeapMemoryTaskStorage(org.apache.druid.indexing.overlord.HeapMemoryTaskStorage) SegmentCacheManagerFactory(org.apache.druid.indexing.common.SegmentCacheManagerFactory) SQLMetadataConnector(org.apache.druid.metadata.SQLMetadataConnector) TaskLockbox(org.apache.druid.indexing.overlord.TaskLockbox) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) SqlSegmentsMetadataManager(org.apache.druid.metadata.SqlSegmentsMetadataManager) Before(org.junit.Before)

Aggregations

SQLMetadataConnector (org.apache.druid.metadata.SQLMetadataConnector)2 InjectableValues (com.fasterxml.jackson.databind.InjectableValues)1 Injector (com.google.inject.Injector)1 SegmentCacheManagerFactory (org.apache.druid.indexing.common.SegmentCacheManagerFactory)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 IndexerSQLMetadataStorageCoordinator (org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator)1 MetadataStorageTablesConfig (org.apache.druid.metadata.MetadataStorageTablesConfig)1 SqlSegmentsMetadataManager (org.apache.druid.metadata.SqlSegmentsMetadataManager)1 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)1 Before (org.junit.Before)1