ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [56/70] [abbrv] ignite git commit: Rename OutOfMemoryException
Date Thu, 20 Apr 2017 07:49:29 GMT
Rename OutOfMemoryException


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

Branch: refs/heads/ignite-2893
Commit: 67d3358d030a2e40262a7a344ef95fee607b274e
Parents: a51477c
Author: Sergey Chugunov <sergey.chugunov@gmail.com>
Authored: Wed Apr 19 16:45:53 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Wed Apr 19 16:45:53 2017 +0300

----------------------------------------------------------------------
 .../benchmarks/jmh/tree/BPlusTreeBenchmark.java |  1 +
 .../MemoryPolicyConfiguration.java              |  4 +-
 .../mem/IgniteOutOfMemoryException.java         | 51 ++++++++++++++++++++
 .../internal/mem/OutOfMemoryException.java      | 51 --------------------
 .../pagemem/impl/PageMemoryNoStoreImpl.java     | 16 +++++-
 .../IgniteCacheDatabaseSharedManager.java       | 12 +++--
 .../pagemem/impl/PageMemoryNoLoadSelfTest.java  |  2 +-
 .../CacheMemoryPolicyConfigurationTest.java     |  6 +--
 .../processors/database/BPlusTreeSelfTest.java  |  7 ++-
 .../database/FreeListImplSelfTest.java          |  8 ++-
 .../database/MetadataStorageSelfTest.java       |  2 +-
 .../h2/database/InlineIndexHelperTest.java      |  3 ++
 12 files changed, 98 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/tree/BPlusTreeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/tree/BPlusTreeBenchmark.java
b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/tree/BPlusTreeBenchmark.java
index 5d02235..5833e1f 100644
--- a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/tree/BPlusTreeBenchmark.java
+++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/tree/BPlusTreeBenchmark.java
@@ -213,6 +213,7 @@ public class BPlusTreeBenchmark extends JmhAbstractBenchmark {
             new UnsafeMemoryProvider(sizes),
             null,
             PAGE_SIZE,
+            null,
             new MemoryMetricsImpl(null),
             false);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/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 2cd6d02..810ecaa 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
@@ -17,7 +17,7 @@
 package org.apache.ignite.configuration;
 
 import java.io.Serializable;
-import org.apache.ignite.internal.mem.OutOfMemoryException;
+import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
 
 /**
  * This class allows defining custom memory policies' configurations with various parameters
for Apache Ignite
@@ -86,7 +86,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
      * it will take empty page from the pool instead of allocating a new one.
      * Increase this parameter if cache can contain very big entries (total size of pages
in the pool should be enough
      * to contain largest cache entry).
-     * Increase this parameter if {@link OutOfMemoryException} occurred with enabled page
eviction.
+     * Increase this parameter if {@link IgniteOutOfMemoryException} occurred with enabled
page eviction.
      */
     private int emptyPagesPoolSize = 100;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/main/java/org/apache/ignite/internal/mem/IgniteOutOfMemoryException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/mem/IgniteOutOfMemoryException.java
b/modules/core/src/main/java/org/apache/ignite/internal/mem/IgniteOutOfMemoryException.java
new file mode 100644
index 0000000..22ef795
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/mem/IgniteOutOfMemoryException.java
@@ -0,0 +1,51 @@
+/*
+ * 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.mem;
+
+import java.io.IOException;
+import org.apache.ignite.IgniteException;
+
+/**
+ *
+ */
+public class IgniteOutOfMemoryException extends IgniteException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     *
+     */
+    public IgniteOutOfMemoryException() {
+        // No-op.
+    }
+
+    /**
+     * @param msg Error message.
+     */
+    public IgniteOutOfMemoryException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * @param msg Error message.
+     * @param e Cause exception.
+     */
+    public IgniteOutOfMemoryException(String msg, IOException e) {
+        super(msg, e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/main/java/org/apache/ignite/internal/mem/OutOfMemoryException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/mem/OutOfMemoryException.java
b/modules/core/src/main/java/org/apache/ignite/internal/mem/OutOfMemoryException.java
deleted file mode 100644
index 8219807..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/mem/OutOfMemoryException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.mem;
-
-import java.io.IOException;
-import org.apache.ignite.IgniteException;
-
-/**
- *
- */
-public class OutOfMemoryException extends IgniteException {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     *
-     */
-    public OutOfMemoryException() {
-        // No-op.
-    }
-
-    /**
-     * @param msg Error message.
-     */
-    public OutOfMemoryException(String msg) {
-        super(msg);
-    }
-
-    /**
-     * @param msg Error message.
-     * @param e Cause exception.
-     */
-    public OutOfMemoryException(String msg, IOException e) {
-        super(msg, e);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
index 7134cff..872e496 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
@@ -24,10 +24,11 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.mem.DirectMemory;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
 import org.apache.ignite.internal.mem.DirectMemoryRegion;
-import org.apache.ignite.internal.mem.OutOfMemoryException;
+import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
 import org.apache.ignite.internal.pagemem.PageIdUtils;
 import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
@@ -36,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.OffheapReadWriteLock;
 import org.apache.ignite.internal.util.offheap.GridOffHeapOutOfMemoryException;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lifecycle.LifecycleAware;
 
 import static org.apache.ignite.internal.util.GridUnsafe.wrapPointer;
@@ -105,6 +107,9 @@ public class PageMemoryNoStoreImpl implements PageMemory {
     /** Direct memory allocator. */
     private final DirectMemoryProvider directMemoryProvider;
 
+    /** Name of MemoryPolicy this PageMemory is associated with. */
+    private final MemoryPolicyConfiguration memoryPolicyCfg;
+
     /** Object to collect memory usage metrics. */
     private final MemoryMetricsImpl memMetrics;
 
@@ -137,6 +142,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
      * @param directMemoryProvider Memory allocator to use.
      * @param sharedCtx Cache shared context.
      * @param pageSize Page size.
+     * @param memPlcCfg Memory Policy configuration.
      * @param memMetrics Memory Metrics.
      * @param trackAcquiredPages If {@code true} tracks number of allocated pages (for tests
purpose only).
      */
@@ -145,6 +151,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
         DirectMemoryProvider directMemoryProvider,
         GridCacheSharedContext<?, ?> sharedCtx,
         int pageSize,
+        MemoryPolicyConfiguration memPlcCfg,
         MemoryMetricsImpl memMetrics,
         boolean trackAcquiredPages
     ) {
@@ -155,6 +162,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
         this.directMemoryProvider = directMemoryProvider;
         this.trackAcquiredPages = trackAcquiredPages;
         this.memMetrics = memMetrics;
+        memoryPolicyCfg = memPlcCfg;
 
         sysPageSize = pageSize + PAGE_OVERHEAD;
 
@@ -252,7 +260,11 @@ public class PageMemoryNoStoreImpl implements PageMemory {
         }
 
         if (relPtr == INVALID_REL_PTR)
-            throw new OutOfMemoryException();
+            throw new IgniteOutOfMemoryException("Not enough memory allocated " +
+                "(consider increasing memory policy size or enabling evictions) " +
+                "[policyName=" + memoryPolicyCfg.getName() +
+                ", size=" + U.readableSize(memoryPolicyCfg.getSize(), true) + "]"
+            );
 
         assert (relPtr & ~PageIdUtils.PAGE_IDX_MASK) == 0;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/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 a34aed2..e6fe7cd 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
@@ -608,7 +608,7 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
                 true,
                 sizes);
 
-        PageMemory pageMem = createPageMemory(memProvider, dbCfg.getPageSize(), memMetrics);
+        PageMemory pageMem = createPageMemory(memProvider, dbCfg.getPageSize(), plc, memMetrics);
 
         return new MemoryPolicy(pageMem, plc, memMetrics, createPageEvictionTracker(plc,
pageMem));
     }
@@ -676,11 +676,17 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      *
      * @param memProvider Memory provider.
      * @param pageSize Page size.
+     * @param memPlcCfg Memory policy configuration.
      * @param memMetrics MemoryMetrics to collect memory usage metrics.
      * @return PageMemory instance.
      */
-    protected PageMemory createPageMemory(DirectMemoryProvider memProvider, int pageSize,
MemoryMetricsImpl memMetrics) {
-        return new PageMemoryNoStoreImpl(log, memProvider, cctx, pageSize, memMetrics, false);
+    protected PageMemory createPageMemory(
+        DirectMemoryProvider memProvider,
+        int pageSize,
+        MemoryPolicyConfiguration memPlcCfg,
+        MemoryMetricsImpl memMetrics
+    ) {
+        return new PageMemoryNoStoreImpl(log, memProvider, cctx, pageSize, memPlcCfg, memMetrics,
false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java
index c1ce8b7..0fe90cd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java
@@ -287,7 +287,7 @@ public class PageMemoryNoLoadSelfTest extends GridCommonAbstractTest {
         DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir, true,
             sizes);
 
-        return new PageMemoryNoStoreImpl(log(), provider, null, PAGE_SIZE, new MemoryMetricsImpl(null),
true);
+        return new PageMemoryNoStoreImpl(log(), provider, null, PAGE_SIZE, null, new MemoryMetricsImpl(null),
true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
index 630d4be..d88723c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
@@ -23,7 +23,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.mem.OutOfMemoryException;
+import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -77,7 +77,7 @@ public class CacheMemoryPolicyConfigurationTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * Verifies that {@link OutOfMemoryException} is thrown when cache is configured with
too small MemoryPolicy.
+     * Verifies that {@link IgniteOutOfMemoryException} is thrown when cache is configured
with too small MemoryPolicy.
      */
     public void testTooSmallMemoryPolicy() throws Exception {
         memCfg = new MemoryConfiguration();
@@ -109,7 +109,7 @@ public class CacheMemoryPolicyConfigurationTest extends GridCommonAbstractTest
{
             Throwable cause = e;
 
             do {
-                if (cause instanceof OutOfMemoryException) {
+                if (cause instanceof IgniteOutOfMemoryException) {
                     oomeThrown = true;
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
index dd89406..32c6675 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
@@ -1704,7 +1704,12 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
         for (int i = 0; i < sizes.length; i++)
             sizes[i] = 1024 * MB / CPUS;
 
-        PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(sizes),
null, PAGE_SIZE, new MemoryMetricsImpl(null), true);
+        PageMemory pageMem = new PageMemoryNoStoreImpl(log,
+            new UnsafeMemoryProvider(sizes),
+            null,
+            PAGE_SIZE,
+            null,
+            new MemoryMetricsImpl(null), true);
 
         pageMem.start();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
index a3bce8b..1cede9b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
@@ -319,7 +319,13 @@ public class FreeListImplSelfTest extends GridCommonAbstractTest {
         for (int i = 0; i < sizes.length; i++)
             sizes[i] = 1024 * MB / CPUS;
 
-        PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(sizes),
null, pageSize, new MemoryMetricsImpl(null), true);
+        PageMemory pageMem = new PageMemoryNoStoreImpl(log,
+            new UnsafeMemoryProvider(sizes),
+            null,
+            pageSize,
+            null,
+            new MemoryMetricsImpl(null),
+            true);
 
         pageMem.start();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
index 8b49d03..61c8ad9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
@@ -161,6 +161,6 @@ public class MetadataStorageSelfTest extends GridCommonAbstractTest {
 
         DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath,
clean, sizes);
 
-        return new PageMemoryNoStoreImpl(log, provider, null, PAGE_SIZE, new MemoryMetricsImpl(null),
true);
+        return new PageMemoryNoStoreImpl(log, provider, null, PAGE_SIZE, null, new MemoryMetricsImpl(null),
true);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/67d3358d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
index 361bad3..f34deae 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java
@@ -140,6 +140,7 @@ public class InlineIndexHelperTest extends TestCase {
             new UnsafeMemoryProvider(sizes),
             null,
             PAGE_SIZE,
+            null,
             new MemoryMetricsImpl(null),
             false);
 
@@ -186,6 +187,7 @@ public class InlineIndexHelperTest extends TestCase {
             new UnsafeMemoryProvider(sizes),
             null,
             PAGE_SIZE,
+            null,
             new MemoryMetricsImpl(null),
             false);
 
@@ -308,6 +310,7 @@ public class InlineIndexHelperTest extends TestCase {
             new UnsafeMemoryProvider(sizes),
             null,
             PAGE_SIZE,
+            null,
             new MemoryMetricsImpl(null),
             false);
 


Mime
View raw message