Search in sources :

Example 6 with PartitionFunction

use of com.linkedin.databus2.producers.PartitionFunction in project databus by linkedin.

the class GGEventGenerationFactory method buildPartitionFunction.

/**
   * Given a logical source config, create a partition function.
   *
   * @param sourceConfig
   * @return the partition function
   * @throws InvalidConfigException
   */
public static PartitionFunction buildPartitionFunction(LogicalSourceStaticConfig sourceConfig) throws InvalidConfigException {
    String partitionFunction = sourceConfig.getPartitionFunction();
    if (partitionFunction.startsWith("constant:")) {
        try {
            String numberPart = partitionFunction.substring("constant:".length()).trim();
            short constantPartitionNumber = Short.valueOf(numberPart);
            return new ConstantPartitionFunction(constantPartitionNumber);
        } catch (Exception ex) {
            // to parse the partition number.
            throw new InvalidConfigException("Invalid partition configuration (" + partitionFunction + "). " + "Could not parse the constant partition number.");
        }
    } else {
        throw new InvalidConfigException("Invalid partition configuration (" + partitionFunction + ").");
    }
}
Also used : ConstantPartitionFunction(com.linkedin.databus2.producers.ConstantPartitionFunction) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DatabusException(com.linkedin.databus2.core.DatabusException) DecoderException(org.apache.commons.codec.DecoderException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException)

Example 7 with PartitionFunction

use of com.linkedin.databus2.producers.PartitionFunction 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 8 with PartitionFunction

use of com.linkedin.databus2.producers.PartitionFunction in project databus by linkedin.

the class TestGoldenGateEventProducer method buildSimplePssc.

private PhysicalSourceStaticConfig buildSimplePssc(short[] sourceIds, String[] sourceNames, String uri) throws InvalidConfigException {
    String partitionFunction = "constant:1";
    String pPartName = "part1";
    short pPartId = 0;
    PhysicalSourceConfig pc = new PhysicalSourceConfig(pPartName, uri, pPartId);
    for (int i = 0; i < sourceIds.length; i++) {
        LogicalSourceConfig lc = new LogicalSourceConfig();
        lc.setId(sourceIds[i]);
        lc.setName(sourceNames[i]);
        lc.setPartitionFunction(partitionFunction);
        // this format is expected by GG
        lc.setUri(pPartName + "." + sourceNames[i]);
        pc.addSource(lc);
    }
    return pc.build();
}
Also used : PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig)

Example 9 with PartitionFunction

use of com.linkedin.databus2.producers.PartitionFunction in project databus by linkedin.

the class OracleEventProducerFactory method buildPartitionFunction.

public PartitionFunction buildPartitionFunction(LogicalSourceStaticConfig sourceConfig) throws InvalidConfigException {
    String partitionFunction = sourceConfig.getPartitionFunction();
    if (partitionFunction.startsWith("constant:")) {
        try {
            String numberPart = partitionFunction.substring("constant:".length()).trim();
            short constantPartitionNumber = Short.valueOf(numberPart);
            return new ConstantPartitionFunction(constantPartitionNumber);
        } catch (Exception ex) {
            // Could be a NumberFormatException, IndexOutOfBoundsException or other exception when trying to parse the partition number.
            throw new InvalidConfigException("Invalid partition configuration (" + partitionFunction + "). " + "Could not parse the constant partition number.");
        }
    } else {
        throw new InvalidConfigException("Invalid partition configuration (" + partitionFunction + ").");
    }
}
Also used : ConstantPartitionFunction(com.linkedin.databus2.producers.ConstantPartitionFunction) 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)

Aggregations

InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)5 DatabusException (com.linkedin.databus2.core.DatabusException)4 PartitionFunction (com.linkedin.databus2.producers.PartitionFunction)4 NoSuchSchemaException (com.linkedin.databus2.schemas.NoSuchSchemaException)4 EventSourceStatistics (com.linkedin.databus.monitoring.mbean.EventSourceStatistics)3 ConstantPartitionFunction (com.linkedin.databus2.producers.ConstantPartitionFunction)3 UnsupportedKeyException (com.linkedin.databus.core.UnsupportedKeyException)2 LogicalSourceConfig (com.linkedin.databus2.relay.config.LogicalSourceConfig)2 PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)2 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)1 DbusEventInfo (com.linkedin.databus.core.DbusEventInfo)1 DbusEventKey (com.linkedin.databus.core.DbusEventKey)1 DbusOpcode (com.linkedin.databus.core.DbusOpcode)1 BackoffTimerStaticConfigBuilder (com.linkedin.databus2.core.BackoffTimerStaticConfigBuilder)1 DbUpdateState (com.linkedin.databus2.ggParser.XmlStateMachine.DbUpdateState)1 TransactionState (com.linkedin.databus2.ggParser.XmlStateMachine.TransactionState)1 PerSourceTransactionalUpdate (com.linkedin.databus2.ggParser.XmlStateMachine.TransactionState.PerSourceTransactionalUpdate)1 EventCreationException (com.linkedin.databus2.producers.EventCreationException)1 EventFactory (com.linkedin.databus2.producers.db.EventFactory)1 EventReaderSummary (com.linkedin.databus2.producers.db.EventReaderSummary)1