Search in sources :

Example 1 with FixedRangeGenerator

use of org.apache.flink.connector.pulsar.source.enumerator.topic.range.FixedRangeGenerator in project flink by apache.

the class KeySharedSubscriptionContext method createSource.

@Override
public Source<String, ?, ?> createSource(TestingSourceSettings sourceSettings) {
    int keyHash = keyHash(key1);
    TopicRange range = new TopicRange(keyHash, keyHash);
    PulsarSourceBuilder<String> builder = PulsarSource.builder().setDeserializationSchema(pulsarSchema(STRING)).setServiceUrl(operator.serviceUrl()).setAdminUrl(operator.adminUrl()).setTopicPattern("pulsar-[0-9]+-key-shared", RegexSubscriptionMode.AllTopics).setSubscriptionType(SubscriptionType.Key_Shared).setSubscriptionName("pulsar-key-shared").setRangeGenerator(new FixedRangeGenerator(singletonList(range)));
    if (sourceSettings.getBoundedness() == Boundedness.BOUNDED) {
        // Using latest stop cursor for making sure the source could be stopped.
        builder.setBoundedStopCursor(StopCursor.latest());
    }
    return builder.build();
}
Also used : TopicRange(org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange) FixedRangeGenerator(org.apache.flink.connector.pulsar.source.enumerator.topic.range.FixedRangeGenerator)

Aggregations

TopicRange (org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange)1 FixedRangeGenerator (org.apache.flink.connector.pulsar.source.enumerator.topic.range.FixedRangeGenerator)1