ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [41/50] ignite git commit: Metadata storage fixed.
Date Thu, 28 Apr 2016 08:53:11 GMT
Metadata storage fixed.


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

Branch: refs/heads/ignite-db-x-10884
Commit: ca839c87d5d0dbcbedcc2d65e6f34473bc9e5cfa
Parents: 956f083
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Tue Apr 26 22:08:59 2016 -0700
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Tue Apr 26 22:08:59 2016 -0700

----------------------------------------------------------------------
 .../cache/database/MetadataStorage.java         | 20 +++++++++++++++-----
 .../database/MetadataStorageSelfTest.java       |  4 ++--
 2 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ca839c87/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
index 169c97c..5cb0ca1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.pagemem.Page;
 import org.apache.ignite.internal.pagemem.PageIdAllocator;
 import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 
 /**
@@ -100,12 +101,19 @@ public class MetadataStorage implements MetaStore {
                 try {
                     state.writePage = nextPageId;
 
-                    nextPageId = buf.getLong();
+                    buf = nextPage.getForRead();
 
-                    rootPageId = scanForIndexRoot(buf, idxNameBytes, cacheId);
+                    try {
+                        nextPageId = buf.getLong();
 
-                    if (rootPageId != null)
-                        return rootPageId;
+                        rootPageId = scanForIndexRoot(buf, idxNameBytes, cacheId);
+
+                        if (rootPageId != null)
+                            return rootPageId;
+                    }
+                    finally {
+                        nextPage.releaseRead();
+                    }
                 }
                 finally {
                     pageMem.releasePage(nextPage);
@@ -160,7 +168,7 @@ public class MetadataStorage implements MetaStore {
             try {
                 long nextPageId = writeBuf.getLong();
 
-                assert nextPageId == 0: nextPageId;
+                assert nextPageId == 0: "[nextPageId=" + U.hexLong(nextPageId) + ", writePageId="
+ U.hexLong(writePageId) + ']';
 
                 // Position buffer to the last record.
                 writeBuf.position(state.position);
@@ -185,6 +193,8 @@ public class MetadataStorage implements MetaStore {
                     writePage = pageMem.page(newMeta);
                     writeBuf = writePage.getForWrite();
                     writePageId = newMeta.pageId();
+                    // Next page, just need to make an offset.
+                    writeBuf.putLong(0);
                 }
 
                 writeBuf.put((byte)idxNameBytes.length);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca839c87/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
index c25288c..e5e4879 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/MetadataStorageSelfTest.java
@@ -36,8 +36,8 @@ import java.util.concurrent.ThreadLocalRandom;
  *
  */
 public class MetadataStorageSelfTest extends GridCommonAbstractTest {
-    /** */
-    public static final int PAGE_SIZE = 8 * 1024;
+    /** Make sure page is small enough to trigger multiple pages in a linked list. */
+    public static final int PAGE_SIZE = 1024;
 
     /** */
     private static File allocationPath;


Mime
View raw message