ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject ignite git commit: ignite-1272: adding test to check entry processor and deployment mode
Date Thu, 22 Oct 2015 15:32:17 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1272 3ee912156 -> 44ea14840


ignite-1272: adding test to check entry processor and deployment mode


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

Branch: refs/heads/ignite-1272
Commit: 44ea148407017fc05bd1a7b292a47db3eb6afecf
Parents: 3ee9121
Author: Denis Magda <dmagda@gridgain.com>
Authored: Thu Oct 22 18:32:03 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Thu Oct 22 18:32:03 2015 +0300

----------------------------------------------------------------------
 ...idCacheEntryProcessorDeploymentSelfTest.java | 83 +++++++++++++++++++-
 .../testsuites/IgniteCacheTestSuite3.java       |  2 +
 .../CacheDeploymentPortableEntryProcessor.java  | 18 +++++
 3 files changed, 100 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/44ea1484/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
index f171c0b..269b216 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
@@ -17,6 +17,9 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import java.util.HashSet;
+import java.util.Map;
+import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -41,10 +44,10 @@ public class GridCacheEntryProcessorDeploymentSelfTest extends GridCommonAbstrac
     private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
     /** Entry processor */
-    private static final String TEST_ENT_PROCESSOR = "org.apache.ignite.tests.p2p.CacheDeploymentEntryProcessor";
+    protected static String TEST_ENT_PROCESSOR = "org.apache.ignite.tests.p2p.CacheDeploymentEntryProcessor";
 
     /** Test value. */
-    private static final String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue";
+    protected static String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue";
 
     /** */
     private DeploymentMode depMode;
@@ -97,11 +100,45 @@ public class GridCacheEntryProcessorDeploymentSelfTest extends GridCommonAbstrac
     }
 
     /**
-     * @throws Exception
+     * @throws Exception In case of error.
      */
     public void testInvokeDeployment() throws Exception {
         depMode = DeploymentMode.CONTINUOUS;
 
+        doTestInvoke();
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testInvokeDeployment2() throws Exception {
+        depMode = DeploymentMode.SHARED;
+
+        doTestInvoke();
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testInvokeAllDeployment() throws Exception {
+        depMode = DeploymentMode.CONTINUOUS;
+
+        doTestInvokeAll();
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testInvokeAllDeployment2() throws Exception {
+        depMode = DeploymentMode.SHARED;
+
+        doTestInvokeAll();
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    private void doTestInvoke() throws Exception {
         cliendMode = false;
         startGrid(0);
 
@@ -120,5 +157,45 @@ public class GridCacheEntryProcessorDeploymentSelfTest extends GridCommonAbstrac
         cache.put("key", valCls.newInstance());
 
         Boolean res = (Boolean)cache.invoke("key", (CacheEntryProcessor)procCls.newInstance());
+
+        assertTrue(res);
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    private void doTestInvokeAll() throws Exception {
+        cliendMode = false;
+        startGrid(0);
+
+        cliendMode = true;
+        startGrid(1);
+
+        ClassLoader ldr = getExternalClassLoader();
+
+        Class procCls = ldr.loadClass(TEST_ENT_PROCESSOR);
+        Class valCls = ldr.loadClass(TEST_VALUE);
+
+        assertTrue(grid(1).configuration().isClientMode());
+
+        IgniteCache cache = grid(1).cache(null);
+
+        HashSet keys = new HashSet();
+
+        for (int i = 0; i < 3; i++) {
+            String key = "key" + i;
+
+            cache.put(key, valCls.newInstance());
+
+            keys.add(key);
+        }
+
+        Map<String, EntryProcessorResult> res = (Map<String, EntryProcessorResult>)cache.invokeAll(keys,
+            (CacheEntryProcessor)procCls.newInstance());
+
+        assertEquals(3, res.size());
+
+        for (EntryProcessorResult result : res.values())
+            assertTrue((Boolean)result.get());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/44ea1484/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index 08c0c75..5ef6fa7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
 import org.apache.ignite.internal.processors.cache.GridCacheConditionalDeploymentSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheDeploymentOffHeapSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheDeploymentSelfTest;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryProcessorDeploymentSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryVersionSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheOrderedPreloadingSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheReferenceCleanupSelfTest;
@@ -118,6 +119,7 @@ public class IgniteCacheTestSuite3 extends TestSuite {
         suite.addTestSuite(GridCacheDeploymentSelfTest.class);
         suite.addTestSuite(GridCacheDeploymentOffHeapSelfTest.class);
         suite.addTestSuite(GridCacheConditionalDeploymentSelfTest.class);
+        suite.addTestSuite(GridCacheEntryProcessorDeploymentSelfTest.class);
 
         suite.addTestSuite(GridCachePutArrayValueSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedUnswapAdvancedSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/44ea1484/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentPortableEntryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentPortableEntryProcessor.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentPortableEntryProcessor.java
new file mode 100644
index 0000000..c8e08b9
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentPortableEntryProcessor.java
@@ -0,0 +1,18 @@
+package org.apache.ignite.tests.p2p;
+
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+
+/**
+ * Entry processor used by {@code GridCacheEntryProcessorDeploymentSelfTest}.
+ */
+public class CacheDeploymentPortableEntryProcessor implements CacheEntryProcessor<String,
String, Boolean> {
+    /** {@inheritDoc} */
+    @Override public Boolean process(MutableEntry<String, String> entry, Object...
arguments)
+        throws EntryProcessorException {
+        String val = entry.getKey();
+
+        return true;
+    }
+}


Mime
View raw message