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

Feat/214 dataspace discovery service handle multiple edc urls received for bpn #711

Conversation

dsmf added 12 commits December 20, 2023 03:05
…stest non-failing result while ignoring the others
reason: returning Optional requires too many changes in existing code when ResultFinder is used later
…istryService

- EndpointDataForConnectorsService returns multiple EndpointDataReferences now
- These are handled in DecentralDigitalTwinRegistryService.fetchShellDescriptors and by selecting the results of the fastest
…scovery-Service-handle-multiple-EDC-Urls-received-for-BPN
@dsmf dsmf marked this pull request as draft January 9, 2024 22:55
@dsmf dsmf requested a review from ds-jhartmann January 9, 2024 22:55
Copy link

github-actions bot commented Jan 9, 2024

CHANGELOG file was not updated! Make sure to include important changes.

dsmf added 14 commits January 24, 2024 00:14
switch log.debug to info because debug does not seem to get logged and add special marker "#214@" to filter the logs for debugging the story
…scovery-Service-handle-multiple-EDC-Urls-received-for-BPN
…multiple-EDC-Urls-received-for-BPN

# Conflicts:
#	CHANGELOG.md
This commit corrects the glossary sort order and adds some missing definitions, explanations and links.
…ug infos

Moved logging from helper class to business class because this way the log entry shows the business class and not the helper class.
@dsmf dsmf marked this pull request as ready for review February 1, 2024 04:52
…scovery-Service-handle-multiple-EDC-Urls-received-for-BPN

fastestResultPromise.completeExceptionally(new CompletionExceptions("None successful", exceptions));
} else {
log.debug("Completing");

Choose a reason for hiding this comment

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

I think you could make this log more verbose, what is completing or something, this may not to meaningful

Copy link
Author

Choose a reason for hiding this comment

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

difficult because of the CompletableFuture we don't have any context here. We could log the value of the request, but this might contain stuff that may not be logged and might be quite verbose?!


if (notFinishedByOtherFuture && currentFutureSuccessful) {

// first future that completes successfully completes the overall future

Choose a reason for hiding this comment

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

I would not recommend describing code behaviour as comments, we could add more description in below log or wrap it in named method (something like First future completed successfully, complitting overall future.
refs:
comment rules point 5. -> https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29
https://medium.com/codex/clean-code-comments-833e11a706dc

Copy link
Author

@dsmf dsmf Feb 2, 2024

Choose a reason for hiding this comment

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

Actually this is not just saying what the code does but WHY. In my opinion this makes it easier to understand why we have two completable futures here: the actual data retrieval future and the overall future that is just there to complete as soon as the first future completes successfully. But obviously the comment did not transport this. Therefore I renamed the overall promise, removed the comment here and added one when the overall promise is declared that describes the purpose of the overall promise.

log.info("Found {} shell(s) for {} key(s)", collectedShells.size(), keys.size());
return collectedShells;

final var watch = new StopWatch();

Choose a reason for hiding this comment

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

how about making stopwatch instance scope instead of instantiating it every time method is called?
"Note that a StopWatch is reusable. That is, you can call start() and stop() in succession and the getElapsedTime() method will refer to the time since the most recent start() call."

Copy link
Author

@dsmf dsmf Feb 2, 2024

Choose a reason for hiding this comment

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

This is asynchronous code. Therefore the measured times would not be correct because two threads would use the same stopwatch.

Choose a reason for hiding this comment

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

ah, you are perfectly right

try {
return fetchShellDescriptors(entry, calledEndpoints);
} catch (RuntimeException e) {
// catching generic exception is intended here,

Choose a reason for hiding this comment

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

same here, instead of commenting out consider wrapping it in named method that would describe finishing of a Job

} else {
log.info("Retrieved shellId {} for globalAssetId {}", aaShellIdentification, key);

final var watch = new StopWatch();

Choose a reason for hiding this comment

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

same with stopwatch

Copy link
Author

Choose a reason for hiding this comment

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

see above

return lookupShellIds(bpn, endpointDataReferenceFutures);

} catch (RuntimeException e) {
// catching generic exception is intended here,

Choose a reason for hiding this comment

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

and same with comment :)

Copy link
Author

@dsmf dsmf Feb 2, 2024

Choose a reason for hiding this comment

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

Actually catching the generic RuntimeException is a bad practice normally. The comment describes why it is intended and valid in this special case.

public List<CompletableFuture<EndpointDataReference>> createFindEndpointDataForConnectorsFutures(
final List<String> connectorEndpoints) {

final var watch = new StopWatch();

Choose a reason for hiding this comment

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

also stopwatch

Copy link

@ds-jhartmann ds-jhartmann 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 consider the changes requested by @ds-psosnowski

dsmf added 4 commits February 2, 2024 15:49
…scovery-Service-handle-multiple-EDC-Urls-received-for-BPN
The TODOs concerning #405 are resolved by #214.
Also removed the type of exception from the method name because this information is in the assert which is sufficient. No need to duplicate this.
Copy link

sonarqubecloud bot commented Feb 2, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
97.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

@ds-psosnowski ds-psosnowski left a comment

Choose a reason for hiding this comment

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

lgtm

@dsmf dsmf merged commit b81fc36 into main Feb 2, 2024
@dsmf dsmf deleted the feat/214-Dataspace-Discovery-Service-handle-multiple-EDC-Urls-received-for-BPN branch February 2, 2024 15:28
ds-pweick referenced this pull request in ds-pweick/tx-item-relationship-service Jun 19, 2024
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.

3 participants