szetszwo commented on code in PR #1015:
URL: https://github.com/apache/ratis/pull/1015#discussion_r1456331777
##########
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:
We call `remove(..)` in `whenComplete(..)`; see
https://github.com/apache/ratis/blob/24482561f98e9f9b0555dffbddd92111af303724/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java#L1815
So, the context will be removed no matter the `stateMachineFuture` is
completed normally or exceptionally. Note that a `stateMachineFuture` will
always be completed (unless for critical error that the server will be shut
down).
--
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]