use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig in project databus by linkedin.
the class OpenReplicatorEventProducerServiceProvider 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 + ").");
}
}
use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig 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;
}
use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig 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 + ").");
}
}
use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig in project databus by linkedin.
the class DbusEventBufferMult method addBuffer.
/**
* add another buffer with the mappings
*/
public synchronized void addBuffer(PhysicalSourceStaticConfig pConfig, DbusEventBuffer buf) {
LOG.info("addBuffer for phSrc=" + pConfig + "; buf=" + buf.hashCode());
PhysicalPartition pPartition = pConfig.getPhysicalPartition();
PhysicalPartitionKey pKey = new PhysicalPartitionKey(pPartition);
_bufsMap.put(pKey, buf);
_uniqBufs.add(buf);
buf.setDropOldEvents(_dropOldEvents);
for (LogicalSourceStaticConfig lSrc : pConfig.getSources()) {
updateLogicalSourceMapping(pKey, lSrc.getLogicalSource(), lSrc.getPartition());
}
}
use of com.linkedin.databus2.relay.config.LogicalSourceStaticConfig in project databus by linkedin.
the class PhysicalSourceConfig method build.
@Override
public PhysicalSourceStaticConfig build() throws InvalidConfigException {
checkForNulls();
// check config options for chained relays
if (_largestEventSizeInBytes >= _largestWindowSizeInBytes) {
throw new InvalidConfigException("Invalid relay config: largestEventSizeInBytes has to be lesser than largestWindowSizeInBytes:" + " largestEventSizeInBytes=" + _largestEventSizeInBytes + " largestWindowSizeInBytes=" + _largestWindowSizeInBytes);
}
LogicalSourceStaticConfig[] sourcesStaticConfigs = new LogicalSourceStaticConfig[_sources.size()];
for (int i = 0; i < _sources.size(); ++i) {
sourcesStaticConfigs[i] = _sources.get(i).build();
}
ChunkingType chunkingType = ChunkingType.valueOf(_chunkingType);
return new PhysicalSourceStaticConfig(_name, _id, _uri, _resourceKey, sourcesStaticConfigs, _role, _slowSourceQueryThreshold, _restartScnOffset, _retries.build(), chunkingType, _txnsPerChunk, _scnChunkSize, _chunkedScnThreshold, _maxScnDelayMs, _eventRatePerSec, _maxThrottleDurationInSecs, isDbusEventBufferSet() ? _dbusEventBuffer.build() : null, _largestEventSizeInBytes, _largestWindowSizeInBytes, _errorOnMissingFields, _xmlVersion, _xmlEncoding, _replBitSetter.build());
}
Aggregations