ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [38/50] [abbrv] ignite git commit: IGNITE-6719 Get rid of no-op segment lock/unlock in PageMemoryImpl
Date Wed, 25 Oct 2017 09:41:12 GMT
IGNITE-6719 Get rid of no-op segment lock/unlock in PageMemoryImpl


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

Branch: refs/heads/ignite-3478
Commit: 22ee726e5f2b0023ed9f1d6289cae7253cc74769
Parents: 62cb4fb
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Tue Oct 24 11:22:07 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Tue Oct 24 11:22:28 2017 +0300

----------------------------------------------------------------------
 .../persistence/pagemem/PageMemoryImpl.java     | 37 +++++++++++---------
 1 file changed, 21 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/22ee726e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
index 4a4fe9e..a773b42 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
@@ -119,9 +119,6 @@ public class PageMemoryImpl implements PageMemoryEx {
     /** Dirty flag. */
     private static final long DIRTY_FLAG = 0x0100000000000000L;
 
-    /** Dirty flag. */
-    private static final long TMP_DIRTY_FLAG = 0x0200000000000000L;
-
     /** Invalid relative pointer value. */
     private static final long INVALID_REL_PTR = RELATIVE_PTR_MASK;
 
@@ -237,9 +234,6 @@ public class PageMemoryImpl implements PageMemoryEx {
     /** */
     private DataRegionMetricsImpl memMetrics;
 
-    /** */
-    private volatile boolean closed;
-
     /**
      * @param directMemoryProvider Memory allocator to use.
      * @param sharedCtx Cache shared context.
@@ -361,14 +355,8 @@ public class PageMemoryImpl implements PageMemoryEx {
 
         U.shutdownNow(getClass(), asyncRunner, log);
 
-        closed = true;
-
-        for (Segment seg : segments) {
-            // Make sure all threads have left the lock.
-            seg.writeLock().lock();
-
-            seg.writeLock().unlock();
-        }
+        for (Segment seg : segments)
+            seg.close();
 
         directMemoryProvider.shutdown();
     }
@@ -1105,7 +1093,7 @@ public class PageMemoryImpl implements PageMemoryEx {
                 seg.readLock().lock();
 
                 try {
-                    if (closed)
+                    if (seg.closed)
                         continue;
 
                     total += seg.loadedPages.size();
@@ -1129,7 +1117,7 @@ public class PageMemoryImpl implements PageMemoryEx {
             seg.readLock().lock();
 
             try {
-                if (closed)
+                if (seg.closed)
                     continue;
 
                 total += seg.acquiredPages();
@@ -1670,6 +1658,9 @@ public class PageMemoryImpl implements PageMemoryEx {
         /** Maps partition (cacheId, partId) to its tag. Tag is 1-based incrementing partition
file counter */
         private final Map<T2<Integer, Integer>, Integer> partTagMap = new HashMap<>();
 
+        /** */
+        private boolean closed;
+
         /**
          * @param region Memory region.
          * @param throttlingEnabled Write throttling enabled flag.
@@ -1695,6 +1686,20 @@ public class PageMemoryImpl implements PageMemoryEx {
         }
 
         /**
+         * Closes the segment.
+         */
+        private void close() {
+            writeLock().lock();
+
+            try {
+                closed = true;
+            }
+            finally {
+                writeLock().unlock();
+            }
+        }
+
+        /**
          *
          */
         private boolean safeToUpdate() {


Mime
View raw message