use of org.apache.pulsar.common.io.BatchSourceConfig in project pulsar by apache.
the class SourceConfigUtilsTest method createSourceConfigWithBatch.
private SourceConfig createSourceConfigWithBatch() {
SourceConfig sourceConfig = createSourceConfig();
BatchSourceConfig batchSourceConfig = createBatchSourceConfig();
sourceConfig.setBatchSourceConfig(batchSourceConfig);
return sourceConfig;
}
use of org.apache.pulsar.common.io.BatchSourceConfig in project pulsar by apache.
the class SourceConfigUtilsTest method testMergeDifferentBatchTriggerer.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "DiscoverTriggerer class cannot be updated for batchsources")
public void testMergeDifferentBatchTriggerer() {
SourceConfig sourceConfig = createSourceConfigWithBatch();
BatchSourceConfig batchSourceConfig = createBatchSourceConfig();
batchSourceConfig.setDiscoveryTriggererClassName("SomeOtherClassName");
SourceConfig newSourceConfig = createUpdatedSourceConfig("batchSourceConfig", batchSourceConfig);
SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
}
use of org.apache.pulsar.common.io.BatchSourceConfig in project pulsar by apache.
the class SourceConfigUtilsTest method createBatchSourceConfig.
private BatchSourceConfig createBatchSourceConfig() {
BatchSourceConfig batchSourceConfig = new BatchSourceConfig();
batchSourceConfig.setDiscoveryTriggererClassName(TestTriggerer.class.getName());
Map<String, Object> batchConfig = new HashMap<>();
batchConfig.put("foo", "bar");
batchSourceConfig.setDiscoveryTriggererConfig(batchConfig);
return batchSourceConfig;
}
use of org.apache.pulsar.common.io.BatchSourceConfig in project pulsar by apache.
the class BatchDataGeneratorExec method main.
public static void main(final String[] args) throws Exception {
final String cronString = "0 0/5 * * * ?";
final Map<String, Object> discoveryConfig = new HashMap<>();
discoveryConfig.put(CronTriggerer.CRON_KEY, cronString);
final BatchSourceConfig batchSourceConfig = BatchSourceConfig.builder().discoveryTriggererClassName(CronTriggerer.class.getName()).discoveryTriggererConfig(discoveryConfig).build();
final SourceConfig sourceConfig = SourceConfig.builder().batchSourceConfig(batchSourceConfig).className(BatchDataGeneratorSource.class.getName()).configs(new HashMap<>()).name("BatchDataGenerator").parallelism(1).topicName("persistent://public/default/batchdatagenerator").build();
final LocalRunner localRunner = LocalRunner.builder().brokerServiceUrl("pulsar://localhost:6650").sourceConfig(sourceConfig).build();
localRunner.start(false);
TimeUnit.MINUTES.sleep(30);
localRunner.stop();
System.exit(0);
}
use of org.apache.pulsar.common.io.BatchSourceConfig in project pulsar by apache.
the class TestCmdSources method testBatchSourceConfigMissingDiscoveryTriggererClassName.
/*
* Test where the DiscoveryTriggererClassName is null
*/
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Discovery Triggerer not specified")
public void testBatchSourceConfigMissingDiscoveryTriggererClassName() throws Exception {
SourceConfig testSourceConfig = getSourceConfig();
BatchSourceConfig batchSourceConfig = getBatchSourceConfig();
batchSourceConfig.setDiscoveryTriggererClassName(null);
testSourceConfig.setBatchSourceConfig(batchSourceConfig);
SourceConfig expectedSourceConfig = getSourceConfig();
expectedSourceConfig.setBatchSourceConfig(batchSourceConfig);
testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig);
}
Aggregations