You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/09/08 07:55:52 UTC
[10/27] ignite git commit: IGNITE-2779 BinaryMarshaller caches must
be cleaned during client reconnect
IGNITE-2779 BinaryMarshaller caches must be cleaned during client reconnect
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c6ac6a56
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c6ac6a56
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c6ac6a56
Branch: refs/heads/ignite-3484
Commit: c6ac6a56171564be7d2277fd8af757b5724c27ae
Parents: 0ece83f
Author: NSAmelchev <ns...@gmail.com>
Authored: Wed Sep 6 17:32:42 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Sep 6 17:32:42 2017 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 14 +++
.../binary/CacheObjectBinaryProcessorImpl.java | 3 +-
.../IgniteClientReconnectBinaryContexTest.java | 115 +++++++++++++++++++
.../IgniteClientReconnectTestSuite.java | 2 +
4 files changed, 133 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c6ac6a56/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index afa40e6..dd192bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -1367,6 +1367,20 @@ public class BinaryContext {
}
/**
+ * Unregisters the user types descriptors.
+ **/
+ public void unregisterUserTypeDescriptors() {
+ Iterator<Map.Entry<Class<?>, BinaryClassDescriptor>> it = descByCls.entrySet().iterator();
+
+ while (it.hasNext()) {
+ Map.Entry<Class<?>, BinaryClassDescriptor> e = it.next();
+
+ if (e.getValue().userType())
+ it.remove();
+ }
+ }
+
+ /**
* Returns instance of {@link OptimizedMarshaller}.
*
* @return Optimized marshaller.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c6ac6a56/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 16d9fd0..5b43f8f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -113,9 +113,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@GridToStringExclude
private IgniteBinary binaries;
- /** Listener removes all registered binary schemas after the local client reconnected. */
+ /** Listener removes all registered binary schemas and user type descriptors after the local client reconnected. */
private final GridLocalEventListener clientDisconLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
+ binaryContext().unregisterUserTypeDescriptors();
binaryContext().unregisterBinarySchemas();
metadataLocCache.clear();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c6ac6a56/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectBinaryContexTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectBinaryContexTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectBinaryContexTest.java
new file mode 100644
index 0000000..1486476
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectBinaryContexTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ *
+ */
+public class IgniteClientReconnectBinaryContexTest extends IgniteClientReconnectAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int serverCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected int clientCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setPeerClassLoadingEnabled(false);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReconnectCleaningUsersMetadata() throws Exception {
+ Ignite client = grid(serverCount());
+
+ assertTrue(client.cluster().localNode().isClient());
+
+ Ignite srv = grid(0);
+
+ CacheConfiguration<Integer, UserClass> cacheCfg = new CacheConfiguration<Integer, UserClass>()
+ .setName(DEFAULT_CACHE_NAME)
+ .setCacheMode(CacheMode.REPLICATED);
+
+ IgniteCache<Integer, UserClass> cache = client.createCache(cacheCfg);
+
+ Integer key = 1;
+ UserClass val = new UserClass(1);
+
+ cache.put(key, val); // For registering user types binary metadata
+
+ reconnectServersRestart(log, client, Collections.singleton(srv), new Callable<Collection<Ignite>>() {
+ @Override public Collection<Ignite> call() throws Exception {
+ return Collections.singleton((Ignite)startGrid(0));
+ }
+ });
+
+ cache = client.createCache(cacheCfg);
+
+ cache.put(key, val);
+
+ assertEquals(val, cache.get(key));
+ }
+
+ /** */
+ private static class UserClass {
+ /** */
+ private final int field;
+
+ /**
+ * @param field Value.
+ */
+ private UserClass(int field) {
+ this.field = field;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ UserClass val = (UserClass)o;
+
+ return field == val.field;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return field;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c6ac6a56/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
index 67d88e1..03d3fe2 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.IgniteClientReconnectApiExceptionTest;
import org.apache.ignite.internal.IgniteClientReconnectAtomicsTest;
+import org.apache.ignite.internal.IgniteClientReconnectBinaryContexTest;
import org.apache.ignite.internal.IgniteClientReconnectCacheTest;
import org.apache.ignite.internal.IgniteClientReconnectCollectionsTest;
import org.apache.ignite.internal.IgniteClientReconnectComputeTest;
@@ -46,6 +47,7 @@ public class IgniteClientReconnectTestSuite extends TestSuite {
suite.addTestSuite(IgniteClientReconnectApiExceptionTest.class);
suite.addTestSuite(IgniteClientReconnectDiscoveryStateTest.class);
suite.addTestSuite(IgniteClientReconnectCacheTest.class);
+ suite.addTestSuite(IgniteClientReconnectBinaryContexTest.class);
suite.addTestSuite(IgniteClientReconnectContinuousProcessorTest.class);
suite.addTestSuite(IgniteClientReconnectComputeTest.class);
suite.addTestSuite(IgniteClientReconnectAtomicsTest.class);