[
https://issues.apache.org/jira/browse/GOBBLIN-2118?focusedWorklogId=928886&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-928886
]
ASF GitHub Bot logged work on GOBBLIN-2118:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 06/Aug/24 10:46
Start Date: 06/Aug/24 10:46
Worklog Time Spent: 10m
Work Description: arpit09 commented on code in PR #4009:
URL: https://github.com/apache/gobblin/pull/4009#discussion_r1705321133
##########
gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaSource.java:
##########
@@ -440,29 +440,34 @@ private int calculateNumMappersForPacker(SourceState
state,
/*
* This function need to be thread safe since it is called in the Runnable
*/
- private List<WorkUnit> getWorkUnitsForTopic(KafkaTopic topic, SourceState
state,
- Optional<State> topicSpecificState, Optional<Set<Integer>>
filteredPartitions) {
+ public List<WorkUnit> getWorkUnitsForTopic(KafkaTopic topic, SourceState
state, Optional<State> topicSpecificState,
+ Optional<Set<Integer>> filteredPartitions) {
Timer.Context context =
this.metricContext.timer("isTopicQualifiedTimer").time();
boolean topicQualified = isTopicQualified(topic);
context.close();
- List<WorkUnit> workUnits = Lists.newArrayList();
- List<KafkaPartition> topicPartitions = topic.getPartitions();
- for (KafkaPartition partition : topicPartitions) {
- if(filteredPartitions.isPresent() &&
!filteredPartitions.get().contains(partition.getId())) {
- continue;
- }
- WorkUnit workUnit = getWorkUnitForTopicPartition(partition, state,
topicSpecificState);
- if (workUnit != null) {
- // For disqualified topics, for each of its workunits set the high
watermark to be the same
- // as the low watermark, so that it will be skipped.
- if (!topicQualified) {
- skipWorkUnit(workUnit);
- }
- workUnit.setProp(NUM_TOPIC_PARTITIONS, topicPartitions.size());
- workUnits.add(workUnit);
+ final List<WorkUnit> workUnits = Lists.newArrayList();
+ final List<KafkaPartition> topicPartitions = topic.getPartitions();
+ Map<KafkaPartition, WorkUnit> workUnitMap;
+
+ if (filteredPartitions.isPresent()) {
+ LOG.info("Filtered partitions for topic {} are {}", topic.getName(),
filteredPartitions.get());
+ final List<KafkaPartition> filteredPartitionsToBeProcessed =
topicPartitions.stream()
+ .filter(partition ->
filteredPartitions.get().contains(partition.getId()))
+ .collect(Collectors.toList());
+ workUnitMap = getWorkUnits(filteredPartitionsToBeProcessed, state,
topicSpecificState);
+ } else {
+ workUnitMap = getWorkUnits(topicPartitions, state, topicSpecificState);
+ }
+
+ for (WorkUnit workUnit : workUnitMap.values()) {
Review Comment:
Moved `if(!topicQualified)` outside now
Issue Time Tracking
-------------------
Worklog Id: (was: 928886)
Time Spent: 40m (was: 0.5h)
> Reduce no of network calls while fetching kafka offsets during startup
> ----------------------------------------------------------------------
>
> Key: GOBBLIN-2118
> URL: https://issues.apache.org/jira/browse/GOBBLIN-2118
> Project: Apache Gobblin
> Issue Type: Improvement
> Reporter: Arpit Varshney
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> During starting while creating work unit, in Kafkasource there are network
> calls that tries to fetch the kafka offsets (both earliest and latest) to
> find out the watermark (to find the offsets where the gobblin job will start
> consuming from)
> These calls are fetched for each topic and each partition in the topic. For
> each partition, there is a separate call that goes to kafka client, which
> increases the no of network calls. If there are cross colo calls (calls to
> different datacenters in different regions) this increase the time to fetch
> and results in timeout which leads to skipping of the topic partition to
> fetch leading to starvation.
> This ticket targets to reduce the no of network calls, rather than doing a
> call for each partition. Utilize kafka source to fetch the offsets for all
> the paritions at once from kafka.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)