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

EVA-3260 update block allocation strategy #83

Merged
merged 10 commits into from
Mar 21, 2024

Conversation

nitin-ebi
Copy link
Contributor

No description provided.

@nitin-ebi nitin-ebi self-assigned this Mar 15, 2024
Copy link
Member

@tcezard tcezard left a comment

Choose a reason for hiding this comment

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

It looks good. My only concern is that our switch in strategy is not very well explained and might misunderstood by another developer.

Comment on lines 79 to 90
@Transactional(isolation = Isolation.SERIALIZABLE)
public List<ContiguousIdBlock> reserveUncompletedBlocksByCategoryIdAndApplicationInstanceIdOrderByEndAsc(
String categoryId, String applicationInstanceId) {
try (Stream<ContiguousIdBlock> reservedBlocksOfThisInstance = repository
.findAllByCategoryIdAndApplicationInstanceIdOrderByLastValueAsc(categoryId, applicationInstanceId)) {
return reservedBlocksOfThisInstance.filter(ContiguousIdBlock::isNotFull).collect(Collectors.toList());
List<ContiguousIdBlock> blocksList = reservedBlocksOfThisInstance
.filter(block -> block.isNotFull() && block.isNotReserved()).collect(Collectors.toList());

blocksList.stream().forEach(block -> block.markAsReserved());
save(blocksList);

return blocksList;
Copy link
Member

Choose a reason for hiding this comment

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

If I'm not mistaken, this is the core of the process safe block reservation process. I feel like we should describe in a comment why/how this works.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it makes more sense to describe this at the level of the class rather than this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added description on top of the class in the form of Javadoc to explain the behavior

Copy link
Contributor

@apriltuesday apriltuesday left a comment

Choose a reason for hiding this comment

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

Great work, left some suggestions but otherwise happy to have this tested in a "real world" setting.

I agree with Tim that documentation for future developers (e.g. us in a couple years...) would be great. Even better would be updating the diagram and adding some explanation either there or in the code... this might be too large a task for this PR though.

@nitin-ebi nitin-ebi merged commit c0a5c31 into EBIvariation:master Mar 21, 2024
1 check 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.

3 participants