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);
}
Aggregations