private void resetMetadataStore(Injector injector) { log.info("==========================================================================="); log.info("Deleting all Records from Metadata Storage."); log.info("==========================================================================="); MetadataStorageConnector connector = injector.getInstance(MetadataStorageConnector.class); MetadataStorageTablesConfig tablesConfig = injector.getInstance(MetadataStorageTablesConfig.class); String[] tables = new String[]{ tablesConfig.getDataSourceTable(), tablesConfig.getPendingSegmentsTable(), tablesConfig.getSegmentsTable(), tablesConfig.getRulesTable(), tablesConfig.getConfigTable(), tablesConfig.getTasksTable(), tablesConfig.getTaskLockTable(), tablesConfig.getTaskLogTable(), tablesConfig.getAuditTable(), tablesConfig.getSupervisorTable() }; for (String table : tables) { connector.deleteAllRecords(table); } }
public static MetadataStorageTablesConfig fromBase(String base) { return new MetadataStorageTablesConfig(base, null, null, null, null, null, null, null, null, null, null); }
@Override public <A, B, C, D> MetadataStorageActionHandler<A, B, C, D> create( final String entryType, MetadataStorageActionHandlerTypes<A, B, C, D> payloadTypes ) { return new DerbyMetadataStorageActionHandler<>( connector, jsonMapper, payloadTypes, entryType, config.getEntryTable(entryType), config.getLogTable(entryType), config.getLockTable(entryType) ); } }
@Override public void createTaskTables() { if (config.get().isCreateTables()) { final MetadataStorageTablesConfig tablesConfig = tablesConfigSupplier.get(); final String entryType = tablesConfig.getTaskEntryType(); createEntryTable(tablesConfig.getEntryTable(entryType)); createLogTable(tablesConfig.getLogTable(entryType), entryType); createLockTable(tablesConfig.getLockTable(entryType), entryType); } }
final String entryType = tablesConfig.getTaskEntryType(); tables.add(tablesConfig.getConfigTable()); tables.add(tablesConfig.getSegmentsTable()); tables.add(tablesConfig.getRulesTable()); tables.add(tablesConfig.getLockTable(entryType)); tables.add(tablesConfig.getLogTable(entryType)); tables.add(tablesConfig.getEntryTable(entryType)); tables.add(tablesConfig.getAuditTable()); tables.add(tablesConfig.getSupervisorTable());
MetadataStorageTablesConfig config = injector.getInstance(MetadataStorageTablesConfig.class); Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.base"), config.getBase()); Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.segments"), config.getSegmentsTable()); Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.rules"), config.getRulesTable()); Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.config"), config.getConfigTable()); Assert.assertEquals( props.getProperty("druid.metadata.storage.tables.tasks"), config.getEntryTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE) ); Assert.assertEquals( props.getProperty("druid.metadata.storage.tables.taskLog"), config.getLogTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE) ); Assert.assertEquals( props.getProperty("druid.metadata.storage.tables.taskLock"), config.getLockTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE) ); Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.dataSource"), config.getDataSourceTable()); Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.supervisors"), config.getSupervisorTable());
@Inject public ConfigManager(MetadataStorageConnector dbConnector, Supplier<MetadataStorageTablesConfig> dbTables, Supplier<ConfigManagerConfig> config) { this.dbConnector = dbConnector; this.config = config; this.exec = ScheduledExecutors.fixed(1, "config-manager-%s"); this.watchedConfigs = new ConcurrentHashMap<>(); this.configTable = dbTables.get().getConfigTable(); }
private String getSegmentsTable() { return dbTables.get().getSegmentsTable(); }
/** * Read dataSource metadata as bytes, from a specific handle. Returns null if there is no metadata. */ private byte[] getDataSourceMetadataWithHandleAsBytes( final Handle handle, final String dataSource ) { return connector.lookupWithHandle( handle, dbTables.getDataSourceTable(), "dataSource", "commit_metadata_payload", dataSource ); }
@After public void cleanup() { dropTable(tablesConfig.getAuditTable()); dropTable(tablesConfig.getRulesTable()); }
private String getRulesTable() { return dbTables.getRulesTable(); } }
private String getSupervisorsTable() { return dbTables.get().getSupervisorTable(); } }
public String getAuditTable() { return dbTables.get().getAuditTable(); }
@Override public void createConfigTable() { if (config.get().isCreateTables()) { createConfigTable(tablesConfigSupplier.get().getConfigTable()); } }
@Override public void createSegmentTable() { if (config.get().isCreateTables()) { createSegmentTable(tablesConfigSupplier.get().getSegmentsTable()); } }
@Override public void createTaskTables() { if (config.get().isCreateTables()) { final MetadataStorageTablesConfig tablesConfig = tablesConfigSupplier.get(); final String entryType = tablesConfig.getTaskEntryType(); createEntryTable(tablesConfig.getEntryTable(entryType)); createLogTable(tablesConfig.getLogTable(entryType), entryType); createLockTable(tablesConfig.getLockTable(entryType), entryType); } }
@Override public void createDataSourceTable() { if (config.get().isCreateTables()) { createDataSourceTable(tablesConfigSupplier.get().getDataSourceTable()); } }
@Override public void createRulesTable() { if (config.get().isCreateTables()) { createRulesTable(tablesConfigSupplier.get().getRulesTable()); } }
@Override public void createSupervisorsTable() { if (config.get().isCreateTables()) { createSupervisorsTable(tablesConfigSupplier.get().getSupervisorTable()); } }
@Override public void createAuditTable() { if (config.get().isCreateTables()) { createAuditTable(tablesConfigSupplier.get().getAuditTable()); } }