tmgodinho commented on code in PR #7844:
URL: https://github.com/apache/ignite-3/pull/7844#discussion_r3116708995
##########
modules/client/src/main/java/org/apache/ignite/internal/client/tx/DirectTxUtils.java:
##########
@@ -282,6 +284,81 @@ public static CompletableFuture<ClientChannel>
resolveChannel(
});
}
+ /**
+ * If the current request is the first request of a direct tx, add a
listener to the {@link PayloadWriter}.
+ *
+ * @param ctx The {@link WriteContext} that holds transactional context
information.
+ * @param tx The client transaction associated with the request, or {@code
null} if none.
+ * @param base Request native {@link PayloadWriter}.
+ * @return The {@link PayloadWriter} that should be used on the request.
+ */
+ public static PayloadWriter payloadWriter(WriteContext ctx, @Nullable
Transaction tx, PayloadWriter base) {
+ if (ctx.firstReqFut != null && tx instanceof ClientLazyTransaction) {
+ return poc -> {
+ base.accept(poc);
+
+ var clientLazyTx = (ClientLazyTransaction) tx;
+ long requestId = poc.requestId();
+ ClientChannel cc = poc.clientChannel();
+ poc.onSent(() -> clientLazyTx.updateRequestInfo(requestId,
cc));
+ };
+ } else {
+ return base;
+ }
+ }
+
+ /**
+ * Try to handle error on first request. Returns false if not in the
context of the first request.
+ * This method essentially populates context with a failed request
instance.
+ *
+ * @param ctx The {@link WriteContext} that holds transactional context
information.
+ * @param ch The {@link ReliableChannel} used to resolve the actual
communication channel.
+ * @param id Client Table Id.
Review Comment:
Yes, that third param of the ClientTransaction is usually the table id.
Here in this ClientTable they are passing the table id, right??
https://github.com/apache/ignite-3/pull/7844/changes#diff-fad88288a19e953d25290cefffc4c2f59ca6a007b24a24e439149ba4f8f38c09
I didn't quite understand the logic.
--
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]