use of com.linkedin.databus2.producers.ConstantPartitionFunction 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 + ").");
}
}
use of com.linkedin.databus2.producers.ConstantPartitionFunction 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.producers.ConstantPartitionFunction 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 + ").");
}
}
Aggregations