use of com.linkedin.databus2.relay.config.PhysicalSourceConfig 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.PhysicalSourceConfig 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());
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class OracleEventProducerFactory method buildEventProducer.
public EventProducer buildEventProducer(PhysicalSourceStaticConfig physicalSourceConfig, SchemaRegistryService schemaRegistryService, DbusEventBufferAppendable dbusEventBuffer, MBeanServer mbeanServer, DbusEventsStatisticsCollector dbusEventsStatisticsCollector, MaxSCNReaderWriter _maxScnReaderWriter) throws DatabusException, EventCreationException, UnsupportedKeyException, SQLException, InvalidConfigException {
// Make sure the URI from the configuration file identifies an Oracle JDBC source.
String uri = physicalSourceConfig.getUri();
if (!uri.startsWith("jdbc:oracle")) {
throw new InvalidConfigException("Invalid source URI (" + physicalSourceConfig.getUri() + "). Only jdbc:oracle: URIs are supported.");
}
// Parse each one of the logical sources
List<OracleTriggerMonitoredSourceInfo> sources = new ArrayList<OracleTriggerMonitoredSourceInfo>();
for (LogicalSourceStaticConfig sourceConfig : physicalSourceConfig.getSources()) {
OracleTriggerMonitoredSourceInfo source = buildOracleMonitoredSourceInfo(sourceConfig, physicalSourceConfig, schemaRegistryService);
sources.add(source);
}
DataSource ds = null;
try {
ds = OracleJarUtils.createOracleDataSource(uri);
} catch (Exception e) {
String errMsg = "Oracle URI likely not supported. Trouble creating OracleDataSource";
_log.error(errMsg);
throw new InvalidConfigException(errMsg + e.getMessage());
}
// Create the event producer
EventProducer eventProducer = new OracleEventProducer(sources, ds, dbusEventBuffer, true, dbusEventsStatisticsCollector, _maxScnReaderWriter, physicalSourceConfig, ManagementFactory.getPlatformMBeanServer());
_log.info("Created OracleEventProducer for config: " + physicalSourceConfig + " with slowSourceQueryThreshold = " + physicalSourceConfig.getSlowSourceQueryThreshold());
return eventProducer;
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class DatabusRelayTestUtil method createPhysicalConfigBuilder.
/**
* Convenience class to create configs for relays
*
* @param id
* @param name
* @param uri
* @param pollIntervalMs
* @param eventRatePerSec
* @param restartScnOffset
* @param largestEventSize
* @param largestWindowSize
* @param logicalSources
* @return
*/
public static PhysicalSourceConfig createPhysicalConfigBuilder(short id, String name, String uri, long pollIntervalMs, int eventRatePerSec, long restartScnOffset, int largestEventSize, long largestWindowSize, String[] logicalSources) {
LogicalSourceConfig[] lSourceConfigs = new LogicalSourceConfig[logicalSources.length];
short lid = (short) (id + 1);
int i = 0;
for (String schemaName : logicalSources) {
LogicalSourceConfig lConf = new LogicalSourceConfig();
lConf.setId(lid++);
lConf.setName(schemaName);
// this is table name in the oracle source world
lConf.setUri(schemaName);
lConf.setPartitionFunction("constant:1");
lSourceConfigs[i] = lConf;
i++;
}
return createPhysicalConfigBuilder(id, name, uri, pollIntervalMs, eventRatePerSec, restartScnOffset, largestEventSize, largestWindowSize, lSourceConfigs);
}
use of com.linkedin.databus2.relay.config.PhysicalSourceConfig in project databus by linkedin.
the class DatabusRelayTestUtil method createDatabusRelay.
public static DatabusRelayMain createDatabusRelay(PhysicalSourceConfig[] sourceConfigs, HttpRelay.Config httpRelayConfig) throws IOException, DatabusException {
PhysicalSourceStaticConfig[] pStaticConfigs = new PhysicalSourceStaticConfig[sourceConfigs.length];
int i = 0;
for (PhysicalSourceConfig pConf : sourceConfigs) {
// prefixed to the id or what?
for (LogicalSourceConfig lsc : pConf.getSources()) {
httpRelayConfig.setSourceName("" + lsc.getId(), lsc.getName());
}
pStaticConfigs[i++] = pConf.build();
}
DatabusRelayMain relayMain = new DatabusRelayMain(httpRelayConfig.build(), pStaticConfigs);
return relayMain;
}
Aggregations