use of com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig in project databus by linkedin.
the class TestDbusEventBufferMult method setUpTest.
@BeforeTest
public void setUpTest() throws IOException, InvalidConfigException {
LOG.info("Setting up Test");
PhysicalSourceStaticConfig pStatConf1 = convertToPhysicalSourceConfig(_configSource1).build();
PhysicalSourceStaticConfig pStatConf2 = convertToPhysicalSourceConfig(_configSource2).build();
PhysicalSourceStaticConfig pStatConf3 = convertToPhysicalSourceConfig(_configSource3).build();
_pConfigs = new PhysicalSourceStaticConfig[] { pStatConf1, pStatConf2, pStatConf3 };
// generate testData
int scn = 100;
String srcName = "srcName";
int srcId = 1;
PhysicalSource pS = pStatConf1.getPhysicalSource();
PhysicalPartition pP = pStatConf1.getPhysicalPartition();
_events = new TestDbusEvent[20];
LogicalPartition lP = new LogicalPartition((short) 0);
for (int i = 0; i < _events.length; i++) {
_events[i] = new TestDbusEvent(i, scn, new LogicalSource(srcId, srcName + srcId), pS, pP, lP);
switch(i) {
case 4:
srcId = 2;
break;
case 9:
srcId = 11;
pS = pStatConf2.getPhysicalSource();
pP = pStatConf2.getPhysicalPartition();
break;
case 14:
srcId = 12;
break;
}
if ((i & 1) == 1)
scn++;
}
;
}
use of com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig 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.PhysicalSourceStaticConfig in project databus by linkedin.
the class OpenReplicatorEventProducerServiceProvider method buildEventFactory.
public OpenReplicatorAvroEventFactory buildEventFactory(LogicalSourceStaticConfig sourceConfig, PhysicalSourceStaticConfig pConfig, SchemaRegistryService schemaRegistryService) throws DatabusException, EventCreationException, UnsupportedKeyException, InvalidConfigException {
String schema = null;
try {
schema = schemaRegistryService.fetchLatestSchemaBySourceName(sourceConfig.getName());
} catch (NoSuchSchemaException e) {
throw new InvalidConfigException("Unable to load the schema for source (" + sourceConfig.getName() + ").");
}
if (schema == null) {
throw new InvalidConfigException("Unable to load the schema for source (" + sourceConfig.getName() + ").");
}
LOG.info("Loading schema for source id " + sourceConfig.getId() + ": " + schema);
String eventViewSchema;
String eventView;
if (sourceConfig.getUri().indexOf('.') != -1) {
String[] parts = sourceConfig.getUri().split("\\.");
eventViewSchema = parts[0];
eventView = parts[1];
} else {
eventViewSchema = null;
eventView = sourceConfig.getUri();
}
PartitionFunction partitionFunction = buildPartitionFunction(sourceConfig);
OpenReplicatorAvroEventFactory factory = createEventFactory(eventViewSchema, eventView, sourceConfig, pConfig, schema, partitionFunction);
return factory;
}
use of com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig in project databus by linkedin.
the class OpenReplicatorEventProducerServiceProvider method createProducer.
@Override
public EventProducer createProducer(PhysicalSourceStaticConfig physicalSourceConfig, SchemaRegistryService schemaRegistryService, DbusEventBufferAppendable eventBuffer, DbusEventsStatisticsCollector statsCollector, MaxSCNReaderWriter checkpointWriter) throws InvalidConfigException {
// Parse each one of the logical sources
List<OpenReplicatorAvroEventFactory> eventFactories = new ArrayList<OpenReplicatorAvroEventFactory>();
for (LogicalSourceStaticConfig sourceConfig : physicalSourceConfig.getSources()) {
OpenReplicatorAvroEventFactory factory = null;
try {
factory = buildEventFactory(sourceConfig, physicalSourceConfig, schemaRegistryService);
} catch (Exception ex) {
LOG.error("Got exception while building monitored sources for config :" + sourceConfig, ex);
throw new InvalidConfigException(ex);
}
eventFactories.add(factory);
}
EventProducer producer = null;
try {
producer = new OpenReplicatorEventProducer(eventFactories, eventBuffer, checkpointWriter, physicalSourceConfig, statsCollector, null, null, schemaRegistryService, JMX_DOMAIN);
} catch (DatabusException e) {
LOG.error("Got databus exception when instantiating Open Replicator event producer for source : " + physicalSourceConfig.getName(), e);
throw new InvalidConfigException(e);
}
return producer;
}
use of com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig in project databus by linkedin.
the class HttpRelay method initPConfigs.
// create a "fake" configuration for backward compatiblity - in case a new configuration is not available
private void initPConfigs(HttpRelay.StaticConfig config) throws InvalidConfigException {
if (_pConfigs != null)
return;
StringBuilder logListIds = new StringBuilder("Creating default physical source config. Sources are: ");
// default ph config
PhysicalSourceConfig pConfig = PhysicalSourceConfig.createFromLogicalSources(_sourcesIdNameRegistry.getAllSources());
//
for (LogicalSourceConfig ls : pConfig.getSources()) logListIds.append(ls.getId() + ":" + ls.getName() + ",");
LOG.info(logListIds);
// set the memeber
_pConfigs = new ArrayList<PhysicalSourceStaticConfig>(1);
_pConfigs.add(pConfig.build());
}
Aggregations