ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [13/41] ignite git commit: IGNITE-5215 - Allow user to configure memory policy with maxSize smaller than default initialSize. Closes #1938
Date Wed, 24 May 2017 17:26:57 GMT
IGNITE-5215 - Allow user to configure memory policy with maxSize smaller than default initialSize.
Closes #1938


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

Branch: refs/heads/ignite-5267
Commit: 661bb532aa53de22610acc6ab1ef1f495cb6e3fe
Parents: 5582ebf
Author: Ivan Rakov <ivan.glukos@gmail.com>
Authored: Tue May 23 14:34:25 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Tue May 23 14:35:33 2017 +0300

----------------------------------------------------------------------
 .../configuration/MemoryConfiguration.java      |  3 ++-
 .../MemoryPolicyConfiguration.java              |  4 +--
 .../IgniteCacheDatabaseSharedManager.java       | 26 +++++++++++++++-----
 3 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/661bb532/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index 585335b..e6324dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@ -63,7 +63,8 @@ public class MemoryConfiguration implements Serializable {
     private static final long serialVersionUID = 0L;
 
     /** Default memory policy start size (256 MB). */
-    public static final long DFLT_MEMORY_POLICY_INITIAL_SIZE = 256 * 1024 * 1024;
+    @SuppressWarnings("UnnecessaryBoxing")
+    public static final Long DFLT_MEMORY_POLICY_INITIAL_SIZE = new Long(256L * 1024 * 1024);
 
     /** Fraction of available memory to allocate for default MemoryPolicy. */
     private static final double DFLT_MEMORY_POLICY_FRACTION = 0.8;

http://git-wip-us.apache.org/repos/asf/ignite/blob/661bb532/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
index 8e4d30e..2716d8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@ -70,7 +70,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
     private String name = DFLT_MEM_PLC_DEFAULT_NAME;
 
     /** Memory policy start size. */
-    private long initialSize = MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE;
+    private Long initialSize = MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE;
 
     /** Memory policy maximum size. */
     private long maxSize = MemoryConfiguration.DFLT_MEMORY_POLICY_MAX_SIZE;
@@ -145,7 +145,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
      *
      * @return Memory policy start size.
      */
-    public long getInitialSize() {
+    public Long getInitialSize() {
         return initialSize;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/661bb532/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 fbb3b0f..17c16b8 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
@@ -55,11 +55,13 @@ import org.apache.ignite.internal.processors.cache.database.freelist.FreeListImp
 import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
 import org.apache.ignite.mxbean.MemoryMetricsMXBean;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE;
 import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
 
 /**
@@ -419,18 +421,30 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * @param plcCfg MemoryPolicyConfiguration to validate.
      * @throws IgniteCheckedException If config is invalid.
      */
-    private static void checkPolicySize(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException
{
+    private void checkPolicySize(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException
{
         if (plcCfg.getInitialSize() < MIN_PAGE_MEMORY_SIZE)
             throw new IgniteCheckedException("MemoryPolicy must have size more than 10MB
(use " +
                 "MemoryPolicyConfiguration.initialSize property to set correct size in bytes)
" +
                 "[name=" + plcCfg.getName() + ", size=" + U.readableSize(plcCfg.getInitialSize(),
true) + "]"
             );
 
-        if (plcCfg.getMaxSize() < plcCfg.getInitialSize())
-            throw new IgniteCheckedException("MemoryPolicy maxSize must not be smaller than
" +
-                "initialSize [name=" + plcCfg.getName() +
-                ", initSize=" + U.readableSize(plcCfg.getInitialSize(), true) +
-                ", maxSize=" + U.readableSize(plcCfg.getMaxSize(), true) + ']');
+        if (plcCfg.getMaxSize() < plcCfg.getInitialSize()) {
+            // We will know for sure if initialSize has been changed if we compare Longs
by "==".
+            if (plcCfg.getInitialSize() == DFLT_MEMORY_POLICY_INITIAL_SIZE) {
+                plcCfg.setInitialSize(plcCfg.getMaxSize());
+
+                LT.warn(log, "MemoryPolicy maxSize=" + U.readableSize(plcCfg.getMaxSize(),
true) +
+                    " is smaller than defaultInitialSize=" +
+                    U.readableSize(MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE, true)
+
+                    ", setting initialSize to " + U.readableSize(plcCfg.getMaxSize(), true));
+            }
+            else {
+                throw new IgniteCheckedException("MemoryPolicy maxSize must not be smaller
than " +
+                    "initialSize [name=" + plcCfg.getName() +
+                    ", initSize=" + U.readableSize(plcCfg.getInitialSize(), true) +
+                    ", maxSize=" + U.readableSize(plcCfg.getMaxSize(), true) + ']');
+            }
+        }
 
         if (U.jvm32Bit() && plcCfg.getInitialSize() > MAX_PAGE_MEMORY_INIT_SIZE_32_BIT)
             throw new IgniteCheckedException("MemoryPolicy initialSize exceeds 2GB on 32-bit
JVM (use " +


Mime
View raw message