-
Notifications
You must be signed in to change notification settings - Fork 3
name kafka streams topology nodes appropriately #79
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,12 @@ | |
| import static org.hypertrace.core.viewgenerator.service.ViewGeneratorConstants.VIEW_GENERATORS_CONFIG; | ||
|
|
||
| import com.typesafe.config.Config; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import java.util.TreeSet; | ||
| import org.apache.kafka.streams.StreamsBuilder; | ||
| import org.apache.kafka.streams.kstream.KStream; | ||
| import org.hypertrace.core.kafkastreams.framework.KafkaStreamsApp; | ||
|
|
@@ -20,7 +20,7 @@ | |
| import org.hypertrace.core.serviceframework.config.ConfigUtils; | ||
|
|
||
| public class MultiViewGeneratorLauncher extends KafkaStreamsApp { | ||
| private Map<String, Config> viewGenConfigs; | ||
| private final Map<String, Config> viewGenConfigs; | ||
|
|
||
| public MultiViewGeneratorLauncher(ConfigClient configClient) { | ||
| super(configClient); | ||
|
|
@@ -61,23 +61,23 @@ public String getJobConfigKey() { | |
| @Override | ||
| public List<String> getInputTopics(Map<String, Object> properties) { | ||
| List<String> viewGenNames = getViewGenName(properties); | ||
| Set<String> inputTopics = new HashSet<>(); | ||
| Set<String> inputTopics = new TreeSet<>(); | ||
| for (String viewGen : viewGenNames) { | ||
| Config viewGenConfig = viewGenConfigs.get(viewGen); | ||
| inputTopics.addAll(viewGenConfig.getStringList(INPUT_TOPICS_CONFIG_KEY)); | ||
| } | ||
| return inputTopics.stream().collect(Collectors.toList()); | ||
| return new ArrayList<>(inputTopics); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit - why this change? List.copyOf (unless we're intentionally making this mutable) That said, we should make this deterministic and avoid the hash set here. (same comment below)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Intellij suggestion
set needed as input topic across all viewgens is same and we need to add only one source per input topic.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So we have a uniqueness requirement, not a set it sounds like. Using a hash set means that different runs with the same input will return their outputs in a different order. Even if that's not impactful today, it's a bad practice and makes writing tests annoying. Suggest any of
return getViewGenName(properties)
.stream()
.map(viewGenConfigs::get)
.map(config -> config.getStringList(INPUT_TOPICS_CONFIG_KEY))
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toUnmodifiableList());
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not a TreeSet? Looks simpler and much readable than the streams snippet in the suggestion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
matter of opinion! but yes, any ordered set will do for repeatability, doesn't need to be insertion ordered - I was just trying to match the perceived intent. |
||
| } | ||
|
|
||
| @Override | ||
| public List<String> getOutputTopics(Map<String, Object> properties) { | ||
| List<String> viewGenNames = getViewGenName(properties); | ||
| Set<String> outputTopics = new HashSet<>(); | ||
| Set<String> outputTopics = new TreeSet<>(); | ||
| for (String viewGen : viewGenNames) { | ||
| Config viewGenConfig = viewGenConfigs.get(viewGen); | ||
| outputTopics.add(viewGenConfig.getString(OUTPUT_TOPIC_CONFIG_KEY)); | ||
| } | ||
| return outputTopics.stream().collect(Collectors.toList()); | ||
| return new ArrayList<>(outputTopics); | ||
| } | ||
|
|
||
| private Config getJobConfig(Map<String, Object> properties) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change,
hypertrace/hypertrace-ingestortransitively loadsslf4j-api:2.0.5via dependency onhypertrace/view-generator-framework, but internally it still useslog4j-slf4j-implinstead ofslf4j2. That led to failure of integration tests in QS which loads container"hypertrace/hypertrace-view-generator:main".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raised PR to fix it: hypertrace/hypertrace-ingester#425