-
Notifications
You must be signed in to change notification settings - Fork 12
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
EVA-3260 update block allocation strategy #83
Conversation
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.
It looks good. My only concern is that our switch in strategy is not very well explained and might misunderstood by another developer.
@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; |
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.
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.
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.
Maybe it makes more sense to describe this at the level of the class rather than this method.
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.
Added description on top of the class in the form of Javadoc to explain the behavior
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.
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.
No description provided.