Skip to content
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

[Generic DAO][Part 2] Implement backfill method #385

Merged
merged 7 commits into from
Jun 12, 2024

Conversation

zhixuanjia
Copy link
Contributor

Summary

Add backfill method into Generic DAO.

Testing Done

Unit tests

Checklist

@codecov-commenter
Copy link

codecov-commenter commented Jun 9, 2024

Codecov Report

Attention: Patch coverage is 75.55556% with 11 lines in your changes missing coverage. Please review.

Project coverage is 67.84%. Comparing base (6f0bf31) to head (c26477b).

Files Patch % Lines
...om/linkedin/metadata/dao/EbeanGenericLocalDAO.java 78.78% 1 Missing and 6 partials ⚠️
...adata/restli/BaseEntityAgnosticAspectResource.java 66.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #385      +/-   ##
============================================
+ Coverage     67.73%   67.84%   +0.10%     
- Complexity     1375     1388      +13     
============================================
  Files           136      136              
  Lines          5412     5446      +34     
  Branches        565      572       +7     
============================================
+ Hits           3666     3695      +29     
+ Misses         1516     1514       -2     
- Partials        230      237       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

public interface GenericMetadataProducer {

/**
* Produces an aspect specific Metadata Audit Event (MAE) after a metadata aspect is updated for an entity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be used in MCE producer as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this producer is to replace the type-bounded BaseMetadataEventProducer and specifically used for MAE emission.

MCE producer is within ingestion-template (MP: metadata-graph-platformization)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification. I'm more from the requirement on "entity agnostic" aspect ingestion. Doesn't need to be addressed here.

final AuditStamp oldAuditStamp = latest.get().getExtraInfo() == null ? null : latest.get().getExtraInfo().getAudit();

final boolean isBackfillEvent = trackingContext != null && trackingContext.hasBackfill() && trackingContext.isBackfill();
final boolean shouldBackfill = trackingContext != null && trackingContext.hasEmitTime() && oldAuditStamp != null && oldAuditStamp.hasTime()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is complicated, making it a function and covered with an unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, convert it to method and added some unit tests.

final boolean shouldBackfill = trackingContext != null && trackingContext.hasEmitTime() && oldAuditStamp != null && oldAuditStamp.hasTime()
&& trackingContext.getEmitTime() > oldAuditStamp.getTime();

// Skip update if metadata is sent by backfill event but should not be backfilled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: such as expired backfill? (any other scenarios? )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, it's basically to prevent expired backfill. Let me update the comment to make it more clear.

@Nonnull BackfillMode mode, @Nonnull Map<Urn, Set<Class<? extends RecordTemplate>>> aspectClasses) {

if (aspectClasses.isEmpty()) {
return new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collections.emptyMap()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, updated.


Optional<GenericLocalDAO.MetadataWithExtraInfo> metadata = _genericLocalDAO.queryLatest(fooUrn, AspectFoo.class);

// {"value":"bar"} is inserted later so it is the latest metadata.
assertEquals(metadata.get().getAspect(), RecordUtils.toJsonString(aspectFoo2));
}

@Test
public void testBackfill() throws URISyntaxException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: adding [when / given / expect] would help for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, added [when / expects]

Copy link
Contributor

@jsdonn jsdonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please get approval from Yang.

Copy link
Contributor

@yangyangv2 yangyangv2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for addressing the comments!

@zhixuanjia zhixuanjia merged commit 793bd8c into linkedin:master Jun 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants