IGNITE-2965 Failed to read class name from file on deserialization
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c28faddb Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c28faddb Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c28faddb Branch: refs/heads/ignite-testing-discovery Commit: c28faddb51c02be70d7692141f215972fa3e976e Parents: 7b8bd7c Author: Anton Vinogradov <[email protected]> Authored: Mon Apr 11 17:41:32 2016 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Mon Apr 11 17:41:32 2016 +0300 ---------------------------------------------------------------------- .../ignite/internal/MarshallerContextImpl.java | 7 +- .../processors/cache/GridCacheAdapter.java | 2 +- .../processors/cache/GridCacheProxyImpl.java | 4 +- .../processors/cache/IgniteInternalCache.java | 4 +- .../dht/atomic/GridDhtAtomicCache.java | 4 +- .../distributed/near/GridNearAtomicCache.java | 4 +- .../MarshallerCacheJobRunNodeRestartTest.java | 307 +++++++++++++++++++ .../testsuites/IgniteCacheTestSuite4.java | 3 + 8 files changed, 323 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java index 05fe8ef..2023a58 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java @@ -119,7 +119,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter { String old; try { - old = cache0.tryPutIfAbsent(id, clsName); + old = cache0.tryGetAndPut(id, clsName); if (old != null && !old.equals(clsName)) throw new IgniteCheckedException("Type ID collision detected [id=" + id + ", clsName1=" + clsName + @@ -177,8 +177,9 @@ public class MarshallerContextImpl extends MarshallerContextAdapter { } } catch (IOException e) { - throw new IgniteCheckedException("Failed to read class name from file [id=" + id + - ", file=" + file.getAbsolutePath() + ']', e); + throw new IgniteCheckedException("Class definition was not found " + + "at marshaller cache and local file. " + + "[id=" + id + ", file=" + file.getAbsolutePath() + ']'); } } finally { http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index b8fcfb6..6d4ee58 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -2536,7 +2536,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } /** {@inheritDoc} */ - @Nullable @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { + @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { // Supported only in ATOMIC cache. throw new UnsupportedOperationException(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 9b4aff3..99dd608 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -1285,11 +1285,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte } /** {@inheritDoc} */ - @Nullable @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { + @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { - return delegate.tryPutIfAbsent(key, val); + return delegate.tryGetAndPut(key, val); } finally { gate.leave(prev); http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java index 68d0f06..d155b0e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java @@ -1951,7 +1951,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> { public V getTopologySafe(K key) throws IgniteCheckedException; /** - * Tries to put value in cache. Will fail with {@link GridCacheTryPutFailedException} + * Tries to get and put value in cache. Will fail with {@link GridCacheTryPutFailedException} * if topology exchange is in progress. * * @param key Key. @@ -1959,7 +1959,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> { * @return Old value. * @throws IgniteCheckedException In case of error. */ - @Nullable public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException; + @Nullable public V tryGetAndPut(K key, V val) throws IgniteCheckedException; /** * @param topVer Locked topology version. http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index 3a71b7a..11fd855 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -478,7 +478,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { + @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { A.notNull(key, "key", val, "val"); return (V)updateAllAsync0(F0.asMap(key, val), @@ -488,7 +488,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, true, false, - ctx.noValArray(), + null, false, UPDATE).get(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java index 63c073d..28cfc15 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java @@ -471,8 +471,8 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Nullable @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { - return dht.tryPutIfAbsent(key, val); + @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { + return dht.tryGetAndPut(key, val); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java new file mode 100644 index 0000000..c7aecb4 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java @@ -0,0 +1,307 @@ +/* + * 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; + +import java.io.Serializable; +import java.util.concurrent.Callable; +import org.apache.ignite.Ignite; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteCallable; +import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * + */ +public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest { + /** */ + private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** */ + private boolean client; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + cfg.setClientMode(client); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testJobRun() throws Exception { + for (int i = 0; i < 5; i++) { + U.resolveWorkDirectory("marshaller", true); + + log.info("Iteration: " + i); + + final int NODES = 3; + + startGridsMultiThreaded(NODES); + + client = true; + + startGrid(NODES); + + client = false; + + final IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>() { + @Override public Void call() throws Exception { + for (int i = 0; i < 3; i++) { + startGrid(NODES + 1); + + U.sleep(1000); + + stopGrid(NODES + 1); + } + + return null; + } + }); + + GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() { + @Override public void apply(Integer integer) { + Ignite ignite = ignite(integer % 4); + + while (!fut.isDone()) { + for (int i = 0; i < 10; i++) + ignite.compute().broadcast(job(i)); + } + } + }, (NODES + 1) * 5, "test"); + + stopAllGrids(); + } + } + + /** + * @param idx Job class index. + * @return Job. + */ + static IgniteCallable job(int idx) { + switch (idx) { + case 0: + return new Job1(); + case 1: + return new Job2(); + case 2: + return new Job3(); + case 3: + return new Job4(); + case 4: + return new Job5(); + case 5: + return new Job6(); + case 6: + return new Job7(); + case 7: + return new Job8(); + case 8: + return new Job9(); + case 9: + return new Job10(); + default: + fail(); + } + + fail(); + + return null; + } + + /** + * + */ + static class Job1 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class1(); + } + } + + /** + * + */ + static class Job2 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class2(); + } + } + + /** + * + */ + static class Job3 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class3(); + } + } + + /** + * + */ + static class Job4 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class4(); + } + } + + /** + * + */ + static class Job5 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class5(); + } + } + + /** + * + */ + static class Job6 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class6(); + } + } + + /** + * + */ + static class Job7 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class7(); + } + } + + /** + * + */ + static class Job8 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class8(); + } + } + + /** + * + */ + static class Job9 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class9(); + } + } + + /** + * + */ + static class Job10 implements IgniteCallable { + /** {@inheritDoc} */ + @Override public Object call() throws Exception { + return new Class10(); + } + } + + /** + * + */ + static class Class1 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class2 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class3 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class4 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class5 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class6 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class7 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class8 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class9 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class10 implements Serializable { + // No-op. + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/c28faddb/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index 7aab990..5a017e6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -87,6 +87,7 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCacheTypesTest; import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionAtomicSelfTest; import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionSelfTest; import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest; +import org.apache.ignite.internal.processors.cache.MarshallerCacheJobRunNodeRestartTest; import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest; import org.apache.ignite.internal.processors.cache.distributed.CacheGetFutureHangsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest; @@ -312,6 +313,8 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(IgniteCacheGetCustomCollectionsSelfTest.class); suite.addTestSuite(IgniteCacheLoadRebalanceEvictionSelfTest.class); + suite.addTestSuite(MarshallerCacheJobRunNodeRestartTest.class); + return suite; } } \ No newline at end of file
