ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: Fixed local cache size() method,
Date Fri, 30 Dec 2016 09:03:47 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3477 9776f3f49 -> 6f47f44c4


Fixed local cache size() method,


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

Branch: refs/heads/ignite-3477
Commit: 6f47f44c4b060d18f372a7d80bdd973a0ff02c7e
Parents: 9776f3f
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Dec 30 12:03:45 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Dec 30 12:03:45 2016 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheOffheapManager.java          |  6 ++++++
 .../cache/IgniteCacheOffheapManagerImpl.java      | 18 ++++++++++++++++--
 .../processors/cache/local/GridLocalCache.java    |  7 ++-----
 3 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6f47f44c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index 944428e..c1d8299 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -244,6 +244,12 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
 
     /**
      *
+     * @return Number of entries.
+     */
+    public long entriesCount();
+
+    /**
+     *
      */
     interface CacheDataStore {
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f47f44c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 2fc568f..bfbc616 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -79,13 +79,14 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
     private boolean indexingEnabled;
 
     /** */
-    protected CacheDataStore locCacheDataStore;
+    // TODO GG-11208 need restore size after restart.
+    private CacheDataStore locCacheDataStore;
 
     /** */
     protected final ConcurrentMap<Integer, CacheDataStore> partDataStores = new ConcurrentHashMap<>();
 
     /** */
-    protected final CacheDataStore removedStore = new CacheDataStoreImpl(-1, null, null,
null);
+    protected final CacheDataStore rmvdStore = new CacheDataStoreImpl(-1, null, null, null);
 
     /** */
     protected PendingEntriesTree pendingEntries;
@@ -196,6 +197,19 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public long entriesCount() {
+        if (cctx.isLocal())
+            return locCacheDataStore.size();
+
+        long size = 0;
+
+        for (CacheDataStore store : partDataStores.values())
+            size += store.size();
+
+        return size;
+    }
+
     /**
      * @param p Partition.
      * @return Partition data.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f47f44c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
index ee75bd3..7f03650 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
@@ -55,9 +55,6 @@ public class GridLocalCache<K, V> extends GridCacheAdapter<K, V>
{
     /** */
     private GridCachePreloader preldr;
 
-    /** Storage size. */
-    private final AtomicLong storageSize = new AtomicLong(); // TODO GG-11208 need restore
after restart.
-
     /**
      * Empty constructor required by {@link Externalizable}.
      */
@@ -247,7 +244,7 @@ public class GridLocalCache<K, V> extends GridCacheAdapter<K,
V> {
         modes.backup = true;
 
         if (modes.offheap)
-            return storageSize.get();
+            return ctx.offheap().entriesCount();
         else if (modes.heap)
             return size();
         else
@@ -255,7 +252,7 @@ public class GridLocalCache<K, V> extends GridCacheAdapter<K,
V> {
     }
 
     /** {@inheritDoc} */
-    @Override public long localSizeLong(int partition, CachePeekMode[] peekModes) throws
IgniteCheckedException {
+    @Override public long localSizeLong(int part, CachePeekMode[] peekModes) throws IgniteCheckedException
{
         return localSizeLong(peekModes);
     }
 }


Mime
View raw message