ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [5/9] ignite git commit: Offheap MemoryPolicies can be configured for client nodes, exception is thrown when no MemoryPolicy is configured
Date Mon, 10 Apr 2017 11:18:04 GMT
Offheap MemoryPolicies can be configured for client nodes, exception is thrown when no MemoryPolicy
is configured


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

Branch: refs/heads/ignite-1794
Commit: 973f3352554f9d5784fb21a4ec6e537561c2d40e
Parents: 24d68a7
Author: Sergey Chugunov <sergey.chugunov@gmail.com>
Authored: Wed Apr 5 19:58:08 2017 +0300
Committer: Sergey Chugunov <sergey.chugunov@gmail.com>
Committed: Mon Apr 10 11:45:55 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  3 ++
 .../org/apache/ignite/internal/IgnitionEx.java  |  2 +-
 .../processors/cache/GridCacheProcessor.java    | 25 ++++++++++
 .../cache/IgniteCacheOffheapManagerImpl.java    |  8 +---
 .../IgniteCacheDatabaseSharedManager.java       |  6 ++-
 .../cache/CacheClientStoreSelfTest.java         |  4 ++
 .../cache/CacheStopAndDestroySelfTest.java      | 48 ++++++++++++++++----
 7 files changed, 78 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 9c661df..286ced0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2430,6 +2430,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     private void ackMemoryConfiguration() {
         MemoryConfiguration memCfg = cfg.getMemoryConfiguration();
 
+        if (memCfg == null)
+            return;
+
         U.log(log, "System cache MemoryPolicy size is configured to " +
                 (memCfg.getSystemCacheMemorySize() / (1024 * 1024)) +
         "MB size. " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 15ca88b..c701411 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -2102,7 +2102,7 @@ public class IgnitionEx {
 
             initializeDefaultCacheConfiguration(myCfg);
 
-            if (myCfg.getMemoryConfiguration() == null) {
+            if (!myCfg.isClientMode() && myCfg.getMemoryConfiguration() == null)
{
                 MemoryConfiguration dbCfg = new MemoryConfiguration();
 
                 dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);

http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index ab5db28..2564787 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -390,6 +390,27 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * @param c Ignite Configuration.
+     * @param cc Cache Configuration.
+     * @return {@code true} if cache is starting on client node and this node is affinity
node for the cache.
+     */
+    private boolean storesLocallyOnClient(IgniteConfiguration c,
+                                          CacheConfiguration cc) {
+        if (c.isClientMode()
+                && c.getMemoryConfiguration() == null) {
+            if (cc.getCacheMode() == LOCAL)
+                return true;
+
+            if (ctx.discovery().cacheAffinityNode(ctx.discovery().localNode(), cc.getName()))
+                return true;
+
+            return false;
+        }
+        else
+            return false;
+    }
+
+    /**
      * @param c Ignite configuration.
      * @param cc Configuration to validate.
      * @param cacheType Cache type.
@@ -410,6 +431,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             }
         }
 
+        if (storesLocallyOnClient(c, cc))
+            throw new IgniteCheckedException("MemoryPolicy for client caches must be explicitly
configured " +
+                    "on client node startup. Use MemoryConfiguration to configure MemoryPolicy.");
+
         if (cc.getCacheMode() == LOCAL && !cc.getAffinity().getClass().equals(LocalAffinityFunction.class))
             U.warn(log, "AffinityFunction configuration parameter will be ignored for local
cache [cacheName=" +
                 U.maskName(cc.getName()) + ']');

http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index a1aea2f..9b10d71 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -119,15 +119,9 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
     @Override protected void start0() throws IgniteCheckedException {
         super.start0();
 
-        updateValSizeThreshold = cctx.kernalContext().config().getMemoryConfiguration().getPageSize()
/ 2;
+        updateValSizeThreshold = cctx.shared().database().pageSize() / 2;
 
         if (cctx.affinityNode()) {
-            if (cctx.kernalContext().clientNode()) {
-                assert cctx.isLocal() : cctx.name();
-
-                cctx.shared().database().init();
-            }
-
             cctx.shared().database().checkpointReadLock();
 
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/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 300e935..d61130b 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
@@ -80,8 +80,10 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
 
     /** {@inheritDoc} */
     @Override protected void start0() throws IgniteCheckedException {
-        if (!cctx.kernalContext().clientNode())
-            init();
+        if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getMemoryConfiguration()
== null)
+            return;
+
+        init();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheClientStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheClientStoreSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheClientStoreSelfTest.java
index b2588a9..35442bb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheClientStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheClientStoreSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreAdapter;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteBiInClosure;
@@ -73,6 +74,9 @@ public class CacheClientStoreSelfTest extends GridCommonAbstractTest {
 
         cfg.setClientMode(client);
 
+        if (client)
+            cfg.setMemoryConfiguration(new MemoryConfiguration());
+
         CacheConfiguration cc = new CacheConfiguration();
 
         cc.setName(CACHE_NAME);

http://git-wip-us.apache.org/repos/asf/ignite/blob/973f3352/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
index ef6c5fd..1a7e76a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -68,18 +69,16 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
     /** local cache name. */
     protected static String CACHE_NAME_LOC = "cache_local";
 
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        super.beforeTest();
-
-        startGridsMultiThreaded(gridCount());
-    }
+    /** Memory configuration to be used on client nodes with local caches. */
+    private static MemoryConfiguration memCfg;
 
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         super.afterTest();
 
         stopAllGrids();
+
+        memCfg = null;
     }
 
     /**
@@ -93,9 +92,12 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
         IgniteConfiguration iCfg = super.getConfiguration(igniteInstanceName);
 
-        if (getTestIgniteInstanceName(2).equals(igniteInstanceName))
+        if (getTestIgniteInstanceName(2).equals(igniteInstanceName)) {
             iCfg.setClientMode(true);
 
+            iCfg.setMemoryConfiguration(memCfg);
+        }
+
         ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
         ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
 
@@ -192,6 +194,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testDhtDoubleDestroy() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         dhtDestroy();
 
         dhtDestroy();
@@ -230,6 +234,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testClientDoubleDestroy() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         clientDestroy();
 
         clientDestroy();
@@ -268,6 +274,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testNearDoubleDestroy() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         nearDestroy();
 
         nearDestroy();
@@ -306,6 +314,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testLocalDoubleDestroy() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         localDestroy();
 
         localDestroy();
@@ -339,6 +349,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testDhtClose() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         IgniteCache<Integer, Integer> dhtCache0 = grid(0).getOrCreateCache(getDhtConfig());
 
         final Integer key = primaryKey(dhtCache0);
@@ -418,6 +430,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testDhtCloseWithTry() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         String curVal = null;
 
         for (int i = 0; i < 3; i++) {
@@ -453,6 +467,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testClientClose() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         IgniteCache<String, String> cache0 = grid(0).getOrCreateCache(getClientConfig());
 
         assert cache0.get(KEY_VAL) == null;
@@ -502,6 +518,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testClientCloseWithTry() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         String curVal = null;
 
         for (int i = 0; i < 3; i++) {
@@ -541,6 +559,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
     public void testNearClose() throws Exception {
         fail("https://issues.apache.org/jira/browse/IGNITE-2189");
 
+        startGridsMultiThreaded(gridCount());
+
         IgniteCache<String, String> cache0 = grid(0).getOrCreateCache(getNearConfig());
 
         // GridDhtTxPrepareRequest requests to Client node will be counted.
@@ -615,6 +635,8 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testNearCloseWithTry() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         String curVal = null;
 
         grid(0).getOrCreateCache(getNearConfig());
@@ -651,6 +673,10 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testLocalClose() throws Exception {
+        memCfg = new MemoryConfiguration();
+
+        startGridsMultiThreaded(gridCount());
+
         grid(0).getOrCreateCache(getLocalConfig());
 
         assert grid(0).cache(CACHE_NAME_LOC).get(KEY_VAL) == null;
@@ -695,6 +721,10 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testLocalCloseWithTry() throws Exception {
+        memCfg = new MemoryConfiguration();
+
+        startGridsMultiThreaded(gridCount());
+
         String curVal = null;
 
         for (int i = 0; i < 3; i++) {
@@ -722,7 +752,9 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
     /**
      * Tests start -> destroy -> start -> close using CacheManager.
      */
-    public void testTckStyleCreateDestroyClose() {
+    public void testTckStyleCreateDestroyClose() throws Exception {
+        startGridsMultiThreaded(gridCount());
+
         CacheManager mgr = Caching.getCachingProvider().getCacheManager();
 
         String cacheName = "cache";


Mime
View raw message