use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class TestDbusEventBufferMult method convertToPhysicalSourceConfig.
public PhysicalSourceConfig convertToPhysicalSourceConfig(String str) {
_mapper = new ObjectMapper();
InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(str));
PhysicalSourceConfig pConfig = null;
try {
pConfig = _mapper.readValue(isr, PhysicalSourceConfig.class);
} catch (JsonParseException e) {
fail("Failed parsing", e);
} catch (JsonMappingException e) {
fail("Failed parsing", e);
} catch (IOException e) {
fail("Failed parsing", e);
}
try {
isr.close();
} catch (IOException e) {
fail("Failed", e);
}
return pConfig;
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class TestDbusEventBufferPersistence method createBufferMult.
private DbusEventBufferMult createBufferMult(DbusEventBuffer.StaticConfig config) throws IOException, InvalidConfigException {
ObjectMapper mapper = new ObjectMapper();
InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(TestDbusEventBufferMult._configSource1));
PhysicalSourceConfig pConfig1 = mapper.readValue(isr, PhysicalSourceConfig.class);
isr.close();
isr = new InputStreamReader(IOUtils.toInputStream(TestDbusEventBufferMult._configSource2));
PhysicalSourceConfig pConfig2 = mapper.readValue(isr, PhysicalSourceConfig.class);
PhysicalSourceStaticConfig pStatConf1 = pConfig1.build();
PhysicalSourceStaticConfig pStatConf2 = pConfig2.build();
PhysicalSourceStaticConfig[] _physConfigs = new PhysicalSourceStaticConfig[] { pStatConf1, pStatConf2 };
return new DbusEventBufferMult(_physConfigs, config, new DbusEventV2Factory());
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class TestDbusPhysicalPartitionEventBuffer method deserializePhysicalSourceConfigWithoutEbuffer.
@Test
public void deserializePhysicalSourceConfigWithoutEbuffer() throws JSONException, JsonParseException, JsonMappingException, IOException {
JSONObject jsonObject = new JSONObject(PhysicalSourcesConfigWithoutEBuffer.toString());
Assert.assertEquals(jsonObject.get("dbusEventBuffer"), JSONObject.NULL);
ObjectMapper mapper = new ObjectMapper();
PhysicalSourceConfig config = mapper.readValue(jsonObject.toString(), PhysicalSourceConfig.class);
Assert.assertEquals(config.isDbusEventBufferSet(), false);
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class TestDbusPhysicalPartitionEventBuffer method setUp.
@BeforeClass
public void setUp() throws InvalidConfigException {
LogicalSourceConfig loConfig = new LogicalSourceConfig();
loConfig.setId((short) 0);
loConfig.setName("testlogicalName");
loConfig.setPartition((short) 0);
loConfig.setUri("testuri");
loConfig.setPartitionFunction("constant:1");
//Physical sources config without event buffer
PhysicalSourceConfig config = new PhysicalSourceConfig();
config.setName("testname");
config.setUri("testuri");
config.setSource(0, loConfig);
PhysicalSourcesStaticConfigWithoutEbuffer = config.build();
PhysicalSourcesConfigWithoutEBuffer = config;
//Physical sources config with event buffer
PhysicalSourceConfig config2 = new PhysicalSourceConfig();
config2.setName("testname");
config2.setUri("testuri");
config2.setSource(0, loConfig);
config2.setName("testname");
config2.setUri("testuri");
config2.getDbusEventBuffer().setMaxSize(eventBufferMaxSize);
config2.getDbusEventBuffer().setScnIndexSize(scnIndexSize);
config2.getDbusEventBuffer().setAverageEventSize(eventBufferReadBufferSize);
PhysicalSourcesStaticConfigWithEBuffer = config2.build();
PhysicalSourcesConfigWithEBuffer = config2;
//Global event buffer config
DbusEventBuffer.Config ebufConfig = new DbusEventBuffer.Config();
ebufConfig.setMaxSize(globaleventBufferMaxSize);
GlobalDbusEbufferStaticConfig = ebufConfig.build();
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig 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