asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject incubator-asterixdb-hyracks git commit: Add method to check state of buffer cache
Date Tue, 24 Nov 2015 00:48:05 GMT
Repository: incubator-asterixdb-hyracks
Updated Branches:
  refs/heads/master 1a659da1f -> 31c2926ca


Add method to check state of buffer cache

Change-Id: I80fb891b5310252143854a336b591bf3f8cd4ba8
Reviewed-on: https://asterix-gerrit.ics.uci.edu/497
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <hubailmor@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/commit/31c2926c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/tree/31c2926c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/diff/31c2926c

Branch: refs/heads/master
Commit: 31c2926ca3da3e01023e2f2859de8948c94772de
Parents: 1a659da
Author: Ian Maxon <imaxon@apache.org>
Authored: Fri Nov 13 13:58:04 2015 -0800
Committer: Ian Maxon <imaxon@apache.org>
Committed: Mon Nov 23 16:02:55 2015 -0800

----------------------------------------------------------------------
 .../storage/common/buffercache/BufferCache.java | 50 +++++++++++++++++---
 .../buffercache/IBufferCacheInternal.java       |  2 +
 2 files changed, 46 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/31c2926c/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
----------------------------------------------------------------------
diff --git a/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
b/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
index 3a23c8d..f66726b 100644
--- a/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
+++ b/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
@@ -20,12 +20,7 @@ package org.apache.hyracks.storage.common.buffercache;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
@@ -487,6 +482,49 @@ public class BufferCache implements IBufferCacheInternal, ILifeCycleComponent
{
         return buffer.toString();
     }
 
+    @Override
+    public boolean isClean(){
+        List<Long> reachableDpids = new LinkedList<>();
+        synchronized (cachedPages) {
+            for (ICachedPageInternal internalPage : cachedPages) {
+            CachedPage c = (CachedPage) internalPage;
+                if (c.confiscated() ||
+                        c.latch.getReadLockCount() != 0 || c.latch.getWriteHoldCount() !=
0) {
+                    return false;
+                }
+                if(c.valid){
+                    reachableDpids.add(c.dpid);
+                }
+            }
+        }
+        for(Long l: reachableDpids){
+            if(!canFindValidCachedPage(l)){
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean canFindValidCachedPage(long dpid){
+        int hash = hash(dpid);
+        CachedPage cPage = null;
+        CacheBucket bucket = pageMap[hash];
+        bucket.bucketLock.lock();
+        try {
+            cPage = bucket.cachedPage;
+            while (cPage != null) {
+                assert bucket.cachedPage != bucket.cachedPage.next;
+                if (cPage.dpid == dpid) {
+                    return true;
+                }
+                cPage = cPage.next;
+            }
+        } finally {
+            bucket.bucketLock.unlock();
+        }
+        return false;
+    }
+
     private void read(CachedPage cPage) throws HyracksDataException {
         BufferedFileHandle fInfo = getFileInfo(cPage);
         cPage.buffer.clear();

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/31c2926c/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCacheInternal.java
----------------------------------------------------------------------
diff --git a/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCacheInternal.java
b/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCacheInternal.java
index 7c9f01f..01f06d8 100644
--- a/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCacheInternal.java
+++ b/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCacheInternal.java
@@ -19,6 +19,8 @@
 package org.apache.hyracks.storage.common.buffercache;
 
 public interface IBufferCacheInternal extends IBufferCache {
+    boolean isClean();
+
     public ICachedPageInternal getPage(int cpid);
 
     public void addPage(ICachedPageInternal page);


Mime
View raw message