You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/27 15:45:52 UTC

incubator-ignite git commit: ignite-471-2: fixed IGNITE-914

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-471-2 48afb862d -> 38e808a5c


ignite-471-2: fixed IGNITE-914


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

Branch: refs/heads/ignite-471-2
Commit: 38e808a5c90440699726d217f93d8e446b472ba2
Parents: 48afb86
Author: Denis Magda <dm...@gridgain.com>
Authored: Wed May 27 11:34:32 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed May 27 11:34:32 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheEntryMemorySizeSelfTest.java | 95 +++++++++++---------
 .../ignite/testsuites/IgniteCacheTestSuite.java |  2 +-
 2 files changed, 53 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38e808a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
index 177e990..25c7c85 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
@@ -48,63 +48,28 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest {
     private static final int NULL_REF_SIZE = 1;
 
     /** Entry overhead. */
-    private static final int ENTRY_OVERHEAD;
+    private static int ENTRY_OVERHEAD;
 
     /** Replicated entry overhead. */
-    private static final int REPLICATED_ENTRY_OVERHEAD;
+    private static int REPLICATED_ENTRY_OVERHEAD;
 
     /** DHT entry overhead. */
-    private static final int DHT_ENTRY_OVERHEAD;
+    private static int DHT_ENTRY_OVERHEAD;
 
     /** Near entry overhead. */
-    private static final int NEAR_ENTRY_OVERHEAD;
+    private static int NEAR_ENTRY_OVERHEAD;
 
     /** Reader size. */
-    private static final int READER_SIZE = 24;
+    private static int READER_SIZE = 24;
 
     /** Key size in bytes. */
-    private static final int KEY_SIZE;
+    private static int KEY_SIZE;
 
     /** 1KB value size in bytes. */
-    private static final int ONE_KB_VAL_SIZE;
+    private static int ONE_KB_VAL_SIZE;
 
     /** 2KB value size in bytes. */
-    private static final int TWO_KB_VAL_SIZE;
-
-    /**
-     *
-     */
-    static {
-        try {
-            ENTRY_OVERHEAD = U.<Integer>staticField(GridCacheMapEntry.class, "SIZE_OVERHEAD");
-            DHT_ENTRY_OVERHEAD = U.<Integer>staticField(GridDhtCacheEntry.class, "DHT_SIZE_OVERHEAD");
-            NEAR_ENTRY_OVERHEAD = U.<Integer>staticField(GridNearCacheEntry.class, "NEAR_SIZE_OVERHEAD");
-            REPLICATED_ENTRY_OVERHEAD = DHT_ENTRY_OVERHEAD;
-
-            Marshaller marsh = new OptimizedMarshaller();
-
-            marsh.setContext(new MarshallerContext() {
-                @Override public boolean registerClass(int id, Class cls) {
-                    return true;
-                }
-
-                @Override public Class getClass(int id, ClassLoader ldr) {
-                    throw new UnsupportedOperationException();
-                }
-
-                @Override public boolean isSystemType(String typeName) {
-                    return false;
-                }
-            });
-
-            KEY_SIZE = marsh.marshal(1).length;
-            ONE_KB_VAL_SIZE = marsh.marshal(new Value(new byte[1024])).length;
-            TWO_KB_VAL_SIZE = marsh.marshal(new Value(new byte[2048])).length;
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteException(e);
-        }
-    }
+    private static int TWO_KB_VAL_SIZE;
 
     /** Cache mode. */
     private CacheMode mode;
@@ -137,6 +102,50 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest {
         return cfg;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        try {
+            ENTRY_OVERHEAD = U.<Integer>staticField(GridCacheMapEntry.class, "SIZE_OVERHEAD");
+            DHT_ENTRY_OVERHEAD = U.<Integer>staticField(GridDhtCacheEntry.class, "DHT_SIZE_OVERHEAD");
+            NEAR_ENTRY_OVERHEAD = U.<Integer>staticField(GridNearCacheEntry.class, "NEAR_SIZE_OVERHEAD");
+            REPLICATED_ENTRY_OVERHEAD = DHT_ENTRY_OVERHEAD;
+
+            Marshaller marsh = createMarshaller();
+
+            KEY_SIZE = marsh.marshal(1).length;
+            ONE_KB_VAL_SIZE = marsh.marshal(new Value(new byte[1024])).length;
+            TWO_KB_VAL_SIZE = marsh.marshal(new Value(new byte[2048])).length;
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
+        }
+    }
+
+    /**
+     * Creates an instance of Marshaller that is used by caches during the test run.
+     *
+     * @return
+     */
+    protected Marshaller createMarshaller() {
+        Marshaller marsh = new OptimizedMarshaller();
+
+        marsh.setContext(new MarshallerContext() {
+            @Override public boolean registerClass(int id, Class cls) {
+                return true;
+            }
+
+            @Override public Class getClass(int id, ClassLoader ldr) {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override public boolean isSystemType(String typeName) {
+                return false;
+            }
+        });
+
+        return marsh;
+    }
+
     /** @throws Exception If failed. */
     public void testLocal() throws Exception {
         mode = LOCAL;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38e808a5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 54e8cfb..7678fcc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -122,7 +122,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         GridTestUtils.addTestIfNeeded(suite, DataStreamProcessorSelfTest.class, ignoredTests);
         suite.addTestSuite(DataStreamerMultiThreadedSelfTest.class);
         suite.addTestSuite(DataStreamerImplSelfTest.class);
-        suite.addTestSuite(GridCacheEntryMemorySizeSelfTest.class);
+        GridTestUtils.addTestIfNeeded(suite, GridCacheEntryMemorySizeSelfTest.class, ignoredTests);
         suite.addTestSuite(GridCacheClearAllSelfTest.class);
         suite.addTestSuite(GridCacheObjectToStringSelfTest.class);
         suite.addTestSuite(GridCacheLoadOnlyStoreAdapterSelfTest.class);