Search in sources :

Example 1 with PhysicalSourceStaticConfig

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++;
    }
    ;
}
Also used : PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) PhysicalSource(com.linkedin.databus.core.data_model.PhysicalSource) LogicalSource(com.linkedin.databus.core.data_model.LogicalSource) LogicalPartition(com.linkedin.databus.core.data_model.LogicalPartition) PhysicalPartition(com.linkedin.databus.core.data_model.PhysicalPartition) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with PhysicalSourceStaticConfig

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());
}
Also used : PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) InputStreamReader(java.io.InputStreamReader) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 3 with PhysicalSourceStaticConfig

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;
}
Also used : PartitionFunction(com.linkedin.databus2.producers.PartitionFunction) NoSuchSchemaException(com.linkedin.databus2.schemas.NoSuchSchemaException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException)

Example 4 with PhysicalSourceStaticConfig

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;
}
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 5 with PhysicalSourceStaticConfig

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

Aggregations

PhysicalSourceStaticConfig (com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig)21 ArrayList (java.util.ArrayList)10 Test (org.testng.annotations.Test)9 PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)8 DbusEventBufferAppendable (com.linkedin.databus.core.DbusEventBufferAppendable)7 PhysicalPartition (com.linkedin.databus.core.data_model.PhysicalPartition)7 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)6 LogicalSourceConfig (com.linkedin.databus2.relay.config.LogicalSourceConfig)6 TransactionInfo (com.linkedin.databus.monitoring.mbean.GGParserStatistics.TransactionInfo)5 LogicalSourceStaticConfig (com.linkedin.databus2.relay.config.LogicalSourceStaticConfig)5 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)4 NoSuchSchemaException (com.linkedin.databus2.schemas.NoSuchSchemaException)4 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)4 EventSourceStatistics (com.linkedin.databus.monitoring.mbean.EventSourceStatistics)3 DatabusException (com.linkedin.databus2.core.DatabusException)3 EventProducer (com.linkedin.databus2.producers.EventProducer)3 PartitionFunction (com.linkedin.databus2.producers.PartitionFunction)3 OracleEventProducer (com.linkedin.databus2.producers.db.OracleEventProducer)3 HashSet (java.util.HashSet)3 BeforeTest (org.testng.annotations.BeforeTest)3