-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GOBBLIN-278] Fix sending lineage event for KafkaSource #2131
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 |
---|---|---|
|
@@ -81,25 +81,11 @@ public enum SizeEstimatorType { | |
|
||
protected final AbstractSource<?, ?> source; | ||
protected final SourceState state; | ||
protected final Extract.TableType tableType; | ||
protected final String extractNameSpace; | ||
protected final boolean isFullExtract; | ||
protected final KafkaWorkUnitSizeEstimator sizeEstimator; | ||
|
||
protected KafkaWorkUnitPacker(AbstractSource<?, ?> source, SourceState state) { | ||
this.source = source; | ||
this.state = state; | ||
if (state.getPropAsBoolean(KafkaSource.GOBBLIN_KAFKA_EXTRACT_ALLOW_TABLE_TYPE_NAMESPACE_CUSTOMIZATION)) { | ||
String tableTypeStr = state.getProp(ConfigurationKeys.EXTRACT_TABLE_TYPE_KEY, | ||
KafkaSource.DEFAULT_TABLE_TYPE.toString()); | ||
tableType = Extract.TableType.valueOf(tableTypeStr); | ||
extractNameSpace = state.getProp(ConfigurationKeys.EXTRACT_NAMESPACE_NAME_KEY, KafkaSource.DEFAULT_NAMESPACE_NAME); | ||
} else { | ||
// To be compatible, reject table type and namespace configuration keys as previous implementation | ||
tableType = KafkaSource.DEFAULT_TABLE_TYPE; | ||
extractNameSpace = KafkaSource.DEFAULT_NAMESPACE_NAME; | ||
} | ||
isFullExtract = state.getPropAsBoolean(ConfigurationKeys.EXTRACT_IS_FULL_KEY); | ||
this.sizeEstimator = getWorkUnitSizeEstimator(); | ||
} | ||
|
||
|
@@ -227,13 +213,18 @@ protected WorkUnit squeezeMultiWorkUnit(MultiWorkUnit multiWorkUnit) { | |
List<KafkaPartition> partitions = getPartitionsFromMultiWorkUnit(multiWorkUnit); | ||
Preconditions.checkArgument(!partitions.isEmpty(), "There must be at least one partition in the multiWorkUnit"); | ||
|
||
Extract extract = this.source.createExtract(tableType, extractNameSpace, partitions.get(0).getTopicName()); | ||
if (isFullExtract) { | ||
extract.setProp(ConfigurationKeys.EXTRACT_IS_FULL_KEY, true); | ||
} | ||
WorkUnit workUnit = WorkUnit.create(extract, interval); | ||
// Squeeze all partitions from the multiWorkUnit into of one the work units, which can be any one | ||
WorkUnit workUnit = multiWorkUnit.getWorkUnits().get(0); | ||
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. Is this to preserve properties from the workunit by using an existing workunit instead of creating a new one? Will removing the properties below affect other places that access this workunit? Would it be safer and sufficient to create a new workunit and copy the properties over from the first work unit? 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.
Yes.
No. Because these properties are either ignored or replaced by the configurations immediately set below.
No. We do need to remove those properties. Otherwise, the logic won't be the same as before. And all work units of in the same multi work unit have the same properties but those that are removed and extractid. 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. I meant copy then remove from the copy. But if it is safe then you can remove directly. |
||
// Update interval | ||
workUnit.removeProp(ConfigurationKeys.WORK_UNIT_LOW_WATER_MARK_KEY); | ||
workUnit.removeProp(ConfigurationKeys.WORK_UNIT_HIGH_WATER_MARK_KEY); | ||
workUnit.setWatermarkInterval(interval); | ||
// Remove the original partition information | ||
workUnit.removeProp(KafkaSource.PARTITION_ID); | ||
workUnit.removeProp(KafkaSource.LEADER_ID); | ||
workUnit.removeProp(KafkaSource.LEADER_HOSTANDPORT); | ||
// Add combined partitions information | ||
populateMultiPartitionWorkUnit(partitions, workUnit); | ||
workUnit.setProp(ESTIMATED_WORKUNIT_SIZE, multiWorkUnit.getProp(ESTIMATED_WORKUNIT_SIZE)); | ||
LOG.info(String.format("Created MultiWorkUnit for partitions %s", partitions)); | ||
return workUnit; | ||
} | ||
|
@@ -243,9 +234,7 @@ protected WorkUnit squeezeMultiWorkUnit(MultiWorkUnit multiWorkUnit) { | |
*/ | ||
private static void populateMultiPartitionWorkUnit(List<KafkaPartition> partitions, WorkUnit workUnit) { | ||
Preconditions.checkArgument(!partitions.isEmpty(), "There should be at least one partition"); | ||
workUnit.setProp(KafkaSource.TOPIC_NAME, partitions.get(0).getTopicName()); | ||
GobblinMetrics.addCustomTagToState(workUnit, new Tag<>("kafkaTopic", partitions.get(0).getTopicName())); | ||
workUnit.setProp(ConfigurationKeys.EXTRACT_TABLE_NAME_KEY, partitions.get(0).getTopicName()); | ||
for (int i = 0; i < partitions.size(); i++) { | ||
workUnit.setProp(KafkaUtils.getPartitionPropName(KafkaSource.PARTITION_ID, i), partitions.get(i).getId()); | ||
workUnit.setProp(KafkaUtils.getPartitionPropName(KafkaSource.LEADER_ID, i), | ||
|
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.
Why this is removed?
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.
This is duplicate logic to line 239