use of io.confluent.ksql.physical.scalablepush.locator.PushLocator in project ksql by confluentinc.
the class ScalablePushRegistry method create.
public static Optional<ScalablePushRegistry> create(final LogicalSchema logicalSchema, final Supplier<List<PersistentQueryMetadata>> allPersistentQueries, final boolean isTable, final Map<String, Object> streamsProperties, final Map<String, Object> consumerProperties, final String sourceApplicationId, final KsqlTopic ksqlTopic, final ServiceContext serviceContext, final KsqlConfig ksqlConfig) {
final Object appServer = streamsProperties.get(StreamsConfig.APPLICATION_SERVER_CONFIG);
if (appServer == null) {
return Optional.empty();
}
if (!(appServer instanceof String)) {
throw new IllegalArgumentException(StreamsConfig.APPLICATION_SERVER_CONFIG + " not String");
}
final URL localhost;
try {
localhost = new URL((String) appServer);
} catch (final MalformedURLException e) {
throw new IllegalArgumentException(StreamsConfig.APPLICATION_SERVER_CONFIG + " malformed: " + "'" + appServer + "'");
}
final PushLocator pushLocator = new AllHostsLocator(allPersistentQueries, localhost);
return Optional.of(new ScalablePushRegistry(pushLocator, logicalSchema, isTable, consumerProperties, ksqlTopic, serviceContext, ksqlConfig, sourceApplicationId, KafkaConsumerFactory::create, LatestConsumer::new, CatchupConsumer::new, Executors.newSingleThreadExecutor(), Executors.newScheduledThreadPool(ksqlConfig.getInt(KsqlConfig.KSQL_QUERY_PUSH_V2_MAX_CATCHUP_CONSUMERS))));
}
Aggregations