Search in sources :

Example 11 with LogicalSourceStaticConfig

use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig in project databus by linkedin.

the class TestGoldenGateEventProducer method buildPssc.

private PhysicalSourceStaticConfig buildPssc(long rate, long throttleDuration) throws InvalidConfigException {
    String name = "anet";
    short id = 505, partition = 0;
    String uri = "gg:///mnt/dbext/x1";
    String resourceKey = "test";
    String partitionFunction = "constant:1";
    boolean skipInfinityScn = false;
    String queryHints = null;
    LogicalSourceStaticConfig[] sources = new LogicalSourceStaticConfig[1];
    LogicalSourceStaticConfig lssc = new LogicalSourceStaticConfig(id, name, uri, partitionFunction, partition, skipInfinityScn, queryHints, queryHints, queryHints);
    sources[0] = lssc;
    String role = "MASTER";
    long slowSourceQueryThreshold = 0L;
    long restartScnOffset = 0L;
    BackoffTimerStaticConfigBuilder bsc = new BackoffTimerStaticConfigBuilder();
    ChunkingType ct = ChunkingType.NO_CHUNKING;
    long txnsPerChunk = 0L;
    long scnChunkSize = 0L;
    long chunkedScnThreshold = 0L;
    long maxScnDelayMs = 0L;
    long eventRatePerSec = rate;
    long eventRateThrottleDuration = throttleDuration;
    int largestEventSizeInBytes = 10240;
    long largestWindowSizeInBytes = 10240;
    DbusEventBuffer.Config cfgBuilder = new DbusEventBuffer.Config();
    cfgBuilder.setMaxSize(10 * 1024 * 1024);
    cfgBuilder.setScnIndexSize(2 * 1024 * 1024);
    cfgBuilder.setAllocationPolicy("MMAPPED_MEMORY");
    DbusEventBuffer.StaticConfig dbusEventBuffer = cfgBuilder.build();
    boolean errorOnMissingFields = true;
    String xmlVersion = "1.0";
    String xmlEncoding = "";
    String fieldName = "";
    String regex = "";
    ReplicationBitSetterStaticConfig replicationBitSetter = new ReplicationBitSetterStaticConfig(ReplicationBitSetterStaticConfig.SourceType.NONE, fieldName, regex, MissingValueBehavior.STOP_WITH_ERROR);
    PhysicalSourceStaticConfig pssc = new PhysicalSourceStaticConfig(name, id, uri, resourceKey, sources, role, slowSourceQueryThreshold, restartScnOffset, bsc.build(), ct, txnsPerChunk, scnChunkSize, chunkedScnThreshold, maxScnDelayMs, eventRatePerSec, eventRateThrottleDuration, dbusEventBuffer, largestEventSizeInBytes, largestWindowSizeInBytes, errorOnMissingFields, xmlVersion, xmlEncoding, replicationBitSetter);
    return pssc;
}
Also used : PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) ReplicationBitSetterStaticConfig(com.linkedin.databus2.relay.config.ReplicationBitSetterStaticConfig) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) LogicalSourceStaticConfig(com.linkedin.databus2.relay.config.LogicalSourceStaticConfig) DbusEventBuffer(com.linkedin.databus.core.DbusEventBuffer) ReplicationBitSetterStaticConfig(com.linkedin.databus2.relay.config.ReplicationBitSetterStaticConfig) BackoffTimerStaticConfigBuilder(com.linkedin.databus2.core.BackoffTimerStaticConfigBuilder) LogicalSourceStaticConfig(com.linkedin.databus2.relay.config.LogicalSourceStaticConfig) ChunkingType(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig.ChunkingType)

Example 12 with LogicalSourceStaticConfig

use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig in project databus by linkedin.

the class PhysicalSourceConfigBuilder method build.

@Override
public PhysicalSourceStaticConfig[] build() throws InvalidConfigException {
    ObjectMapper mapper = new ObjectMapper();
    PhysicalSourceStaticConfig[] list = new PhysicalSourceStaticConfig[null == _fileNames ? 0 : _fileNames.length];
    if (_fileNames == null)
        return list;
    for (int i = 0; i < _fileNames.length; ++i) {
        File sourceJson = _fileNames[i];
        PhysicalSourceConfig pConfig = null;
        Exception e = null;
        try {
            pConfig = mapper.readValue(sourceJson, PhysicalSourceConfig.class);
        } catch (JsonParseException jpe) {
            e = jpe;
        } catch (JsonMappingException jme) {
            e = jme;
        } catch (IOException ioe) {
            e = ioe;
        }
        if (e != null || pConfig == null) {
            throw new InvalidConfigException(e);
        }
        pConfig.checkForNulls();
        LOG.info("Generated Physical source config: name= " + pConfig.getId());
        list[i] = pConfig.build();
    }
    /*
    for(PhysicalSourceStaticConfig pCfg : pConfigs) {
      for(LogicalSourceStaticConfig lSC : pCfg.getSources()) {
        config.setSourceName("" + lSC.getId(), lSC.getName());
      }
    }
    */
    return list;
}
Also used : PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) File(java.io.File) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException)

Aggregations

InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)8 NoSuchSchemaException (com.linkedin.databus2.schemas.NoSuchSchemaException)6 DatabusException (com.linkedin.databus2.core.DatabusException)5 UnsupportedKeyException (com.linkedin.databus.core.UnsupportedKeyException)4 LogicalSourceStaticConfig (com.linkedin.databus2.relay.config.LogicalSourceStaticConfig)4 ConstantPartitionFunction (com.linkedin.databus2.producers.ConstantPartitionFunction)3 PartitionFunction (com.linkedin.databus2.producers.PartitionFunction)3 EventSourceStatistics (com.linkedin.databus.monitoring.mbean.EventSourceStatistics)2 EventCreationException (com.linkedin.databus2.producers.EventCreationException)2 OracleTriggerMonitoredSourceInfo (com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo)2 PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)2 PhysicalSourceStaticConfig (com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig)2 ChunkingType (com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig.ChunkingType)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)1 PhysicalPartition (com.linkedin.databus.core.data_model.PhysicalPartition)1 BackoffTimerStaticConfigBuilder (com.linkedin.databus2.core.BackoffTimerStaticConfigBuilder)1 EventProducer (com.linkedin.databus2.producers.EventProducer)1 EventFactory (com.linkedin.databus2.producers.db.EventFactory)1