@ApiOperation(value = "Get data-source", authorizations = @Authorization(value = "master_key")) @Path("/get/database") @JsonRequest public CustomDataSource getDatabase(@Named("project") RequestContext context, String schema) { return service.getDatabase(context.project, schema); }
@ApiOperation(value = "Get data-source", authorizations = @Authorization(value = "master_key")) @Path("/get/file") @JsonRequest public RemoteTable getFile(@Named("project") RequestContext context, String tableName) { return service.getFile(context.project, tableName); }
@ApiOperation(value = "Get file", authorizations = @Authorization(value = "master_key")) @Path("/list/file") @JsonRequest public Map<String, RemoteTable> getFiles(@Named("project") RequestContext context) { return service.getFiles(context.project); }
Map<String, RemoteTable> files = customDataSource.getFiles(project); CustomDataSource dataSource; try { dataSource = customDataSource.getDatabase(project, prefix); } catch (RakamException e) { if (e.getStatusCode() == NOT_FOUND) {
@BeforeSuite public void setup() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg10(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig(), "set time zone 'UTC'"); FieldDependencyBuilder.FieldDependency build = new FieldDependencyBuilder().build(); EventBus eventBus = new EventBus(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), eventBus, new ProjectConfig()); queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); eventStore = new PostgresqlEventStore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), build); super.setup(); }
@ApiOperation(value = "List data-sources", authorizations = @Authorization(value = "master_key")) @Path("/list") @GET public CustomDataSourceService.CustomDataSourceList listDatabases(@Named("project") RequestContext context) { CustomDataSourceService.CustomDataSourceList customDataSourceList = service.listDatabases(context.project); for (CustomDataSource customDataSource : customDataSourceList.customDataSources) { customDataSource.options.setPassword(null); } return customDataSourceList; }
@ApiOperation(value = "Add data-source", authorizations = @Authorization(value = "master_key")) @Path("/add/database") @JsonRequest public SuccessMessage addDatabase(@Named("project") RequestContext context, @BodyParam CustomDataSource hook) { return service.addDatabase(context.project, hook); }
@ApiOperation(value = "Add file data-source", authorizations = @Authorization(value = "master_key")) @Path("/add/file") @JsonRequest public SuccessMessage addFile(@Named("project") RequestContext context, @ApiParam("tableName") String tableName, @ApiParam("options") CustomDataSourceService.DiscoverableRemoteTable hook) { return service.addFile(context.project, tableName, hook); }
@BeforeSuite public void setup() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg9(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig(), "set time zone 'UTC'"); FieldDependencyBuilder.FieldDependency build = new FieldDependencyBuilder().build(); EventBus eventBus = new EventBus(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), eventBus, new ProjectConfig()); queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); eventStore = new PostgresqlEventStore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), build); super.setup(); }
CustomDataSourceList customDataSourceList = listDatabases(project); for (CustomDataSource customDataSource : customDataSourceList.customDataSources) { List<String> builder = new ArrayList<>();
public CompletableFuture<List<SchemaField>> schemaTable(String project, String schema, String table) { CustomDataSource customDataSource = getDatabase(project, schema); List<SchemaField> builder = new ArrayList<>(); return CompletableFuture.supplyAsync(() -> { SupportedCustomDatabase source = SupportedCustomDatabase.getAdapter(customDataSource.type); try (Connection conn = source.getDataSource().openConnection(customDataSource.options)) { ResultSet dbColumns = conn.getMetaData().getColumns(null, customDataSource.options.getSchema(), table, null); while (dbColumns.next()) { String columnName = dbColumns.getString("COLUMN_NAME"); FieldType fieldType; try { fieldType = fromSql(dbColumns.getInt("DATA_TYPE"), dbColumns.getString("TYPE_NAME")); } catch (UnsupportedOperationException e) { continue; } builder.add(new SchemaField(columnName, fieldType)); } return builder; } catch (SQLException e) { throw Throwables.propagate(e); } }, executor); }
@BeforeSuite public void setup() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg9(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig()); FieldDependencyBuilder.FieldDependency build = new FieldDependencyBuilder().build(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlVersion(dataSource), new EventBus(), new ProjectConfig()); PostgresqlQueryExecutor queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); eventStore = new PostgresqlEventStore(dataSource, new PostgresqlVersion(dataSource), build); retentionQueryExecutor = new PostgresqlRetentionQueryExecutor(new ProjectConfig(), queryExecutor, metastore); retentionQueryExecutor.setup(); super.setup(); }
public SuccessMessage addFile(String project, @ApiParam("tableName") String tableName, @ApiParam("options") DiscoverableRemoteTable hook) { try (Handle handle = dbi.open()) { try { handle.createStatement("INSERT INTO custom_file_source (project, table_name, options) " + "VALUES (:project, :table_name, :options)") .bind("project", project) .bind("table_name", tableName) .bind("options", JsonHelper.encode(hook.getTable())) .execute(); return SuccessMessage.success(); } catch (Exception e) { try { getFile(project, tableName); throw new AlreadyExistsException("Custom file", BAD_REQUEST); } catch (RakamException e1) { if (e1.getStatusCode() != NOT_FOUND) { throw e1; } else { throw e; } } } } }
CustomDataSource dataSource = customDataSource.getDatabase(project, prefix);
@BeforeSuite public void setup() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg10(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig()); FieldDependencyBuilder.FieldDependency build = new FieldDependencyBuilder().build(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlVersion(dataSource), new EventBus(), new ProjectConfig()); PostgresqlQueryExecutor queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); eventStore = new PostgresqlEventStore(dataSource, new PostgresqlVersion(dataSource), build); retentionQueryExecutor = new PostgresqlRetentionQueryExecutor(new ProjectConfig(), queryExecutor, metastore); retentionQueryExecutor.setup(); super.setup(); }
public SuccessMessage addDatabase(String project, CustomDataSource hook) { try (Handle handle = dbi.open()) { try { handle.createStatement("INSERT INTO custom_data_source (project, schema_name, type, options) " + "VALUES (:project, :schema_name, :type, :options)") .bind("project", project) .bind("schema_name", hook.schemaName) .bind("type", hook.type) .bind("options", JsonHelper.encode(hook.options)) .execute(); return SuccessMessage.success(); } catch (Exception e) { try { getDatabase(project, hook.schemaName); throw new AlreadyExistsException("Custom database", BAD_REQUEST); } catch (RakamException e1) { if (e1.getStatusCode() != NOT_FOUND) { throw e1; } else { throw e; } } } } }
@Override @BeforeSuite public void setup() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg10(); InMemoryQueryMetadataStore queryMetadataStore = new InMemoryQueryMetadataStore(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig(), "set time zone 'UTC'"); FieldDependencyBuilder.FieldDependency build = new FieldDependencyBuilder().build(); EventBus eventBus = new EventBus(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), eventBus, new ProjectConfig()); PostgresqlQueryExecutor queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); PostgresqlMaterializedViewService postgresqlMaterializedViewService = new PostgresqlMaterializedViewService(queryExecutor, queryMetadataStore, Clock.systemUTC()); eventStore = new PostgresqlEventStore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), build); PostgresqlMaterializedViewService materializedViewService = postgresqlMaterializedViewService; eventExplorer = new PostgresqlEventExplorer( new ProjectConfig(), new QueryExecutorService(queryExecutor, metastore, materializedViewService, '"'), materializedViewService); super.setup(); }
@Override @BeforeSuite public void setup() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg9(); InMemoryQueryMetadataStore queryMetadataStore = new InMemoryQueryMetadataStore(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig(), "set time zone 'UTC'"); FieldDependencyBuilder.FieldDependency build = new FieldDependencyBuilder().build(); EventBus eventBus = new EventBus(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), eventBus, new ProjectConfig()); PostgresqlQueryExecutor queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); PostgresqlMaterializedViewService postgresqlMaterializedViewService = new PostgresqlMaterializedViewService(queryExecutor, queryMetadataStore, Clock.systemUTC()); eventStore = new PostgresqlEventStore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), build); PostgresqlMaterializedViewService materializedViewService = postgresqlMaterializedViewService; eventExplorer = new PostgresqlEventExplorer( new ProjectConfig(), new QueryExecutorService(queryExecutor, metastore, materializedViewService, '"'), materializedViewService); super.setup(); }
@BeforeSuite @Override public void setUp() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg10(); InMemoryQueryMetadataStore queryMetadataStore = new InMemoryQueryMetadataStore(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig(), "set time zone 'UTC'"); EventBus eventBus = new EventBus(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), eventBus, new ProjectConfig()); PostgresqlQueryExecutor queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); PostgresqlMaterializedViewService materializedViewService = new PostgresqlMaterializedViewService(queryExecutor, queryMetadataStore, Clock.systemUTC()); QueryExecutorService queryExecutorService = new QueryExecutorService(queryExecutor, metastore, materializedViewService, '"'); configManager = new PostgresqlConfigManager(dataSource); configManager.setup(); PostgresqlUserStorage userStorage = new PostgresqlUserStorage(queryExecutorService, materializedViewService, configManager, queryExecutor); PostgresqlEventStore postgresqlEventStore = new PostgresqlEventStore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), new FieldDependencyBuilder().build()); userService = new PostgresqlUserService(new ProjectConfig(), configManager, postgresqlEventStore, userStorage, metastore, queryExecutor); super.setUp(); }
@BeforeSuite @Override public void setUp() throws Exception { testingPostgresqlServer = new TestingEnvironmentPg9(); InMemoryQueryMetadataStore queryMetadataStore = new InMemoryQueryMetadataStore(); JDBCPoolDataSource dataSource = JDBCPoolDataSource.getOrCreateDataSource(testingPostgresqlServer.getPostgresqlConfig(), "set time zone 'UTC'"); EventBus eventBus = new EventBus(); metastore = new PostgresqlMetastore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), eventBus, new ProjectConfig()); PostgresqlQueryExecutor queryExecutor = new PostgresqlQueryExecutor(new ProjectConfig(), dataSource, metastore, new CustomDataSourceService(dataSource), false); PostgresqlMaterializedViewService materializedViewService = new PostgresqlMaterializedViewService(queryExecutor, queryMetadataStore, Clock.systemUTC()); QueryExecutorService queryExecutorService = new QueryExecutorService(queryExecutor, metastore, materializedViewService, '"'); configManager = new PostgresqlConfigManager(dataSource); configManager.setup(); PostgresqlUserStorage userStorage = new PostgresqlUserStorage(queryExecutorService, materializedViewService, configManager, queryExecutor); PostgresqlEventStore postgresqlEventStore = new PostgresqlEventStore(dataSource, new PostgresqlModule.PostgresqlVersion(dataSource), new FieldDependencyBuilder().build()); userService = new PostgresqlUserService(new ProjectConfig(), configManager, postgresqlEventStore, userStorage, metastore, queryExecutor); super.setUp(); }