alex-plekhanov commented on code in PR #11176:
URL: https://github.com/apache/ignite/pull/11176#discussion_r1495364897
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java:
##########
@@ -58,4 +59,21 @@ public ClientRequest(long reqId) {
public ClientResponse process(ClientConnectionContext ctx) {
return new ClientResponse(reqId);
}
+
+ /**
+ * Processes the request asynchronously.
+ *
+ * @return Future for response.
+ */
+ public IgniteInternalFuture<ClientResponse>
processAsync(ClientConnectionContext ctx) {
Review Comment:
Pavel also proposed to use async methods for atomic cache operations:
https://github.com/apache/ignite/pull/11176#discussion_r1455481115
Async operations add some overhead and I think it's better to use sync
operations in cases where they don't lead to deadlocks.
Perhaps we can benchmark it and my concerns are baseless, but I propose to
do it in another ticket.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java:
##########
@@ -3653,6 +3654,52 @@ public void awaitLastFut() {
}
}
+ /**
+ * Replaces previous async operation future on transaction suspend.
+ */
+ public @Nullable FutureHolder suspendLastFut() {
+ FutureHolder holder = lastFut.get();
+
+ IgniteInternalFuture fut = holder.future();
+
+ if (fut != null && !fut.isDone()) {
+ lastFut.set(new FutureHolder());
+
+ return holder;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Replaces previous async operation future on transaction resume.
+ */
+ public void resumeLastFut(FutureHolder holder) {
+ IgniteInternalFuture resumedFut = holder.future();
+
+ if (resumedFut == null || resumedFut.isDone())
+ return;
+
+ FutureHolder threadHolder = lastFut.get();
+
+ IgniteInternalFuture threadFut = threadHolder.future();
+
+ if (threadFut != null && !threadFut.isDone()) {
+ threadHolder.lock();
Review Comment:
Checking just local variable is enough. Future can be completed after lock
as well, so additional check is redundant.
Check for completion also performed by compound future, so here code is safe.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java:
##########
@@ -3653,6 +3654,52 @@ public void awaitLastFut() {
}
}
+ /**
+ * Replaces previous async operation future on transaction suspend.
+ */
+ public @Nullable FutureHolder suspendLastFut() {
+ FutureHolder holder = lastFut.get();
+
+ IgniteInternalFuture fut = holder.future();
+
+ if (fut != null && !fut.isDone()) {
+ lastFut.set(new FutureHolder());
+
+ return holder;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Replaces previous async operation future on transaction resume.
+ */
+ public void resumeLastFut(FutureHolder holder) {
+ IgniteInternalFuture resumedFut = holder.future();
+
+ if (resumedFut == null || resumedFut.isDone())
+ return;
+
+ FutureHolder threadHolder = lastFut.get();
+
+ IgniteInternalFuture threadFut = threadHolder.future();
+
+ if (threadFut != null && !threadFut.isDone()) {
+ threadHolder.lock();
+
+ try {
+ GridCompoundFuture f = new
GridCompoundFuture<>().add(threadFut).add(resumedFut).markInitialized();
Review Comment:
EmbeddedFuture executes asynchroniously some code after completion of one
future. Here we need to wait for two futures (threadFut and resumedFut) and
don't have any additional code to execute async (except code in saveFuture), so
I have no idea how EmbeddedFuture will help here.
--
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]