You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2023/12/22 12:29:07 UTC
(ignite-3) branch main updated: IGNITE-21034 Fix retry handling with notifications in ClientCompute (#2975)
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new f85ef90d1a IGNITE-21034 Fix retry handling with notifications in ClientCompute (#2975)
f85ef90d1a is described below
commit f85ef90d1a57be5c7536ecdbe9eab6f99f6cacec
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Fri Dec 22 14:29:01 2023 +0200
IGNITE-21034 Fix retry handling with notifications in ClientCompute (#2975)
Address the following scenario:
* Initial `COMPUTE_EXECUTE` request has been sent, but the connection has failed before we got a response
* `TcpClientChannel#close` invokes all notification handlers with `IgniteClientConnectionException`
* `RetryPolicy` kicks in, reconnects the channel and sends another `COMPUTE_EXECUTE` request, which leads to a successful task execution
* Notification handler is invoked with a computation result, BUT, `notificationFut` is already completed exceptionally due to the first failure
To fix that, `notificationFut` is now returned with the resulting `PayloadInputChannel` from `serviceAsync`. This way we ignore notification handlers from failed attempts, and only use the last one.
Fixes `testClientRetriesComputeJobOnPrimaryAndDefaultNodes`.
---
.../ignite/internal/client/ClientChannel.java | 6 +--
.../internal/client/NotificationHandler.java | 35 ---------------
.../internal/client/PayloadInputChannel.java | 18 +++++++-
.../ignite/internal/client/ReliableChannel.java | 12 ++---
.../ignite/internal/client/TcpClientChannel.java | 51 ++++++++++++++--------
.../internal/client/compute/ClientCompute.java | 41 ++++++++---------
.../client/table/ClientKeyValueBinaryView.java | 28 ++++++------
.../internal/client/table/ClientKeyValueView.java | 42 +++++++++---------
.../client/table/ClientRecordBinaryView.java | 27 ++++++------
.../internal/client/table/ClientRecordView.java | 27 ++++++------
.../ignite/internal/client/table/ClientTable.java | 51 +++++++++++-----------
.../apache/ignite/client/ClientComputeTest.java | 2 -
.../RepeatedFinishClientTransactionTest.java | 2 +-
13 files changed, 164 insertions(+), 178 deletions(-)
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/ClientChannel.java b/modules/client/src/main/java/org/apache/ignite/internal/client/ClientChannel.java
index 1bb732f14c..c6ac9a35f4 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/ClientChannel.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/ClientChannel.java
@@ -31,7 +31,7 @@ public interface ClientChannel extends AutoCloseable {
* @param opCode Operation code.
* @param payloadWriter Payload writer to stream or {@code null} if request has no payload.
* @param payloadReader Payload reader from stream or {@code null} if response has no payload.
- * @param notificationHandler Notification handler or {@code null} if request does not trigger notifications.
+ * @param expectNotifications Whether to expect notifications as a result of the operation.
* @param <T> Response type.
* @return Future for the operation.
*/
@@ -39,7 +39,7 @@ public interface ClientChannel extends AutoCloseable {
int opCode,
@Nullable PayloadWriter payloadWriter,
@Nullable PayloadReader<T> payloadReader,
- @Nullable NotificationHandler notificationHandler
+ boolean expectNotifications
);
/**
@@ -56,7 +56,7 @@ public interface ClientChannel extends AutoCloseable {
@Nullable PayloadWriter payloadWriter,
@Nullable PayloadReader<T> payloadReader
) {
- return serviceAsync(opCode, payloadWriter, payloadReader, null);
+ return serviceAsync(opCode, payloadWriter, payloadReader, false);
}
/**
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/NotificationHandler.java b/modules/client/src/main/java/org/apache/ignite/internal/client/NotificationHandler.java
deleted file mode 100644
index c3bae9403f..0000000000
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/NotificationHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.client;
-
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Client notification handler.
- */
-@FunctionalInterface
-public interface NotificationHandler {
- /**
- * Consumes the notification.
- *
- * @param input Input, or {@code null} when failed.
- * @param err Error, or {@code null} when successful.
- * @throws Exception on failure.
- */
- void consume(@Nullable PayloadInputChannel input, @Nullable Throwable err) throws Exception;
-}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/PayloadInputChannel.java b/modules/client/src/main/java/org/apache/ignite/internal/client/PayloadInputChannel.java
index 62d92138c8..7e4f77096d 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/PayloadInputChannel.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/PayloadInputChannel.java
@@ -17,7 +17,9 @@
package org.apache.ignite.internal.client;
+import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
+import org.jetbrains.annotations.Nullable;
/**
* Thin client payload input channel.
@@ -29,15 +31,20 @@ public class PayloadInputChannel implements AutoCloseable {
/** Input stream. */
private final ClientMessageUnpacker in;
+ /** Optional notification future. */
+ @Nullable
+ private final CompletableFuture<PayloadInputChannel> notificationFut;
+
/**
* Constructor.
*
* @param ch Channel.
* @param in Unpacker.
*/
- PayloadInputChannel(ClientChannel ch, ClientMessageUnpacker in) {
+ PayloadInputChannel(ClientChannel ch, ClientMessageUnpacker in, @Nullable CompletableFuture<PayloadInputChannel> notificationFut) {
this.in = in;
this.ch = ch;
+ this.notificationFut = notificationFut;
}
/**
@@ -58,6 +65,15 @@ public class PayloadInputChannel implements AutoCloseable {
return in;
}
+ /**
+ * Gets the notification future.
+ *
+ * @return Notification future.
+ */
+ @Nullable public CompletableFuture<PayloadInputChannel> notificationFuture() {
+ return notificationFut;
+ }
+
/** {@inheritDoc} */
@Override
public void close() {
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/ReliableChannel.java b/modules/client/src/main/java/org/apache/ignite/internal/client/ReliableChannel.java
index 54b3f7e8cc..b4343351bd 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/ReliableChannel.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/ReliableChannel.java
@@ -206,11 +206,11 @@ public final class ReliableChannel implements AutoCloseable {
@Nullable PayloadReader<T> payloadReader,
@Nullable String preferredNodeName,
@Nullable RetryPolicy retryPolicyOverride,
- @Nullable NotificationHandler notificationHandler
+ boolean expectNotifications
) {
return ClientFutureUtils.doWithRetryAsync(
() -> getChannelAsync(preferredNodeName)
- .thenCompose(ch -> serviceAsyncInternal(opCode, payloadWriter, payloadReader, notificationHandler, ch)),
+ .thenCompose(ch -> serviceAsyncInternal(opCode, payloadWriter, payloadReader, expectNotifications, ch)),
null,
ctx -> shouldRetry(opCode, ctx, retryPolicyOverride));
}
@@ -229,7 +229,7 @@ public final class ReliableChannel implements AutoCloseable {
PayloadWriter payloadWriter,
@Nullable PayloadReader<T> payloadReader
) {
- return serviceAsync(opCode, payloadWriter, payloadReader, null, null, null);
+ return serviceAsync(opCode, payloadWriter, payloadReader, null, null, false);
}
/**
@@ -241,16 +241,16 @@ public final class ReliableChannel implements AutoCloseable {
* @return Future for the operation.
*/
public <T> CompletableFuture<T> serviceAsync(int opCode, PayloadReader<T> payloadReader) {
- return serviceAsync(opCode, null, payloadReader, null, null, null);
+ return serviceAsync(opCode, null, payloadReader, null, null, false);
}
private <T> CompletableFuture<T> serviceAsyncInternal(
int opCode,
@Nullable PayloadWriter payloadWriter,
@Nullable PayloadReader<T> payloadReader,
- @Nullable NotificationHandler notificationHandler,
+ boolean expectNotifications,
ClientChannel ch) {
- return ch.serviceAsync(opCode, payloadWriter, payloadReader, notificationHandler).whenComplete((res, err) -> {
+ return ch.serviceAsync(opCode, payloadWriter, payloadReader, expectNotifications).whenComplete((res, err) -> {
if (err != null && unwrapConnectionException(err) != null) {
onChannelFailure(ch);
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/TcpClientChannel.java b/modules/client/src/main/java/org/apache/ignite/internal/client/TcpClientChannel.java
index 30e5cceb2d..92a44d386a 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/TcpClientChannel.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/TcpClientChannel.java
@@ -90,7 +90,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
private final Map<Long, ClientRequestFuture<?>> pendingReqs = new ConcurrentHashMap<>();
/** Notification handlers. */
- private final Map<Long, NotificationHandler> notificationHandlers = new ConcurrentHashMap<>();
+ private final Map<Long, CompletableFuture<PayloadInputChannel>> notificationHandlers = new ConcurrentHashMap<>();
/** Topology change listeners. */
private final Collection<Consumer<Long>> assignmentChangeListeners = new CopyOnWriteArrayList<>();
@@ -216,9 +216,9 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
pendingReq.completeExceptionally(new IgniteClientConnectionException(CONNECTION_ERR, "Channel is closed", cause));
}
- for (NotificationHandler handler : notificationHandlers.values()) {
+ for (CompletableFuture<PayloadInputChannel> handler : notificationHandlers.values()) {
try {
- handler.consume(null, new IgniteClientConnectionException(CONNECTION_ERR, "Channel is closed", cause));
+ handler.completeExceptionally(new IgniteClientConnectionException(CONNECTION_ERR, "Channel is closed", cause));
} catch (Exception ignored) {
// Ignore.
}
@@ -254,7 +254,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
int opCode,
@Nullable PayloadWriter payloadWriter,
@Nullable PayloadReader<T> payloadReader,
- @Nullable NotificationHandler notificationHandler
+ boolean expectNotifications
) {
try {
if (log.isTraceEnabled()) {
@@ -263,13 +263,16 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
long id = reqId.getAndIncrement();
- if (notificationHandler != null) {
+ CompletableFuture<PayloadInputChannel> notificationFut = null;
+
+ if (expectNotifications) {
// Notification can arrive before the response to the current request.
// This is fine, because we use the same id and register the handler before sending the request.
- notificationHandlers.put(id, notificationHandler);
+ notificationFut = new CompletableFuture<>();
+ notificationHandlers.put(id, notificationFut);
}
- return send(opCode, id, payloadWriter, payloadReader);
+ return send(opCode, id, payloadWriter, payloadReader, notificationFut);
} catch (Throwable t) {
return CompletableFuture.failedFuture(t);
}
@@ -278,18 +281,23 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
/**
* Sends request.
*
- * @param opCode Operation code.
- * @param id Request id.
+ * @param opCode Operation code.
+ * @param id Request id.
* @param payloadWriter Payload writer to stream or {@code null} if request has no payload.
+ * @param notificationFut Optional notification future.
* @return Request future.
*/
private <T> ClientRequestFuture<T> send(
- int opCode, long id, @Nullable PayloadWriter payloadWriter, @Nullable PayloadReader<T> payloadReader) {
+ int opCode,
+ long id,
+ @Nullable PayloadWriter payloadWriter,
+ @Nullable PayloadReader<T> payloadReader,
+ @Nullable CompletableFuture<PayloadInputChannel> notificationFut) {
if (closed()) {
throw new IgniteClientConnectionException(CONNECTION_ERR, "Channel is closed");
}
- ClientRequestFuture<T> fut = new ClientRequestFuture<>(payloadReader);
+ ClientRequestFuture<T> fut = new ClientRequestFuture<>(payloadReader, notificationFut);
pendingReqs.put(id, fut);
metrics.requestsActiveIncrement();
@@ -348,7 +356,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
pendingReq.complete(null);
} else {
try {
- T res = pendingReq.payloadReader.apply(new PayloadInputChannel(this, unpacker));
+ T res = pendingReq.payloadReader.apply(new PayloadInputChannel(this, unpacker, pendingReq.notificationFut));
pendingReq.complete(res);
} catch (Exception e) {
log.error("Failed to deserialize server response [remoteAddress=" + cfg.getAddress() + "]: " + e.getMessage(), e);
@@ -424,7 +432,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
private void handleNotification(long id, ClientMessageUnpacker unpacker, @Nullable Throwable err) {
// One-shot notification handler - remove immediately.
- NotificationHandler handler = notificationHandlers.remove(id);
+ CompletableFuture<PayloadInputChannel> handler = notificationHandlers.remove(id);
if (handler == null) {
log.error("Unexpected notification ID [remoteAddress=" + cfg.getAddress() + "]: " + id);
@@ -433,9 +441,10 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
try {
if (err != null) {
- handler.consume(null, err);
+ handler.completeExceptionally(err);
} else {
- handler.consume(new PayloadInputChannel(this, unpacker), null);
+ unpacker.retain();
+ handler.complete(new PayloadInputChannel(this, unpacker, null));
}
} catch (Exception e) {
log.error("Failed to handle server notification [remoteAddress=" + cfg.getAddress() + "]: " + e.getMessage(), e);
@@ -533,7 +542,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
/** Client handshake. */
private CompletableFuture<Object> handshakeAsync(ProtocolVersion ver)
throws IgniteClientConnectionException {
- ClientRequestFuture<Object> fut = new ClientRequestFuture<>(r -> handshakeRes(r.in()));
+ ClientRequestFuture<Object> fut = new ClientRequestFuture<>(r -> handshakeRes(r.in()), null);
pendingReqs.put(-1L, fut);
handshakeReqAsync(ver).addListener(f -> {
@@ -704,8 +713,14 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
@Nullable
private final PayloadReader<T> payloadReader;
- private ClientRequestFuture(@Nullable PayloadReader<T> payloadReader) {
+ @Nullable
+ private final CompletableFuture<PayloadInputChannel> notificationFut;
+
+ private ClientRequestFuture(
+ @Nullable PayloadReader<T> payloadReader,
+ @Nullable CompletableFuture<PayloadInputChannel> notificationFut) {
this.payloadReader = payloadReader;
+ this.notificationFut = notificationFut;
}
}
@@ -725,7 +740,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
@Override public void run() {
try {
if (System.currentTimeMillis() - lastSendMillis > interval) {
- var fut = serviceAsync(ClientOp.HEARTBEAT, null, null, null);
+ var fut = serviceAsync(ClientOp.HEARTBEAT, null, null, false);
if (connectTimeout > 0) {
fut
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java b/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java
index 9991a9a888..8fb587f789 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java
@@ -33,6 +33,7 @@ import java.util.function.BiConsumer;
import org.apache.ignite.compute.DeploymentUnit;
import org.apache.ignite.compute.IgniteCompute;
import org.apache.ignite.internal.client.ClientUtils;
+import org.apache.ignite.internal.client.PayloadInputChannel;
import org.apache.ignite.internal.client.PayloadOutputChannel;
import org.apache.ignite.internal.client.ReliableChannel;
import org.apache.ignite.internal.client.proto.ClientMessagePacker;
@@ -218,8 +219,6 @@ public class ClientCompute implements IgniteCompute {
}
private <R> CompletableFuture<R> executeOnOneNode(ClusterNode node, List<DeploymentUnit> units, String jobClassName, Object[] args) {
- CompletableFuture<R> notificationFut = new CompletableFuture<>();
-
var reqFut = ch.serviceAsync(
ClientOp.COMPUTE_EXECUTE,
w -> {
@@ -231,19 +230,19 @@ public class ClientCompute implements IgniteCompute {
packJob(w.out(), units, jobClassName, args);
},
- r -> null,
+ ch -> ch,
node.name(),
null,
- (r, err) -> {
- if (err != null) {
- notificationFut.completeExceptionally(err);
- } else {
- assert r != null;
- notificationFut.complete((R) r.in().unpackObjectFromBinaryTuple());
+ true);
+
+ return reqFut
+ .thenCompose(PayloadInputChannel::notificationFuture)
+ .thenApply(r -> {
+ // Notifications require explicit input close.
+ try (r) {
+ return (R) r.in().unpackObjectFromBinaryTuple();
}
});
-
- return reqFut.thenCompose(v -> notificationFut);
}
private static ClusterNode randomNode(Set<ClusterNode> nodes) {
@@ -299,8 +298,6 @@ public class ClientCompute implements IgniteCompute {
List<DeploymentUnit> units,
String jobClassName,
Object[] args) {
- CompletableFuture<R> notificationFut = new CompletableFuture<>();
-
var reqFut = t.doSchemaOutOpAsync(
ClientOp.COMPUTE_EXECUTE_COLOCATED,
(schema, outputChannel) -> {
@@ -313,18 +310,18 @@ public class ClientCompute implements IgniteCompute {
packJob(w, units, jobClassName, args);
},
- r -> null,
+ ch -> ch,
partitionAwarenessProvider,
- (r, err) -> {
- if (err != null) {
- notificationFut.completeExceptionally(err);
- } else {
- assert r != null;
- notificationFut.complete((R) r.in().unpackObjectFromBinaryTuple());
+ true);
+
+ return reqFut
+ .thenCompose(PayloadInputChannel::notificationFuture)
+ .thenApply(r -> {
+ // Notifications require explicit input close.
+ try (r) {
+ return (R) r.in().unpackObjectFromBinaryTuple();
}
});
-
- return reqFut.thenCompose(v -> notificationFut);
}
private CompletableFuture<ClientTable> getTable(String tableName) {
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java
index 20838e0016..72cee01445 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueBinaryView.java
@@ -30,7 +30,6 @@ import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Flow.Publisher;
import org.apache.ignite.client.RetryLimitPolicy;
-import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.internal.streamer.StreamerBatchSender;
import org.apache.ignite.internal.util.IgniteUtils;
@@ -80,7 +79,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> ser.writeTuple(tx, key, s, w, true),
- ClientTupleSerializer::readValueTuple,
+ (s, r) -> ClientTupleSerializer.readValueTuple(s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -103,7 +102,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_ALL,
(s, w) -> ser.writeTuples(tx, keys, s, w, true),
- ClientTupleSerializer::readKvTuplesNullable,
+ (s, r) -> ClientTupleSerializer.readKvTuplesNullable(s, r.in()),
Collections.emptyMap(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keys.iterator().next()));
}
@@ -142,7 +141,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> ser.writeTuple(tx, key, s, w, true),
- (s, r) -> IgniteUtils.nonNullOrElse(ClientTupleSerializer.readValueTuple(s, r), defaultValue),
+ (s, r) -> IgniteUtils.nonNullOrElse(ClientTupleSerializer.readValueTuple(s, r.in()), defaultValue),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -161,7 +160,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_CONTAINS_KEY,
(s, w) -> ser.writeTuple(tx, key, s, w, true),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -220,7 +219,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
(s, w) -> ser.writeKvTuple(tx, key, val, s, w, false),
- ClientTupleSerializer::readValueTuple,
+ (s, r) -> ClientTupleSerializer.readValueTuple(s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -260,7 +259,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_INSERT,
(s, w) -> ser.writeKvTuple(tx, key, val, s, w, false),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -284,7 +283,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE,
(s, w) -> ser.writeTuple(tx, key, s, w, true),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -297,7 +296,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE_EXACT,
(s, w) -> ser.writeKvTuple(tx, key, val, s, w, false),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -319,7 +318,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_DELETE_ALL,
(s, w) -> ser.writeTuples(tx, keys, s, w, true),
- (s, r) -> ClientTupleSerializer.readTuples(s, r, true),
+ (s, r) -> ClientTupleSerializer.readTuples(s, r.in(), true),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keys.iterator().next()));
}
@@ -338,7 +337,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_DELETE,
(s, w) -> ser.writeTuple(tx, key, s, w, true),
- ClientTupleSerializer::readValueTuple,
+ (s, r) -> ClientTupleSerializer.readValueTuple(s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -383,7 +382,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE,
(s, w) -> ser.writeKvTuple(tx, key, val, s, w, false),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -398,7 +397,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
ser.writeKvTuple(tx, key, oldVal, s, w, false);
ser.writeKvTuple(tx, key, newVal, s, w, true);
},
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -417,7 +416,7 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_REPLACE,
(s, w) -> ser.writeKvTuple(tx, key, val, s, w, false),
- ClientTupleSerializer::readValueTuple,
+ (s, r) -> ClientTupleSerializer.readValueTuple(s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, key));
}
@@ -460,7 +459,6 @@ public class ClientKeyValueBinaryView implements KeyValueView<Tuple, Tuple> {
PartitionAwarenessProvider.of(nodeName),
new RetryLimitPolicy().retryLimit(opts.retryLimit()));
- //noinspection resource
return ClientDataStreamer.streamData(publisher, opts, batchSender, provider, tbl);
}
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
index 9a6947512f..2bc3c9ccf6 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
@@ -37,8 +37,8 @@ import java.util.concurrent.Flow.Publisher;
import org.apache.ignite.client.RetryLimitPolicy;
import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
import org.apache.ignite.internal.binarytuple.BinaryTupleReader;
+import org.apache.ignite.internal.client.PayloadInputChannel;
import org.apache.ignite.internal.client.PayloadOutputChannel;
-import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.internal.client.proto.TuplePart;
import org.apache.ignite.internal.marshaller.ClientMarshallerReader;
@@ -100,7 +100,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- (s, r) -> throwIfNull(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> throwIfNull(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -120,7 +120,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- (s, r) -> NullableValue.of(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> NullableValue.of(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -139,7 +139,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- (s, r) -> valSer.readRec(s, r, TuplePart.VAL),
+ (s, r) -> valSer.readRec(s, r.in(), TuplePart.VAL),
defaultValue,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -181,7 +181,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_CONTAINS_KEY,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -246,7 +246,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- (s, r) -> throwIfNull(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> throwIfNull(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -265,7 +265,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- (s, r) -> NullableValue.of(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> NullableValue.of(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -284,7 +284,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_INSERT,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -308,7 +308,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -320,7 +320,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE_EXACT,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -342,7 +342,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_DELETE_ALL,
(s, w) -> keySer.writeRecs(tx, keys, s, w, TuplePart.KEY),
- (s, r) -> keySer.readRecs(s, r, false, TuplePart.KEY),
+ (s, r) -> keySer.readRecs(s, r.in(), false, TuplePart.KEY),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), keys.iterator().next()));
}
@@ -361,7 +361,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_DELETE,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- (s, r) -> throwIfNull(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> throwIfNull(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -380,7 +380,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_DELETE,
(s, w) -> keySer.writeRec(tx, key, s, w, TuplePart.KEY),
- (s, r) -> NullableValue.of(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> NullableValue.of(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -407,7 +407,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -423,7 +423,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
writeKeyValueRaw(s, w, key, oldVal);
writeKeyValueRaw(s, w, key, newVal);
},
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -442,7 +442,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_REPLACE,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- (s, r) -> throwIfNull(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> throwIfNull(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -462,7 +462,7 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_REPLACE,
(s, w) -> writeKeyValue(s, w, tx, key, val),
- (s, r) -> NullableValue.of(valSer.readRec(s, r, TuplePart.VAL)),
+ (s, r) -> NullableValue.of(valSer.readRec(s, r.in(), TuplePart.VAL)),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keySer.mapper(), key));
}
@@ -493,8 +493,8 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
w.out().packInt(s.version());
}
- private HashMap<K, V> readGetAllResponse(ClientSchema schema, ClientMessageUnpacker in) {
- var cnt = in.unpackInt();
+ private HashMap<K, V> readGetAllResponse(ClientSchema schema, PayloadInputChannel in) {
+ var cnt = in.in().unpackInt();
var res = new LinkedHashMap<K, V>(cnt);
@@ -504,8 +504,8 @@ public class ClientKeyValueView<K, V> implements KeyValueView<K, V> {
try {
for (int i = 0; i < cnt; i++) {
// TODO: Optimize (IGNITE-16022).
- if (in.unpackBoolean()) {
- var tupleReader = new BinaryTupleReader(schema.columns().length, in.readBinaryUnsafe());
+ if (in.in().unpackBoolean()) {
+ var tupleReader = new BinaryTupleReader(schema.columns().length, in.in().readBinaryUnsafe());
var reader = new ClientMarshallerReader(tupleReader);
res.put((K) keyMarsh.readObject(reader, null), (V) valMarsh.readObject(reader, null));
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
index a8d5170e4f..1a75c59a9f 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordBinaryView.java
@@ -28,7 +28,6 @@ import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Flow.Publisher;
import org.apache.ignite.client.RetryLimitPolicy;
-import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.internal.streamer.StreamerBatchSender;
import org.apache.ignite.table.DataStreamerOptions;
@@ -73,7 +72,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> ser.writeTuple(tx, keyRec, s, w, true),
- (s, r) -> ClientTupleSerializer.readTuple(s, r, false),
+ (s, r) -> ClientTupleSerializer.readTuple(s, r.in(), false),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keyRec));
}
@@ -94,7 +93,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_ALL,
(s, w) -> ser.writeTuples(tx, keyRecs, s, w, true),
- ClientTupleSerializer::readTuplesNullable,
+ (s, r) -> ClientTupleSerializer.readTuplesNullable(s, r.in()),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keyRecs.iterator().next())
);
@@ -154,7 +153,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
(s, w) -> ser.writeTuple(tx, rec, s, w, false),
- (s, r) -> ClientTupleSerializer.readTuple(s, r, false),
+ (s, r) -> ClientTupleSerializer.readTuple(s, r.in(), false),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, rec));
}
@@ -173,7 +172,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_INSERT,
(s, w) -> ser.writeTuple(tx, rec, s, w, false),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, rec));
}
@@ -195,7 +194,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_INSERT_ALL,
(s, w) -> ser.writeTuples(tx, recs, s, w, false),
- ClientTupleSerializer::readTuples,
+ (s, r) -> ClientTupleSerializer.readTuples(s, r.in()),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, recs.iterator().next()));
}
@@ -220,7 +219,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE,
(s, w) -> ser.writeTuple(tx, rec, s, w, false),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, rec));
}
@@ -236,7 +235,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
ser.writeTuple(tx, oldRec, s, w, false, false);
ser.writeTuple(tx, newRec, s, w, false, true);
},
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, oldRec));
}
@@ -254,7 +253,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_REPLACE,
(s, w) -> ser.writeTuple(tx, rec, s, w, false),
- (s, r) -> ClientTupleSerializer.readTuple(s, r, false),
+ (s, r) -> ClientTupleSerializer.readTuple(s, r.in(), false),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, rec));
}
@@ -273,7 +272,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE,
(s, w) -> ser.writeTuple(tx, keyRec, s, w, true),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keyRec));
}
@@ -291,7 +290,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE_EXACT,
(s, w) -> ser.writeTuple(tx, rec, s, w, false),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, rec));
}
@@ -309,7 +308,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_DELETE,
(s, w) -> ser.writeTuple(tx, keyRec, s, w, true),
- (s, r) -> ClientTupleSerializer.readTuple(s, r, false),
+ (s, r) -> ClientTupleSerializer.readTuple(s, r.in(), false),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keyRec));
}
@@ -332,7 +331,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_DELETE_ALL,
(s, w) -> ser.writeTuples(tx, keyRecs, s, w, true),
- (s, r) -> ClientTupleSerializer.readTuples(s, r, true),
+ (s, r) -> ClientTupleSerializer.readTuples(s, r.in(), true),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, keyRecs.iterator().next()));
}
@@ -355,7 +354,7 @@ public class ClientRecordBinaryView implements RecordView<Tuple> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_DELETE_ALL_EXACT,
(s, w) -> ser.writeTuples(tx, recs, s, w, false),
- ClientTupleSerializer::readTuples,
+ (s, r) -> ClientTupleSerializer.readTuples(s, r.in()),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, recs.iterator().next()));
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordView.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordView.java
index 034f6c40d0..41f89af706 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordView.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientRecordView.java
@@ -28,7 +28,6 @@ import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Flow.Publisher;
import org.apache.ignite.client.RetryLimitPolicy;
-import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
import org.apache.ignite.internal.client.proto.ClientOp;
import org.apache.ignite.internal.client.proto.TuplePart;
import org.apache.ignite.internal.streamer.StreamerBatchSender;
@@ -73,7 +72,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
(s, w) -> ser.writeRec(tx, keyRec, s, w, TuplePart.KEY),
- (s, r) -> ser.readValRec(keyRec, s, r),
+ (s, r) -> ser.readValRec(keyRec, s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), keyRec));
}
@@ -94,7 +93,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_ALL,
(s, w) -> ser.writeRecs(tx, keyRecs, s, w, TuplePart.KEY),
- (s, r) -> ser.readRecs(s, r, true, TuplePart.KEY_AND_VAL),
+ (s, r) -> ser.readRecs(s, r.in(), true, TuplePart.KEY_AND_VAL),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), keyRecs.iterator().next())
);
@@ -154,7 +153,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
(s, w) -> ser.writeRec(tx, rec, s, w, TuplePart.KEY_AND_VAL),
- (s, r) -> ser.readValRec(rec, s, r),
+ (s, r) -> ser.readValRec(rec, s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), rec));
}
@@ -173,7 +172,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_INSERT,
(s, w) -> ser.writeRec(tx, rec, s, w, TuplePart.KEY_AND_VAL),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), rec));
}
@@ -195,7 +194,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_INSERT_ALL,
(s, w) -> ser.writeRecs(tx, recs, s, w, TuplePart.KEY_AND_VAL),
- (s, r) -> ser.readRecs(s, r, false, TuplePart.KEY_AND_VAL),
+ (s, r) -> ser.readRecs(s, r.in(), false, TuplePart.KEY_AND_VAL),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), recs.iterator().next()));
}
@@ -220,7 +219,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE,
(s, w) -> ser.writeRec(tx, rec, s, w, TuplePart.KEY_AND_VAL),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), rec));
}
@@ -233,7 +232,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE_EXACT,
(s, w) -> ser.writeRecs(tx, oldRec, newRec, s, w, TuplePart.KEY_AND_VAL),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), oldRec));
}
@@ -251,7 +250,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_REPLACE,
(s, w) -> ser.writeRec(tx, rec, s, w, TuplePart.KEY_AND_VAL),
- (s, r) -> ser.readValRec(rec, s, r),
+ (s, r) -> ser.readValRec(rec, s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), rec));
}
@@ -270,7 +269,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE,
(s, w) -> ser.writeRec(tx, keyRec, s, w, TuplePart.KEY),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), keyRec));
}
@@ -288,7 +287,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE_EXACT,
(s, w) -> ser.writeRec(tx, rec, s, w, TuplePart.KEY_AND_VAL),
- ClientMessageUnpacker::unpackBoolean,
+ r -> r.in().unpackBoolean(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), rec));
}
@@ -306,7 +305,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_DELETE,
(s, w) -> ser.writeRec(tx, keyRec, s, w, TuplePart.KEY),
- (s, r) -> ser.readValRec(keyRec, s, r),
+ (s, r) -> ser.readValRec(keyRec, s, r.in()),
null,
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), keyRec));
}
@@ -329,7 +328,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_DELETE_ALL,
(s, w) -> ser.writeRecs(tx, keyRecs, s, w, TuplePart.KEY),
- (s, r) -> ser.readRecs(s, r, false, TuplePart.KEY),
+ (s, r) -> ser.readRecs(s, r.in(), false, TuplePart.KEY),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), keyRecs.iterator().next()));
}
@@ -352,7 +351,7 @@ public class ClientRecordView<R> implements RecordView<R> {
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_DELETE_ALL_EXACT,
(s, w) -> ser.writeRecs(tx, recs, s, w, TuplePart.KEY_AND_VAL),
- (s, r) -> ser.readRecs(s, r, false, TuplePart.KEY_AND_VAL),
+ (s, r) -> ser.readRecs(s, r.in(), false, TuplePart.KEY_AND_VAL),
Collections.emptyList(),
ClientTupleSerializer.getPartitionAwarenessProvider(tx, ser.mapper(), recs.iterator().next()));
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
index 793b9eac0f..faee18b10c 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java
@@ -33,7 +33,7 @@ import java.util.function.Function;
import org.apache.ignite.client.RetryPolicy;
import org.apache.ignite.internal.client.ClientSchemaVersionMismatchException;
import org.apache.ignite.internal.client.ClientUtils;
-import org.apache.ignite.internal.client.NotificationHandler;
+import org.apache.ignite.internal.client.PayloadInputChannel;
import org.apache.ignite.internal.client.PayloadOutputChannel;
import org.apache.ignite.internal.client.ReliableChannel;
import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;
@@ -291,11 +291,10 @@ public class ClientTable implements Table {
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
- @SuppressWarnings("ClassEscapesDefinedScope")
public <T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
BiConsumer<ClientSchema, PayloadOutputChannel> writer,
- Function<ClientMessageUnpacker, T> reader,
+ Function<PayloadInputChannel, T> reader,
@Nullable PartitionAwarenessProvider provider) {
return doSchemaOutInOpAsync(
opCode,
@@ -306,7 +305,7 @@ public class ClientTable implements Table {
provider,
null,
null,
- null);
+ false);
}
/**
@@ -316,17 +315,16 @@ public class ClientTable implements Table {
* @param writer Writer.
* @param reader Reader.
* @param provider Partition awareness provider.
- * @param notificationHandler Notification handler.
+ * @param expectNotifications Whether to expect notifications as a result of the operation.
* @param <T> Result type.
* @return Future representing pending completion of the operation.
*/
- @SuppressWarnings("ClassEscapesDefinedScope")
public <T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
BiConsumer<ClientSchema, PayloadOutputChannel> writer,
- Function<ClientMessageUnpacker, T> reader,
+ Function<PayloadInputChannel, T> reader,
@Nullable PartitionAwarenessProvider provider,
- @Nullable NotificationHandler notificationHandler) {
+ boolean expectNotifications) {
return doSchemaOutInOpAsync(
opCode,
writer,
@@ -336,7 +334,7 @@ public class ClientTable implements Table {
provider,
null,
null,
- notificationHandler);
+ expectNotifications);
}
/**
@@ -352,7 +350,7 @@ public class ClientTable implements Table {
<T> CompletableFuture<T> doSchemaOutOpAsync(
int opCode,
BiConsumer<ClientSchema, PayloadOutputChannel> writer,
- Function<ClientMessageUnpacker, T> reader,
+ Function<PayloadInputChannel, T> reader,
@Nullable PartitionAwarenessProvider provider,
@Nullable RetryPolicy retryPolicyOverride) {
return doSchemaOutInOpAsync(
@@ -364,7 +362,7 @@ public class ClientTable implements Table {
provider,
retryPolicyOverride,
null,
- null);
+ false);
}
/**
@@ -381,11 +379,11 @@ public class ClientTable implements Table {
<T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
BiConsumer<ClientSchema, PayloadOutputChannel> writer,
- BiFunction<ClientSchema, ClientMessageUnpacker, T> reader,
+ BiFunction<ClientSchema, PayloadInputChannel, T> reader,
@Nullable T defaultValue,
@Nullable PartitionAwarenessProvider provider
) {
- return doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, true, provider, null, null, null);
+ return doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, true, provider, null, null, false);
}
/**
@@ -405,13 +403,13 @@ public class ClientTable implements Table {
private <T> CompletableFuture<T> doSchemaOutInOpAsync(
int opCode,
BiConsumer<ClientSchema, PayloadOutputChannel> writer,
- BiFunction<ClientSchema, ClientMessageUnpacker, T> reader,
+ BiFunction<ClientSchema, PayloadInputChannel, T> reader,
@Nullable T defaultValue,
boolean responseSchemaRequired,
@Nullable PartitionAwarenessProvider provider,
@Nullable RetryPolicy retryPolicyOverride,
@Nullable Integer schemaVersionOverride,
- @Nullable NotificationHandler notificationHandler) {
+ boolean expectNotifications) {
CompletableFuture<T> fut = new CompletableFuture<>();
CompletableFuture<ClientSchema> schemaFut = getSchema(schemaVersionOverride == null ? latestSchemaVer : schemaVersionOverride);
@@ -428,10 +426,10 @@ public class ClientTable implements Table {
// Perform the operation.
return ch.serviceAsync(opCode,
w -> writer.accept(schema, w),
- r -> readSchemaAndReadData(schema, r.in(), reader, defaultValue, responseSchemaRequired),
+ r -> readSchemaAndReadData(schema, r, reader, defaultValue, responseSchemaRequired),
preferredNodeName,
retryPolicyOverride,
- notificationHandler);
+ expectNotifications);
})
// Read resulting schema and the rest of the response.
@@ -451,7 +449,7 @@ public class ClientTable implements Table {
int expectedVersion = ((ClientSchemaVersionMismatchException) cause).expectedVersion();
doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, responseSchemaRequired, provider,
- retryPolicyOverride, expectedVersion, notificationHandler)
+ retryPolicyOverride, expectedVersion, expectNotifications)
.whenComplete((res0, err0) -> {
if (err0 != null) {
fut.completeExceptionally(err0);
@@ -467,7 +465,7 @@ public class ClientTable implements Table {
schemas.remove(UNKNOWN_SCHEMA_VERSION);
doSchemaOutInOpAsync(opCode, writer, reader, defaultValue, responseSchemaRequired, provider,
- retryPolicyOverride, UNKNOWN_SCHEMA_VERSION, notificationHandler)
+ retryPolicyOverride, UNKNOWN_SCHEMA_VERSION, expectNotifications)
.whenComplete((res0, err0) -> {
if (err0 != null) {
fut.completeExceptionally(err0);
@@ -490,12 +488,12 @@ public class ClientTable implements Table {
private <T> @Nullable Object readSchemaAndReadData(
ClientSchema knownSchema,
- ClientMessageUnpacker in,
- BiFunction<ClientSchema, ClientMessageUnpacker, T> fn,
+ PayloadInputChannel in,
+ BiFunction<ClientSchema, PayloadInputChannel, T> fn,
@Nullable T defaultValue,
boolean responseSchemaRequired
) {
- int schemaVer = in.unpackInt();
+ int schemaVer = in.in().unpackInt();
if (!responseSchemaRequired) {
ensureSchemaLoadedAsync(schemaVer);
@@ -503,7 +501,7 @@ public class ClientTable implements Table {
return fn.apply(null, in);
}
- if (in.tryUnpackNil()) {
+ if (in.in().tryUnpackNil()) {
ensureSchemaLoadedAsync(schemaVer);
return defaultValue;
@@ -517,18 +515,19 @@ public class ClientTable implements Table {
// Schema is not yet known - request.
// Retain unpacker - normally it is closed when this method exits.
- return new IgniteBiTuple<>(in.retain(), schemaVer);
+ in.in().retain();
+ return new IgniteBiTuple<>(in, schemaVer);
}
private <T> CompletionStage<T> loadSchemaAndReadData(
Object data,
- BiFunction<ClientSchema, ClientMessageUnpacker, T> fn
+ BiFunction<ClientSchema, PayloadInputChannel, T> fn
) {
if (!(data instanceof IgniteBiTuple)) {
return CompletableFuture.completedFuture((T) data);
}
- var biTuple = (IgniteBiTuple<ClientMessageUnpacker, Integer>) data;
+ var biTuple = (IgniteBiTuple<PayloadInputChannel, Integer>) data;
var in = biTuple.getKey();
var schemaId = biTuple.getValue();
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java
index e1ffc8f075..831ed590fa 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java
@@ -45,7 +45,6 @@ import org.apache.ignite.lang.TableNotFoundException;
import org.apache.ignite.table.Tuple;
import org.apache.ignite.table.mapper.Mapper;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -100,7 +99,6 @@ public class ClientComputeTest extends BaseIgniteAbstractTest {
}
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-21034")
public void testClientRetriesComputeJobOnPrimaryAndDefaultNodes() throws Exception {
initServers(reqId -> reqId % 3 == 0);
diff --git a/modules/client/src/test/java/org/apache/ignite/internal/client/RepeatedFinishClientTransactionTest.java b/modules/client/src/test/java/org/apache/ignite/internal/client/RepeatedFinishClientTransactionTest.java
index eee78bf302..e893102503 100644
--- a/modules/client/src/test/java/org/apache/ignite/internal/client/RepeatedFinishClientTransactionTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/internal/client/RepeatedFinishClientTransactionTest.java
@@ -181,7 +181,7 @@ public class RepeatedFinishClientTransactionTest extends BaseIgniteAbstractTest
@Override
public <T> CompletableFuture<T> serviceAsync(
- int opCode, PayloadWriter payloadWriter, PayloadReader<T> payloadReader, NotificationHandler notificationHandler) {
+ int opCode, PayloadWriter payloadWriter, PayloadReader<T> payloadReader, boolean expectNotifications) {
txFinishStartedLatch.countDown();
try {