ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-2893
Date Fri, 21 Apr 2017 10:21:24 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2893 [created] c20d1a279


ignite-2893


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c20d1a27
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c20d1a27
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c20d1a27

Branch: refs/heads/ignite-2893
Commit: c20d1a279b895d45d7d9d4713c03e6b3f1ed4c84
Parents: 8ad5a94
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Apr 21 13:21:17 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Apr 21 13:21:17 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheContext.java      |   8 +
 .../IgniteCacheDatabaseSharedManager.java       |   4 +-
 .../GridCacheAtomicReferenceImpl.java           | 108 +++++++++--
 .../GridCacheAtomicStampedImpl.java             |  68 ++++++-
 .../GridCacheCountDownLatchImpl.java            |   2 +-
 .../datastructures/GridCacheSemaphoreImpl.java  |   2 +-
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   4 +-
 ...IgniteDataStructuresNoClassOnServerTest.java |  30 +++
 .../CacheNoValueClassOnServerNodeTest.java      | 112 +-----------
 .../IgniteNoClassOnServerAbstractTest.java      | 135 ++++++++++++++
 modules/extdata/p2p/pom.xml                     |   6 +
 .../p2p/NoValueClassOnServerAbstractClient.java |  90 +++++++++
 .../CacheNoValueClassOnServerTestClient.java    |  79 ++++----
 ...DataStructuresNoClassOnServerTestClient.java | 181 +++++++++++++++++++
 14 files changed, 646 insertions(+), 183 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 9e6fc3776..edd108b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -2079,6 +2079,14 @@ public class GridCacheContext<K, V> implements Externalizable
{
             || (top.partitionState(localNodeId(), part) == OWNING);
     }
 
+    /**
+     * @param obj Object.
+     * @return {@code True}
+     */
+    public boolean knownJdkType(Object obj) {
+        return obj == null;
+    }
+
     /** {@inheritDoc} */
     @Override public void writeExternal(ObjectOutput out) throws IOException {
         U.writeString(out, igniteInstanceName());

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index e6fe7cd..705e74c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -706,12 +706,12 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
 
     /** {@inheritDoc} */
     @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException
{
-
+        // No-op.
     }
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException
{
-
+        // No-op.
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index b7dc007..7776a2a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -23,6 +23,7 @@ import java.io.InvalidObjectException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
+import java.util.concurrent.Callable;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
@@ -32,16 +33,22 @@ import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.lang.IgniteBiTuple;
 
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
 /**
  * Cache atomic reference implementation.
  */
-public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicReferenceEx<T>,
IgniteChangeGlobalStateSupport, Externalizable {
+public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicReferenceEx<T>,
+    IgniteChangeGlobalStateSupport, Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -124,11 +131,30 @@ public final class GridCacheAtomicReferenceImpl<T> implements
GridCacheAtomicRef
     }
 
     /** {@inheritDoc} */
-    @Override public void set(T val) {
+    @Override public void set(final T val) {
         checkRemoved();
 
         try {
-            atomicView.invoke(key, new ReferenceSetEntryProcessor<>(val));
+            if (ctx.knownJdkType(val))
+                atomicView.invoke(key, new ReferenceSetEntryProcessor<>(val));
+            else {
+                CU.retryTopologySafe(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC,
REPEATABLE_READ)) {
+                            GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
+
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic reference
with given name: " + name);
+
+                            atomicView.put(key, new GridCacheAtomicReferenceValue<>(val));
+
+                            tx.commit();
+                        }
+
+                        return null;
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -139,14 +165,40 @@ public final class GridCacheAtomicReferenceImpl<T> implements
GridCacheAtomicRef
     }
 
     /** {@inheritDoc} */
-    @Override public boolean compareAndSet(T expVal, T newVal) {
+    @Override public boolean compareAndSet(final T expVal, final T newVal) {
         try {
-            EntryProcessorResult<Boolean> res =
-                atomicView.invoke(key, new ReferenceCompareAndSetEntryProcessor<>(expVal,
newVal));
+            if (ctx.knownJdkType(expVal) && ctx.knownJdkType(newVal)) {
+                EntryProcessorResult<Boolean> res =
+                    atomicView.invoke(key, new ReferenceCompareAndSetEntryProcessor<>(expVal,
newVal));
+
+                assert res != null && res.get() != null : res;
+
+                return res.get();
+            }
+            else {
+                return CU.retryTopologySafe(new Callable<Boolean>() {
+                    @Override public Boolean call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC,
REPEATABLE_READ)) {
+                            GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
+
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic reference
with given name: " + name);
 
-            assert res != null && res.get() != null : res;
+                            T curVal = ref.get();
 
-            return res.get();
+                            if (!F.eq(expVal, curVal))
+                                return false;
+                            else {
+                                atomicView.put(key, new GridCacheAtomicReferenceValue<>(newVal));
+
+                                tx.commit();
+
+                                return true;
+                            }
+                        }
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -163,16 +215,42 @@ public final class GridCacheAtomicReferenceImpl<T> implements
GridCacheAtomicRef
      * @param expVal Expected value.
      * @return Original value.
      */
-    public T compareAndSetAndGet(T newVal, T expVal) {
+    public T compareAndSetAndGet(final T newVal, final T expVal) {
         checkRemoved();
 
         try {
-            EntryProcessorResult<T> res =
-                atomicView.invoke(key, new ReferenceCompareAndSetAndGetEntryProcessor<T>(expVal,
newVal));
+            if (ctx.knownJdkType(expVal) && ctx.knownJdkType(newVal)) {
+                EntryProcessorResult<T> res =
+                    atomicView.invoke(key, new ReferenceCompareAndSetAndGetEntryProcessor<T>(expVal,
newVal));
+
+                assert res != null;
+
+                return res.get();
+            }
+            else {
+                return CU.retryTopologySafe(new Callable<T>() {
+                    @Override public T call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC,
REPEATABLE_READ)) {
+                            GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
 
-            assert res != null;
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic reference
with given name: " + name);
 
-            return res.get();
+                            T curVal = ref.get();
+
+                            if (!F.eq(expVal, curVal))
+                                return curVal;
+                            else {
+                                atomicView.put(key, new GridCacheAtomicReferenceValue<>(newVal));
+
+                                tx.commit();
+
+                                return expVal;
+                            }
+                        }
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -251,8 +329,6 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
                 throw removedError();
             }
         }
-
-
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
index 3f14942..14c474b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
@@ -23,6 +23,7 @@ import java.io.InvalidObjectException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
+import java.util.concurrent.Callable;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
@@ -32,12 +33,17 @@ import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
 import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.lang.IgniteBiTuple;
 
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
 /**
  * Cache atomic stamped implementation.
  */
@@ -124,11 +130,30 @@ public final class GridCacheAtomicStampedImpl<T, S> implements
GridCacheAtomicSt
     }
 
     /** {@inheritDoc} */
-    @Override public void set(T val, S stamp) {
+    @Override public void set(final T val, final S stamp) {
         checkRemoved();
 
         try {
-            atomicView.invoke(key, new StampedSetEntryProcessor<>(val, stamp));
+            if (ctx.knownJdkType(val) && ctx.knownJdkType(stamp))
+                atomicView.invoke(key, new StampedSetEntryProcessor<>(val, stamp));
+            else {
+                CU.retryTopologySafe(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC,
REPEATABLE_READ)) {
+                            GridCacheAtomicStampedValue<T, S> ref = atomicView.get(key);
+
+                            if (ref == null)
+                                throw new IgniteException("Failed to find atomic stamped
with given name: " + name);
+
+                            atomicView.put(key, new GridCacheAtomicStampedValue<>(val,
stamp));
+
+                            tx.commit();
+                        }
+
+                        return null;
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -139,16 +164,43 @@ public final class GridCacheAtomicStampedImpl<T, S> implements
GridCacheAtomicSt
     }
 
     /** {@inheritDoc} */
-    @Override public boolean compareAndSet(T expVal, T newVal, S expStamp, S newStamp) {
+    @Override public boolean compareAndSet(final T expVal, final T newVal, final S expStamp,
final S newStamp) {
         checkRemoved();
 
         try {
-            EntryProcessorResult<Boolean> res =
-                atomicView.invoke(key, new StampedCompareAndSetEntryProcessor<>(expVal,
expStamp, newVal, newStamp));
+            if (ctx.knownJdkType(expVal) &&
+                ctx.knownJdkType(newVal) &&
+                ctx.knownJdkType(expStamp) &&
+                ctx.knownJdkType(newStamp)) {
+                EntryProcessorResult<Boolean> res =
+                    atomicView.invoke(key, new StampedCompareAndSetEntryProcessor<>(expVal,
expStamp, newVal, newStamp));
 
-            assert res != null && res.get() != null : res;
+                assert res != null && res.get() != null : res;
+
+                return res.get();
+            }
+            else {
+                return CU.retryTopologySafe(new Callable<Boolean>() {
+                    @Override public Boolean call() throws Exception {
+                        try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC,
REPEATABLE_READ)) {
+                            GridCacheAtomicStampedValue<T, S> val = atomicView.get(key);
 
-            return res.get();
+                            if (val == null)
+                                throw new IgniteException("Failed to find atomic stamped
with given name: " + name);
+
+                            if (F.eq(expVal, val.value()) && F.eq(expStamp, val.stamp()))
{
+                                atomicView.put(key, new GridCacheAtomicStampedValue<>(newVal,
newStamp));
+
+                                tx.commit();
+
+                                return true;
+                            }
+
+                            return false;
+                        }
+                    }
+                });
+            }
         }
         catch (EntryProcessorException e) {
             throw new IgniteException(e.getMessage(), e);
@@ -295,7 +347,7 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException
{
-
+        // No-op.
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
index 86e99a9..b93e600 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
@@ -344,7 +344,7 @@ public final class GridCacheCountDownLatchImpl implements GridCacheCountDownLatc
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException
{
-
+        // No-op.
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index edc322e..04b32e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -972,7 +972,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx,
Ignit
 
     /** {@inheritDoc} */
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException
{
-
+        // No-op.
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index 3c4b3a7..b82da58 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -43,10 +43,10 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends
Ignite
      * @throws Exception If failed.
      */
     public void testPrepareAtomicReference() throws Exception {
-        /** Name of first atomic. */
+        /* Name of first atomic. */
         String atomicName1 = UUID.randomUUID().toString();
 
-        /** Name of second atomic. */
+        /* Name of second atomic. */
         String atomicName2 = UUID.randomUUID().toString();
 
         String initVal = "1";

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
new file mode 100644
index 0000000..9808107
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructuresNoClassOnServerTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.datastructures;
+
+import org.apache.ignite.internal.processors.cache.distributed.IgniteNoClassOnServerAbstractTest;
+
+/**
+ *
+ */
+public class IgniteDataStructuresNoClassOnServerTest extends IgniteNoClassOnServerAbstractTest
{
+    /** {@inheritDoc} */
+    @Override protected String clientClassName() {
+        return "org.apache.ignite.tests.p2p.datastructures.DataStructuresNoClassOnServerTestClient";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
index c6ce81e..625a95b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -17,116 +17,12 @@
 
 package org.apache.ignite.internal.processors.cache.distributed;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.GridJavaProcess;
-import org.apache.ignite.internal.util.typedef.CI1;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-
 /**
  *
  */
-public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
-    /** */
-    public static final String NODE_START_MSG = "Test external node started";
-
-    /** */
-    private static final String CLIENT_CLS_NAME =
-        "org.apache.ignite.tests.p2p.cache.CacheNoValueClassOnServerTestClient";
-
-    /**
-     * @return Configuration.
-     */
-    private IgniteConfiguration createConfiguration() {
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setPeerClassLoadingEnabled(false);
-
-        cfg.setLocalHost("127.0.0.1");
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinderCleanFrequency(1000);
-
-        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
-
-        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
-
-        disco.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(disco);
-
-        return cfg;
+public class CacheNoValueClassOnServerNodeTest extends IgniteNoClassOnServerAbstractTest
{
+    /** {@inheritDoc} */
+    @Override protected String clientClassName() {
+        return "org.apache.ignite.tests.p2p.cache.CacheNoValueClassOnServerTestClient";
     }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNoValueClassOnServerNode() throws Exception {
-        // Check class is really not available.
-        try {
-            Class.forName("org.apache.ignite.tests.p2p.cache.Person");
-
-            fail();
-        }
-        catch (ClassNotFoundException ignore) {
-            // Expected exception.
-        }
-
-        try (Ignite ignite = Ignition.start(createConfiguration())) {
-            CacheConfiguration cfg = new CacheConfiguration();
-
-            cfg.setCopyOnRead(true); // To store only value bytes.
-
-            ignite.createCache(cfg);
-
-            final CountDownLatch clientReadyLatch = new CountDownLatch(1);
-
-            Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
-
-            GridJavaProcess clientNode = null;
-
-            try {
-                String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
-
-                clientNode = GridJavaProcess.exec(
-                    CLIENT_CLS_NAME, null,
-                    log,
-                    new CI1<String>() {
-                        @Override public void apply(String s) {
-                            info("Client node: " + s);
-
-                            if (s.contains(NODE_START_MSG))
-                                clientReadyLatch.countDown();
-                        }
-                    },
-                    null,
-                    null,
-                    jvmArgs,
-                    cp
-                );
-
-                assertTrue(clientReadyLatch.await(60, SECONDS));
-
-                int exitCode = clientNode.getProcess().waitFor();
-
-                assertEquals("Unexpected exit code", 0, exitCode);
-            }
-            finally {
-                if (clientNode != null)
-                    clientNode.killProcess();
-            }
-        }
-    }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
new file mode 100644
index 0000000..4357ae7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.distributed;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.GridJavaProcess;
+import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ *
+ */
+public abstract class IgniteNoClassOnServerAbstractTest extends GridCommonAbstractTest {
+    /** */
+    private static final String NODE_START_MSG = "Test external node started";
+
+    /**
+     * @return Client class name.
+     */
+    protected abstract String clientClassName();
+
+    /**
+     * @return Configuration.
+     */
+    private IgniteConfiguration createConfiguration() {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinderCleanFrequency(1000);
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public final void testNoClassOnServerNode() throws Exception {
+        info("Run test with client: " + clientClassName());
+
+        // Check class is really not available.
+        try {
+            Class.forName("org.apache.ignite.tests.p2p.cache.Person");
+
+            fail();
+        }
+        catch (ClassNotFoundException ignore) {
+            // Expected exception.
+        }
+
+        try (Ignite ignite = Ignition.start(createConfiguration())) {
+            CacheConfiguration cfg = new CacheConfiguration();
+
+            cfg.setCopyOnRead(true); // To store only value bytes.
+
+            ignite.createCache(cfg);
+
+            final CountDownLatch clientReadyLatch = new CountDownLatch(1);
+
+            Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
+
+            GridJavaProcess clientNode = null;
+
+            try {
+                String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
+
+                clientNode = GridJavaProcess.exec(
+                    clientClassName(), null,
+                    log,
+                    new CI1<String>() {
+                        @Override public void apply(String s) {
+                            info("Client node: " + s);
+
+                            if (s.contains(NODE_START_MSG))
+                                clientReadyLatch.countDown();
+                        }
+                    },
+                    null,
+                    null,
+                    jvmArgs,
+                    cp
+                );
+
+                assertTrue(clientReadyLatch.await(60, SECONDS));
+
+                int exitCode = clientNode.getProcess().waitFor();
+
+                assertEquals("Unexpected exit code", 0, exitCode);
+            }
+            finally {
+                if (clientNode != null)
+                    clientNode.killProcess();
+            }
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml
index 4863fdd..ec14930 100644
--- a/modules/extdata/p2p/pom.xml
+++ b/modules/extdata/p2p/pom.xml
@@ -39,6 +39,12 @@
             <artifactId>ignite-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
new file mode 100644
index 0000000..9c9338b
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NoValueClassOnServerAbstractClient.java
@@ -0,0 +1,90 @@
+/*
+ * 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.tests.p2p;
+
+import java.util.Arrays;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+
+/**
+ *
+ */
+public abstract class NoValueClassOnServerAbstractClient implements AutoCloseable {
+    /** */
+    protected final Ignite ignite;
+
+    /** */
+    private final IgniteLogger log;
+
+    /**
+     * @param args Command line arguments.
+     * @throws Exception If failed.
+     */
+    public NoValueClassOnServerAbstractClient(String[] args) throws Exception {
+        System.out.println("Starting test client node.");
+
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setClientMode(true);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        ignite = Ignition.start(cfg);
+
+        System.out.println("Test external node started");
+
+        log = ignite.log().getLogger(getClass());
+
+        log.info("Started node [id=" + ignite.cluster().localNode().id() +
+            ", marsh=" + ignite.configuration().getMarshaller().getClass().getSimpleName()
+ ']');
+    }
+
+    /**
+     * @param msg Message.
+     */
+    protected final void info(String msg) {
+        log.info(msg);
+    }
+
+
+    /** {@inheritDoc} */
+    @Override public void close() throws Exception {
+        ignite.close();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    protected abstract void runTest() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
index bbf8abf..c1f3ff6 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/cache/CacheNoValueClassOnServerTestClient.java
@@ -17,70 +17,59 @@
 
 package org.apache.ignite.tests.p2p.cache;
 
-import java.util.Arrays;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.tests.p2p.NoValueClassOnServerAbstractClient;
+
+import static junit.framework.TestCase.assertEquals;
 
 /**
  *
  */
-public class CacheNoValueClassOnServerTestClient {
+public class CacheNoValueClassOnServerTestClient extends NoValueClassOnServerAbstractClient
{
     /**
      * @param args Arguments.
      * @throws Exception If failed.
      */
-    public static void main(String[] args) throws Exception {
-        System.out.println("Starting test client node.");
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setPeerClassLoadingEnabled(false);
-
-        cfg.setClientMode(true);
-
-        cfg.setLocalHost("127.0.0.1");
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
-
-        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
-
-        disco.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(disco);
+    private CacheNoValueClassOnServerTestClient(String[] args) throws Exception {
+        super(args);
+    }
 
-        try (Ignite ignite = Ignition.start(cfg)) {
-            System.out.println("Test external node started");
+    /** {@inheritDoc} */
+    @Override protected void runTest() throws Exception {
+        IgniteCache<Integer, Person> cache = ignite.cache(null);
 
-            int nodes = ignite.cluster().nodes().size();
+        for (int i = 0; i < 100; i++)
+            cache.put(i, new Person("name-" + i));
 
-            if (nodes != 2)
-                throw new Exception("Unexpected nodes number: " + nodes);
+        for (int i = 0; i < 100; i++) {
+            Person p = cache.get(i);
 
-            IgniteCache<Integer, Person> cache = ignite.cache(null);
+            if (p == null)
+                throw new Exception("Null result key: " + i);
 
-            for (int i = 0; i < 100; i++)
-                cache.put(i, new Person("name-" + i));
+            String expName = "name-" + i;
 
-            for (int i = 0; i < 100; i++) {
-                Person p = cache.get(i);
+            assertEquals(expName, p.getName());
 
-                if (p == null)
-                    throw new Exception("Null result key: " + i);
+            if (i % 10 == 0)
+                System.out.println("Get expected value: " + p.name());
+        }
+    }
 
-                String expName = "name-" + i;
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        try (CacheNoValueClassOnServerTestClient client = new CacheNoValueClassOnServerTestClient(args))
{
+            client.runTest();
+        }
+        catch (Throwable e) {
+            System.out.println("Unexpected error: " + e);
 
-                if (!expName.equals(p.name()))
-                    throw new Exception("Unexpected data: " + p.name());
+            e.printStackTrace(System.out);
 
-                if (i % 10 == 0)
-                    System.out.println("Get expected value: " + p.name());
-            }
+            System.exit(1);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c20d1a27/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
new file mode 100644
index 0000000..7cf2cc7
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/datastructures/DataStructuresNoClassOnServerTestClient.java
@@ -0,0 +1,181 @@
+/*
+ * 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.tests.p2p.datastructures;
+
+import org.apache.ignite.IgniteAtomicReference;
+import org.apache.ignite.IgniteAtomicStamped;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.tests.p2p.NoValueClassOnServerAbstractClient;
+import org.apache.ignite.tests.p2p.cache.Person;
+import org.apache.ignite.tests.p2p.cache.PersonKey;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public class DataStructuresNoClassOnServerTestClient extends NoValueClassOnServerAbstractClient
{
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    private DataStructuresNoClassOnServerTestClient(String[] args) throws Exception {
+        super(args);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void runTest() throws Exception {
+        testAtomicReference();
+
+        testAtomicStamped();
+    }
+
+    /**
+     *
+     */
+    private void testAtomicReference() {
+        info("Test atomic reference");
+
+        IgniteAtomicReference<Person> ref = ignite.atomicReference("ref1", null, true);
+
+        assertNull(ref.get());
+
+        ref.set(person("p1"));
+
+        assertEquals(person("p1"), ref.get());
+
+        assertTrue(ref.compareAndSet(person("p1"), person("p2")));
+
+        assertEquals(person("p2"), ref.get());
+
+        assertFalse(ref.compareAndSet(person("p1"), person("p3")));
+
+        assertEquals(person("p2"), ref.get());
+
+        assertTrue(ref.compareAndSet(person("p2"), null));
+
+        assertNull(ref.get());
+
+        assertTrue(ref.compareAndSet(null, person("p2")));
+
+        assertEquals(person("p2"), ref.get());
+
+        ref.close();
+
+        ref = ignite.atomicReference("ref2", person("p1"), true);
+
+        assertEquals(person("p1"), ref.get());
+    }
+
+    /**
+     *
+     */
+    private void testAtomicStamped() {
+        info("Test atomic stamped");
+
+        IgniteAtomicStamped<Person, PersonKey> stamped = ignite.atomicStamped("s1",
null, null, true);
+
+        stamped.set(person("p1"), key(1));
+
+        checkStamped(stamped, "p1", 1);
+
+        assertTrue(stamped.compareAndSet(person("p1"), person("p2"), key(1), key(2)));
+
+        checkStamped(stamped, "p2", 2);
+
+        assertFalse(stamped.compareAndSet(person("p1"), person("p3"), key(1), key(3)));
+
+        checkStamped(stamped, "p2", 2);
+
+        assertFalse(stamped.compareAndSet(person("p2"), person("p3"), key(1), key(3)));
+
+        checkStamped(stamped, "p2", 2);
+
+        assertTrue(stamped.compareAndSet(person("p2"), null, key(2), key(3)));
+
+        checkStamped(stamped, null, 3);
+
+        assertTrue(stamped.compareAndSet(null, person("p2"), key(3), key(4)));
+
+        checkStamped(stamped, "p2", 4);
+
+        stamped.close();
+
+        stamped = ignite.atomicStamped("s2", person("p5"), key(5), true);
+
+        checkStamped(stamped, "p5", 5);
+    }
+
+    /**
+     * @param stamped Stamped.
+     * @param personName Expected person name.
+     * @param id Expected stamp.
+     */
+    private void checkStamped(IgniteAtomicStamped<Person, PersonKey> stamped, String
personName, int id) {
+        assertEquals(person(personName), stamped.value());
+        assertEquals(key(id), stamped.stamp());
+
+        IgniteBiTuple<Person, PersonKey> t = stamped.get();
+
+        assertEquals(person(personName), t.get1());
+        assertEquals(key(id), t.get2());
+    }
+
+    /**
+     * @param name Person name.
+     * @return Person instance.
+     */
+    private Person person(String name) {
+        if (name == null)
+            return null;
+
+        Person p = new Person();
+
+        p.setName(name);
+
+        return p;
+    }
+
+    /**
+     * @param id Key ID.
+     * @return Key.
+     */
+    private PersonKey key(int id) {
+        return new PersonKey(id);
+    }
+
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        try (DataStructuresNoClassOnServerTestClient client = new DataStructuresNoClassOnServerTestClient(args))
{
+            client.runTest();
+        }
+        catch (Throwable e) {
+            System.out.println("Unexpected error: " + e);
+
+            e.printStackTrace(System.out);
+
+            System.exit(1);
+        }
+    }
+}


Mime
View raw message