Search in sources :

Example 16 with SourceConfig

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);
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 17 with SourceConfig

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;
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Resources(org.apache.pulsar.common.functions.Resources)

Example 18 with 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;
}
Also used : SourceConfig(org.apache.pulsar.common.io.SourceConfig)

Example 19 with 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);
}
Also used : Function(org.apache.pulsar.functions.proto.Function) BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 20 with SourceConfig

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));
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) HashMap(java.util.HashMap) BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Gson(com.google.gson.Gson) Test(org.testng.annotations.Test)

Aggregations

SourceConfig (org.apache.pulsar.common.io.SourceConfig)192 BatchSourceConfig (org.apache.pulsar.common.io.BatchSourceConfig)141 Test (org.testng.annotations.Test)129 Gson (com.google.gson.Gson)42 HashMap (java.util.HashMap)30 File (java.io.File)27 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)27 Function (org.apache.pulsar.functions.proto.Function)24 IOException (java.io.IOException)21 Response (javax.ws.rs.core.Response)18 List (java.util.List)15 Map (java.util.Map)15 RestException (org.apache.pulsar.common.util.RestException)15 IdentityFunction (org.apache.pulsar.functions.api.utils.IdentityFunction)15 FunctionMetaDataManager (org.apache.pulsar.functions.worker.FunctionMetaDataManager)15 Lists (com.google.common.collect.Lists)12 FileInputStream (java.io.FileInputStream)12 InputStream (java.io.InputStream)12 Files (java.nio.file.Files)12 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)12