anton-vinogradov commented on code in PR #13095:
URL: https://github.com/apache/ignite/pull/13095#discussion_r3649847194


##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java:
##########
@@ -71,6 +73,9 @@ public class GridIoMessage implements Message, SpanTransport, 
MessageWrapper {
     @GridToStringInclude
     public @Nullable OperationContextMessage opCtxMsg;
 
+    /** Set once the payload is marshalled; guards double marshal and 
unmarshalled transmit. Not on the wire. */
+    private transient boolean marshalled;

Review Comment:
   Removed — the message travels only via the direct protocol (@Order fields), 
JDK serialization never applies to it.



##########
modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java:
##########
@@ -108,13 +104,20 @@ public 
TestMarshallableMessageMarshallableSerializer(Marshaller marshaller, Clas
                 reader.incrementState();
         }
 
-        try {
-            msg.finishUnmarshal(marshaller, clsLdr);
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteException("Failed to unmarshal object " + 
msg.getClass().getSimpleName(), e);
-        }
-
         return true;
     }
-}
+
+    /** */
+    @Override public void marshal(TestMarshallableMessage msg, 
GridKernalContext kctx, GridCacheContext<?, ?> nested) throws 
IgniteCheckedException {
+        GridCacheContext<?, ?> ctx = nested;

Review Comment:
   Right — a leftover golden from an earlier design iteration where 
marshal/unmarshal lived on the serializer (those methods no longer exist on 
MessageSerializer). Removed. Cross-checked every resource under codegen/ 
against the tests: this was the only unreferenced one.



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageUnmarshalThreadIntegrationTest.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.processors.query.calcite.message;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import 
org.apache.ignite.internal.processors.query.calcite.exec.task.AbstractQueryTaskExecutor;
+import 
org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest;
+import org.junit.Test;
+
+import static java.util.stream.Collectors.toList;
+
+/**
+ * Verifies that payload of calcite messages is unmarshalled on the query task 
executor, not on a NIO thread: probe
+ * objects travel as {@code QueryStartRequest} parameters and as {@code 
QueryBatchMessage} rows, and record the thread
+ * that deserializes them.
+ */
+public class CalciteMessageUnmarshalThreadIntegrationTest extends 
AbstractBasicIntegrationTest {
+    /** */
+    private static final int ROWS = 200;
+
+    /** Names of the threads that deserialized a {@link Probe}. */
+    private static final Queue<String> unmarshalThreads = new 
ConcurrentLinkedQueue<>();
+
+    /** {@inheritDoc} */
+    @Override protected int nodeCount() {
+        return 2;
+    }
+
+    /** */
+    @Test
+    public void testPayloadUnmarshalledOnQueryExecutor() {
+        sql("CREATE TABLE t(id INT PRIMARY KEY, oth OTHER)");
+
+        for (int i = 0; i < ROWS; i++)
+            sql("INSERT INTO t VALUES (?, ?)", i, new Probe());
+
+        unmarshalThreads.clear();
+
+        List<List<?>> res = sql("SELECT id, oth FROM t WHERE oth != ?", new 
Probe());
+
+        assertEquals(ROWS, res.size());
+
+        assertFalse("No probe deserialization recorded", 
unmarshalThreads.isEmpty());
+
+        List<String> nioThreads = unmarshalThreads.stream().filter(t -> 
t.contains("nio")).collect(toList());
+
+        assertTrue("Message payload unmarshalled on NIO threads: " + 
nioThreads, nioThreads.isEmpty());
+
+        assertTrue("No probe deserialization on the query task executor: " + 
unmarshalThreads,
+            unmarshalThreads.stream().anyMatch(t -> 
t.startsWith(AbstractQueryTaskExecutor.THREAD_PREFIX)));

Review Comment:
   Applied.



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteMessageUnmarshalThreadIntegrationTest.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.processors.query.calcite.message;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import 
org.apache.ignite.internal.processors.query.calcite.exec.task.AbstractQueryTaskExecutor;
+import 
org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest;
+import org.junit.Test;
+
+import static java.util.stream.Collectors.toList;
+
+/**
+ * Verifies that payload of calcite messages is unmarshalled on the query task 
executor, not on a NIO thread: probe
+ * objects travel as {@code QueryStartRequest} parameters and as {@code 
QueryBatchMessage} rows, and record the thread
+ * that deserializes them.
+ */
+public class CalciteMessageUnmarshalThreadIntegrationTest extends 
AbstractBasicIntegrationTest {
+    /** */
+    private static final int ROWS = 200;
+
+    /** Names of the threads that deserialized a {@link Probe}. */
+    private static final Queue<String> unmarshalThreads = new 
ConcurrentLinkedQueue<>();
+
+    /** {@inheritDoc} */
+    @Override protected int nodeCount() {
+        return 2;
+    }
+
+    /** */
+    @Test
+    public void testPayloadUnmarshalledOnQueryExecutor() {
+        sql("CREATE TABLE t(id INT PRIMARY KEY, oth OTHER)");
+
+        for (int i = 0; i < ROWS; i++)
+            sql("INSERT INTO t VALUES (?, ?)", i, new Probe());
+
+        unmarshalThreads.clear();
+
+        List<List<?>> res = sql("SELECT id, oth FROM t WHERE oth != ?", new 
Probe());
+
+        assertEquals(ROWS, res.size());
+
+        assertFalse("No probe deserialization recorded", 
unmarshalThreads.isEmpty());
+
+        List<String> nioThreads = unmarshalThreads.stream().filter(t -> 
t.contains("nio")).collect(toList());

Review Comment:
   Applied.



##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponseUnmarshalTest.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.processors.cache.query;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.communication.MessageMarshalling;
+import 
org.apache.ignite.internal.processors.cache.CacheObjectNotResolvedException;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/**
+ * Verifies that a query result row key arrives resolved from {@code 
GridCacheQueryResponse} unmarshalling: a
+ * {@code KeyCacheObject} travels bytes-only and forbids lazy resolution (see 
{@code @Marshalled}).
+ */
+public class GridCacheQueryResponseUnmarshalTest extends 
GridCommonAbstractTest {
+    /** An unresolved key (only its bytes present) must fail fast rather than 
resolve lazily. */
+    @Test
+    public void testUnresolvedKeyThrows() {

Review Comment:
   Moved.



##########
modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java:
##########
@@ -1318,15 +1319,19 @@ else if (e instanceof IgniteCheckedException)
         startTimer.finishGlobalStage("Await exchange");
     }
 
+    /** Test entry to {@link #initMessageFactory()}, which production reaches 
via {@link #start}. */
+    @TestOnly
+    public void initMessageFactoryForTest() throws IgniteCheckedException {

Review Comment:
   Removed the delegate; the test now uses U.invoke as suggested.



-- 
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]

Reply via email to