You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2021/11/22 08:22:46 UTC
[ignite] branch ignite-2.12 updated: IGNITE-15924 Thin client cache for OptimizedMarshaller class names (#9576)
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch ignite-2.12
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/ignite-2.12 by this push:
new 4da5185 IGNITE-15924 Thin client cache for OptimizedMarshaller class names (#9576)
4da5185 is described below
commit 4da51857d6acaebadab630b91eca829898a9cfb6
Author: Nikolay <ni...@apache.org>
AuthorDate: Mon Nov 22 11:03:06 2021 +0300
IGNITE-15924 Thin client cache for OptimizedMarshaller class names (#9576)
(cherry picked from commit 620ee3f26832b092e41bcaec6fbc992c040d2463)
---
.../internal/client/thin/TcpIgniteClient.java | 3 +
.../thin/OptimizedMarshallerClassesCachedTest.java | 86 ++++++++++++++++++++++
.../org/apache/ignite/client/ClientTestSuite.java | 4 +-
3 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
index 13ae567..236f6ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
@@ -632,6 +632,9 @@ public class TcpIgniteClient implements IgniteClient {
catch (ClientException e) {
throw new IgniteCheckedException(e);
}
+
+ if (clsName != null)
+ cache.putIfAbsent(typeId, clsName);
}
if (clsName == null)
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/OptimizedMarshallerClassesCachedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/OptimizedMarshallerClassesCachedTest.java
new file mode 100644
index 0000000..e3a7cd5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/OptimizedMarshallerClassesCachedTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.thin;
+
+import java.time.LocalDateTime;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.client.ClientException;
+import org.apache.ignite.client.Config;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/** */
+public class OptimizedMarshallerClassesCachedTest extends GridCommonAbstractTest {
+ /** */
+ private final AtomicInteger cnt = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ return super.getConfiguration(igniteInstanceName);
+ }
+
+ /** Test check that meta for classes serialized by {@link OptimizedMarshaller} are cached on client. */
+ @Test
+ public void testLocalDateTimeMetaCached() throws Exception {
+ try (Ignite srv = startGrid(0)) {
+ srv.getOrCreateCache(Config.DEFAULT_CACHE_NAME).put(1, LocalDateTime.now());
+
+ IgniteClient cli = new TcpIgniteClient((cfg0, hnd) -> new TcpClientChannel(cfg0, hnd) {
+ @Override public <T> T service(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader
+ ) throws ClientException {
+ if (op == ClientOperation.GET_BINARY_TYPE_NAME)
+ cnt.incrementAndGet();
+
+ return super.service(op, payloadWriter, payloadReader);
+ }
+
+ @Override public <T> CompletableFuture<T> serviceAsync(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader
+ ) {
+ if (op == ClientOperation.GET_BINARY_TYPE_NAME)
+ cnt.incrementAndGet();
+
+ return super.serviceAsync(op, payloadWriter, payloadReader);
+ }
+ }, new ClientConfiguration().setAddresses(Config.SERVER));
+
+ try {
+ cli.cache(Config.DEFAULT_CACHE_NAME).get(1);
+ cli.cache(Config.DEFAULT_CACHE_NAME).get(1);
+ }
+ finally {
+ cli.close();
+ }
+
+ assertEquals(1, cnt.get());
+ }
+ }
+}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
index 85255ce..7da1a83 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.client.thin.CacheEntryListenersTest;
import org.apache.ignite.internal.client.thin.ClusterApiTest;
import org.apache.ignite.internal.client.thin.ClusterGroupTest;
import org.apache.ignite.internal.client.thin.ComputeTaskTest;
+import org.apache.ignite.internal.client.thin.OptimizedMarshallerClassesCachedTest;
import org.apache.ignite.internal.client.thin.ReliableChannelTest;
import org.apache.ignite.internal.client.thin.ServicesTest;
import org.apache.ignite.internal.client.thin.ThinClientPartitionAwarenessDiscoveryTest;
@@ -64,7 +65,8 @@ import org.junit.runners.Suite;
ThinClientPartitionAwarenessDiscoveryTest.class,
ReliableChannelTest.class,
CacheAsyncTest.class,
- TimeoutTest.class
+ TimeoutTest.class,
+ OptimizedMarshallerClassesCachedTest.class,
})
public class ClientTestSuite {
// No-op.