Search in sources :

Example 1 with PhysicalSourceConfig

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

Example 2 with PhysicalSourceConfig

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());
}
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 PhysicalSourceConfig

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);
}
Also used : PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) JSONObject(org.json.JSONObject) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.testng.annotations.Test)

Example 4 with PhysicalSourceConfig

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

Example 5 with PhysicalSourceConfig

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);
}
Also used : PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) DatabusRelaySourcesInFiles(com.linkedin.databus2.relay.config.DatabusRelaySourcesInFiles) FileSystemSchemaRegistryService(com.linkedin.databus2.schemas.FileSystemSchemaRegistryService) File(java.io.File) VersionedSchema(com.linkedin.databus2.schemas.VersionedSchema)

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