Search in sources :

Example 6 with PhysicalSourceConfig

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;
}
Also used : DatabusException(com.linkedin.databus2.core.DatabusException) ArrayList(java.util.ArrayList) LogicalSourceStaticConfig(com.linkedin.databus2.relay.config.LogicalSourceStaticConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DatabusException(com.linkedin.databus2.core.DatabusException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) UnsupportedKeyException(com.linkedin.databus.core.UnsupportedKeyException) NoSuchSchemaException(com.linkedin.databus2.schemas.NoSuchSchemaException)

Example 7 with PhysicalSourceConfig

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());
}
Also used : PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig)

Example 8 with PhysicalSourceConfig

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;
}
Also used : ArrayList(java.util.ArrayList) OracleEventProducer(com.linkedin.databus2.producers.db.OracleEventProducer) EventProducer(com.linkedin.databus2.producers.EventProducer) OracleEventProducer(com.linkedin.databus2.producers.db.OracleEventProducer) LogicalSourceStaticConfig(com.linkedin.databus2.relay.config.LogicalSourceStaticConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) UnsupportedKeyException(com.linkedin.databus.core.UnsupportedKeyException) SQLException(java.sql.SQLException) NoSuchSchemaException(com.linkedin.databus2.schemas.NoSuchSchemaException) EventCreationException(com.linkedin.databus2.producers.EventCreationException) DatabusException(com.linkedin.databus2.core.DatabusException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) OracleTriggerMonitoredSourceInfo(com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo) DataSource(javax.sql.DataSource)

Example 9 with PhysicalSourceConfig

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);
}
Also used : LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig)

Example 10 with PhysicalSourceConfig

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;
}
Also used : PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) DatabusRelayMain(com.linkedin.databus2.relay.DatabusRelayMain)

Aggregations

PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)28 Test (org.testng.annotations.Test)16 Checkpoint (com.linkedin.databus.core.Checkpoint)13 DatabusSourcesConnection (com.linkedin.databus.client.DatabusSourcesConnection)12 DbusEventsTotalStats (com.linkedin.databus.core.monitoring.mbean.DbusEventsTotalStats)12 DatabusRelayTestUtil (com.linkedin.databus2.relay.util.test.DatabusRelayTestUtil)12 LogicalSourceConfig (com.linkedin.databus2.relay.config.LogicalSourceConfig)11 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)10 DatabusException (com.linkedin.databus2.core.DatabusException)8 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)7 PhysicalSourceStaticConfig (com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig)6 File (java.io.File)5 Logger (org.apache.log4j.Logger)5 ConditionCheck (com.linkedin.databus2.test.ConditionCheck)4 OracleTriggerMonitoredSourceInfo (com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo)3 FileSystemSchemaRegistryService (com.linkedin.databus2.schemas.FileSystemSchemaRegistryService)3 IOException (java.io.IOException)3 BootstrapConfig (com.linkedin.databus.bootstrap.common.BootstrapConfig)2 BootstrapReadOnlyConfig (com.linkedin.databus.bootstrap.common.BootstrapReadOnlyConfig)2 HttpRelay (com.linkedin.databus.container.netty.HttpRelay)2