Search in sources :

Example 21 with SinkConfig

use of org.apache.pulsar.common.io.SinkConfig in project pulsar by apache.

the class SinkConfigUtilsTest method testMergeEqual.

@Test
public void testMergeEqual() {
    SinkConfig sinkConfig = createSinkConfig();
    SinkConfig newSinkConfig = createSinkConfig();
    SinkConfig mergedConfig = SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
    assertEquals(new Gson().toJson(sinkConfig), new Gson().toJson(mergedConfig));
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Gson(com.google.gson.Gson) Test(org.testng.annotations.Test)

Example 22 with SinkConfig

use of org.apache.pulsar.common.io.SinkConfig in project pulsar by apache.

the class SinkConfigUtilsTest method testMergeDifferentRetainOrdering.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Retain Ordering cannot be altered")
public void testMergeDifferentRetainOrdering() {
    SinkConfig sinkConfig = createSinkConfig();
    SinkConfig newSinkConfig = createUpdatedSinkConfig("retainOrdering", true);
    SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Test(org.testng.annotations.Test)

Example 23 with SinkConfig

use of org.apache.pulsar.common.io.SinkConfig in project pulsar by apache.

the class SinkConfigUtilsTest method testMergeDifferentResources.

@Test
public void testMergeDifferentResources() {
    SinkConfig sinkConfig = createSinkConfig();
    Resources resources = new Resources();
    resources.setCpu(0.3);
    resources.setRam(1232l);
    resources.setDisk(123456l);
    SinkConfig newSinkConfig = createUpdatedSinkConfig("resources", resources);
    SinkConfig mergedConfig = SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
    assertEquals(mergedConfig.getResources(), resources);
    mergedConfig.setResources(sinkConfig.getResources());
    assertEquals(new Gson().toJson(sinkConfig), new Gson().toJson(mergedConfig));
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Gson(com.google.gson.Gson) Resources(org.apache.pulsar.common.functions.Resources) Test(org.testng.annotations.Test)

Example 24 with SinkConfig

use of org.apache.pulsar.common.io.SinkConfig in project pulsar by apache.

the class SinkConfigUtilsTest method testMergeDifferentAutoAck.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "AutoAck cannot be altered")
public void testMergeDifferentAutoAck() {
    SinkConfig sinkConfig = createSinkConfig();
    SinkConfig newSinkConfig = createUpdatedSinkConfig("autoAck", false);
    SinkConfig mergedConfig = SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) Test(org.testng.annotations.Test)

Example 25 with SinkConfig

use of org.apache.pulsar.common.io.SinkConfig in project pulsar by apache.

the class SinkConfigUtilsTest method testPoolMessages.

@Test
public void testPoolMessages() throws IOException {
    SinkConfig sinkConfig = createSinkConfig();
    Function.FunctionDetails functionDetails = SinkConfigUtils.convert(sinkConfig, new SinkConfigUtils.ExtractedSinkDetails(null, null));
    assertFalse(functionDetails.getSource().getInputSpecsMap().get("test-input").getPoolMessages());
    SinkConfig convertedConfig = SinkConfigUtils.convertFromDetails(functionDetails);
    assertFalse(convertedConfig.getInputSpecs().get("test-input").isPoolMessages());
    Map<String, ConsumerConfig> inputSpecs = new HashMap<>();
    inputSpecs.put("test-input", ConsumerConfig.builder().poolMessages(true).build());
    sinkConfig.setInputSpecs(inputSpecs);
    functionDetails = SinkConfigUtils.convert(sinkConfig, new SinkConfigUtils.ExtractedSinkDetails(null, null));
    assertTrue(functionDetails.getSource().getInputSpecsMap().get("test-input").getPoolMessages());
    convertedConfig = SinkConfigUtils.convertFromDetails(functionDetails);
    assertTrue(convertedConfig.getInputSpecs().get("test-input").isPoolMessages());
}
Also used : IdentityFunction(org.apache.pulsar.functions.api.utils.IdentityFunction) Function(org.apache.pulsar.functions.proto.Function) SinkConfig(org.apache.pulsar.common.io.SinkConfig) HashMap(java.util.HashMap) ConsumerConfig(org.apache.pulsar.common.functions.ConsumerConfig) Test(org.testng.annotations.Test)

Aggregations

SinkConfig (org.apache.pulsar.common.io.SinkConfig)223 Test (org.testng.annotations.Test)165 Gson (com.google.gson.Gson)42 HashMap (java.util.HashMap)33 Function (org.apache.pulsar.functions.proto.Function)27 File (java.io.File)24 ConsumerConfig (org.apache.pulsar.common.functions.ConsumerConfig)24 IdentityFunction (org.apache.pulsar.functions.api.utils.IdentityFunction)24 NarClassLoader (org.apache.pulsar.common.nar.NarClassLoader)21 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)19 IOException (java.io.IOException)18 Resources (org.apache.pulsar.common.functions.Resources)15 FileInputStream (java.io.FileInputStream)12 WebTarget (javax.ws.rs.client.WebTarget)12 ObjectMapperFactory (org.apache.pulsar.common.util.ObjectMapperFactory)12 TopicStats (org.apache.pulsar.common.policies.data.TopicStats)10 List (java.util.List)9 Map (java.util.Map)9 CompletableFuture (java.util.concurrent.CompletableFuture)9 Cleanup (lombok.Cleanup)9