-
Notifications
You must be signed in to change notification settings - Fork 12
EVA-3260 update block allocation strategy #83
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
Changes from 5 commits
de768ee
396f619
e4fabd0
3d179ed
6416220
64abef2
deb71c6
c1f5721
6988429
5f2f724
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package uk.ac.ebi.ampt2d.commons.accession.core.exceptions; | ||
|
||
public class AccessionGeneratorShutDownException extends RuntimeException { | ||
public AccessionGeneratorShutDownException(String msg) { | ||
super(msg); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ public ContiguousIdBlockService(ContiguousIdBlockRepository repository, Map<Stri | |
|
||
@Transactional | ||
public void save(Iterable<ContiguousIdBlock> blocks) { | ||
// release block if full | ||
blocks.forEach(block -> {if (block.isFull()) {block.releaseReserved();}}); | ||
repository.saveAll(blocks); | ||
entityManager.flush(); | ||
} | ||
|
@@ -74,12 +76,22 @@ public BlockParameters getBlockParameters(String categoryId) { | |
return categoryBlockInitializations.get(categoryId); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<ContiguousIdBlock> getUncompletedBlocksByCategoryIdAndApplicationInstanceIdOrderByEndAsc( | ||
@Transactional(isolation = Isolation.SERIALIZABLE) | ||
public List<ContiguousIdBlock> reserveUncompletedBlocksByCategoryIdAndApplicationInstanceIdOrderByEndAsc( | ||
apriltuesday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 commentThe 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 commentThe 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 commentThe 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 |
||
} | ||
} | ||
|
||
public ContiguousIdBlockRepository getRepository() { | ||
apriltuesday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return repository; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.