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();
}
Aggregations