duongkame commented on code in PR #1015:
URL: https://github.com/apache/ratis/pull/1015#discussion_r1456065560
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/TransactionManager.java:
##########
@@ -28,17 +29,17 @@
* Managing {@link TransactionContext}.
*/
class TransactionManager {
- private final ConcurrentMap<Long, Supplier<TransactionContext>> contexts =
new ConcurrentHashMap<>();
+ private final ConcurrentMap<TermIndex, Supplier<TransactionContext>>
contexts = new ConcurrentHashMap<>();
- TransactionContext get(long index) {
- return
Optional.ofNullable(contexts.get(index)).map(Supplier::get).orElse(null);
+ TransactionContext get(TermIndex termIndex) {
+ return
Optional.ofNullable(contexts.get(termIndex)).map(Supplier::get).orElse(null);
}
- TransactionContext computeIfAbsent(long index, Supplier<TransactionContext>
constructor) {
- return contexts.computeIfAbsent(index, i -> constructor).get();
+ TransactionContext computeIfAbsent(TermIndex termIndex,
Supplier<TransactionContext> constructor) {
+ return contexts.computeIfAbsent(termIndex, i -> constructor).get();
}
- void remove(long index) {
- contexts.remove(index);
+ void remove(TermIndex termIndex) {
Review Comment:
A minor point, this will lead to some garbage because contexts linked to
discarded log indexes may not get cleaned up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]