Search in sources :

Example 1 with DatabusRelaySourcesInFiles

use of com.linkedin.databus2.relay.config.DatabusRelaySourcesInFiles in project databus by linkedin.

the class DevRelayConfigGenerator method generateRelayConfig.

public static void generateRelayConfig(String schemaRegistryLocation, String dbName, String uri, String outputDir, List<String> srcNames, SchemaMetaDataManager manager) throws Exception {
    PhysicalSourceConfig config = new PhysicalSourceConfig();
    FileSystemSchemaRegistryService s = FileSystemSchemaRegistryService.build(new FileSystemSchemaRegistryService.StaticConfig(new File(schemaRegistryLocation), 0, false, false));
    dbName = dbName.trim().toLowerCase();
    config.setName(dbName);
    config.setUri(uri);
    for (String srcName : srcNames) {
        VersionedSchema schema = null;
        schema = s.fetchLatestVersionedSchemaBySourceName(srcName);
        String dbObjectName = SchemaHelper.getMetaField(schema.getSchema(), "dbFieldName");
        LogicalSourceConfig c = new LogicalSourceConfig();
        c.setId(manager.getSrcId(srcName));
        c.setName(srcName);
        c.setUri(dbName + "." + dbObjectName);
        c.setPartitionFunction("constant:1");
        config.addSource(c);
    }
    DatabusRelaySourcesInFiles relaySourcesInFiles = new DatabusRelaySourcesInFiles(outputDir);
    relaySourcesInFiles.add(dbName, config);
    boolean success = relaySourcesInFiles.save();
    if (!success)
        throw new RuntimeException("Unable to create the dev relay config for DB :" + dbName);
}
Also used : PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) DatabusRelaySourcesInFiles(com.linkedin.databus2.relay.config.DatabusRelaySourcesInFiles) FileSystemSchemaRegistryService(com.linkedin.databus2.schemas.FileSystemSchemaRegistryService) File(java.io.File) VersionedSchema(com.linkedin.databus2.schemas.VersionedSchema)

Aggregations

DatabusRelaySourcesInFiles (com.linkedin.databus2.relay.config.DatabusRelaySourcesInFiles)1 LogicalSourceConfig (com.linkedin.databus2.relay.config.LogicalSourceConfig)1 PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)1 FileSystemSchemaRegistryService (com.linkedin.databus2.schemas.FileSystemSchemaRegistryService)1 VersionedSchema (com.linkedin.databus2.schemas.VersionedSchema)1 File (java.io.File)1