use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class TestCmdSources method testCmdSourceConfigFileMissingResources.
@Test
public void testCmdSourceConfigFileMissingResources() throws Exception {
SourceConfig testSourceConfig = getSourceConfig();
testSourceConfig.setResources(null);
SourceConfig expectedSourceConfig = getSourceConfig();
expectedSourceConfig.setResources(null);
testCmdSourceConfigFile(testSourceConfig, expectedSourceConfig);
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class TestCmdSources method getSourceConfig.
public SourceConfig getSourceConfig() throws JsonProcessingException {
SourceConfig sourceConfig = new SourceConfig();
sourceConfig.setTenant(TENANT);
sourceConfig.setNamespace(NAMESPACE);
sourceConfig.setName(NAME);
sourceConfig.setTopicName(TOPIC_NAME);
sourceConfig.setSerdeClassName(SERDE_CLASS_NAME);
sourceConfig.setProcessingGuarantees(PROCESSING_GUARANTEES);
sourceConfig.setParallelism(PARALLELISM);
sourceConfig.setArchive(JAR_FILE_PATH);
sourceConfig.setResources(new Resources(CPU, RAM, DISK));
sourceConfig.setConfigs(createSource.parseConfigs(SINK_CONFIG_STRING));
return sourceConfig;
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class PulsarSourceE2ETest method createSourceConfig.
private static SourceConfig createSourceConfig(String tenant, String namespace, String functionName, String sinkTopic) {
SourceConfig sourceConfig = new SourceConfig();
sourceConfig.setTenant(tenant);
sourceConfig.setNamespace(namespace);
sourceConfig.setName(functionName);
sourceConfig.setParallelism(1);
sourceConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE);
sourceConfig.setTopicName(sinkTopic);
return sourceConfig;
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class SourceConfigUtilsTest method testSupportsBatchBuilderWhenProducerConfigExists.
@Test
public void testSupportsBatchBuilderWhenProducerConfigExists() {
SourceConfig sourceConfig = createSourceConfig();
sourceConfig.setBatchBuilder("KEY_BASED");
sourceConfig.getProducerConfig().setMaxPendingMessages(123456);
Function.FunctionDetails functionDetails = SourceConfigUtils.convert(sourceConfig, new SourceConfigUtils.ExtractedSourceDetails(null, null));
assertEquals(functionDetails.getSink().getProducerSpec().getBatchBuilder(), "KEY_BASED");
assertEquals(functionDetails.getSink().getProducerSpec().getMaxPendingMessages(), 123456);
}
use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.
the class SourceConfigUtilsTest method testMergeDifferentBatchSourceConfig.
@Test
public void testMergeDifferentBatchSourceConfig() {
SourceConfig sourceConfig = createSourceConfigWithBatch();
BatchSourceConfig batchSourceConfig = createBatchSourceConfig();
Map<String, Object> newConfig = new HashMap<>();
newConfig.put("something", "different");
batchSourceConfig.setDiscoveryTriggererConfig(newConfig);
SourceConfig newSourceConfig = createUpdatedSourceConfig("batchSourceConfig", batchSourceConfig);
SourceConfig mergedConfig = SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
assertEquals(mergedConfig.getBatchSourceConfig().getDiscoveryTriggererConfig().get("something"), "different");
mergedConfig.getBatchSourceConfig().setDiscoveryTriggererConfig(sourceConfig.getBatchSourceConfig().getDiscoveryTriggererConfig());
assertEquals(new Gson().toJson(sourceConfig), new Gson().toJson(mergedConfig));
}
Aggregations