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: EA3 - Fixing partition eviction
Date Mon, 10 Oct 2016 12:13:34 GMT
EA3 - Fixing partition eviction


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

Branch: refs/heads/ignite-gg-8-io2-selNow
Commit: 4f98931e9e8a5829044c9a4a046bd6c757405d52
Parents: f9f45c2
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Mon Oct 3 18:35:24 2016 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Mon Oct 3 18:35:56 2016 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheOffheapManager.java        | 71 +++++++++-----------
 .../cache/IgniteCacheOffheapManagerImpl.java    | 70 ++++++++++++++-----
 .../distributed/dht/GridDhtLocalPartition.java  | 55 +++------------
 .../processors/cache/local/GridLocalCache.java  | 18 +----
 .../apache/ignite/internal/util/GridDebug.java  |  2 +-
 5 files changed, 95 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4f98931e/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 79d4344..ed40925 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
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.util.concurrent.atomic.AtomicLong;
 import javax.cache.Cache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -64,11 +63,10 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
 
     /**
      * @param p Partition.
-     * @param lsnr Listener.
      * @return Data store.
      * @throws IgniteCheckedException If failed.
      */
-    public CacheDataStore createCacheDataStore(int p, CacheDataStore.SizeTracker lsnr) throws
IgniteCheckedException;
+    public CacheDataStore createCacheDataStore(int p) throws IgniteCheckedException;
 
     /**
      * @param p Partition ID.
@@ -236,7 +234,6 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
      *
      */
     interface CacheDataStore {
-
         /**
          * @return Partition ID.
          */
@@ -248,6 +245,37 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
         String name();
 
         /**
+         * @param size Size to init.
+         * @param updCntr Update counter to init.
+         */
+        void init(long size, long updCntr);
+
+        /**
+         * @return Size.
+         */
+        int size();
+
+        /**
+         * @return Update counter.
+         */
+        long updateCounter();
+
+        /**
+         *
+         */
+        void updateCounter(long val);
+
+        /**
+         * @return Next update counter.
+         */
+        public long nextUpdateCounter();
+
+        /**
+         * @return Initial update counter.
+         */
+        public long initialUpdateCounter();
+
+        /**
          * @param key Key.
          * @param part Partition.
          * @param val Value.
@@ -292,40 +320,5 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
          * @return Row store.
          */
         public RowStore rowStore();
-
-        /**
-         * @return Size.
-         */
-        public int size();
-
-        /**
-         * @return Update counter.
-         */
-        public long updateCounter();
-
-        /**
-         * Data store size tracker.
-         */
-        interface SizeTracker {
-            /**
-             * On new entry inserted.
-             */
-            void onInsert();
-
-            /**
-             * On entry removed.
-             */
-            void onRemove();
-
-            /**
-             * @return Size.
-             */
-            int size();
-
-            /**
-             * @return Update counter.
-             */
-            long updateCounter();
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f98931e/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 0c2192a..5e2f6f3 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
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
 import javax.cache.Cache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -109,7 +110,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
                 if (cctx.isLocal()) {
                     assert cctx.cache() instanceof GridLocalCache : cctx.cache();
 
-                    locCacheDataStore = createCacheDataStore(0, (CacheDataStore.SizeTracker)cctx.cache());
+                    locCacheDataStore = createCacheDataStore(0);
                 }
             }
             finally {
@@ -638,9 +639,8 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
     }
 
     /** {@inheritDoc} */
-    @Override public final CacheDataStore createCacheDataStore(int p,
-        CacheDataStore.SizeTracker lsnr) throws IgniteCheckedException {
-        CacheDataStore dataStore = createCacheDataStore0(p, lsnr);
+    @Override public final CacheDataStore createCacheDataStore(int p) throws IgniteCheckedException
{
+        CacheDataStore dataStore = createCacheDataStore0(p);
 
         partDataStores.put(p, dataStore);
 
@@ -649,11 +649,10 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
 
     /**
      * @param p Partition.
-     * @param lsnr Listener.
      * @return Cache data store.
      * @throws IgniteCheckedException If failed.
      */
-    protected CacheDataStore createCacheDataStore0(int p, CacheDataStore.SizeTracker lsnr)
+    protected CacheDataStore createCacheDataStore0(int p)
         throws IgniteCheckedException {
         IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
 
@@ -673,7 +672,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
             rootPage,
             true);
 
-        return new CacheDataStoreImpl(p, idxName, rowStore, dataTree, lsnr);
+        return new CacheDataStoreImpl(p, idxName, rowStore, dataTree);
     }
 
     /** {@inheritDoc} */
@@ -742,27 +741,30 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
         /** */
         private final CacheDataTree dataTree;
 
-        /** */
-        private final SizeTracker lsnr;
+        /** Update counter. */
+        protected final AtomicLong cntr = new AtomicLong();
+
+        /** Partition size. */
+        protected final AtomicLong storageSize = new AtomicLong();
+
+        /** Initialized update counter. */
+        protected long initCntr;
 
         /**
          * @param name Name.
          * @param rowStore Row store.
          * @param dataTree Data tree.
-         * @param lsnr Listener.
          */
         public CacheDataStoreImpl(
             int partId,
             String name,
             CacheDataRowStore rowStore,
-            CacheDataTree dataTree,
-            SizeTracker lsnr
+            CacheDataTree dataTree
         ) {
             this.partId = partId;
             this.name = name;
             this.rowStore = rowStore;
             this.dataTree = dataTree;
-            this.lsnr = lsnr;
         }
 
         /** {@inheritDoc} */
@@ -772,12 +774,27 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
 
         /** {@inheritDoc} */
         @Override public int size() {
-            return lsnr.size();
+            return (int)storageSize.get();
         }
 
         /** {@inheritDoc} */
         @Override public long updateCounter() {
-            return lsnr.updateCounter();
+            return cntr.get();
+        }
+
+        /**
+         * @param val Update index value.
+         */
+        @Override public void updateCounter(long val) {
+            while (true) {
+                long val0 = cntr.get();
+
+                if (val0 >= val)
+                    break;
+
+                if (cntr.compareAndSet(val0, val))
+                    break;
+            }
         }
 
         /** {@inheritDoc} */
@@ -804,7 +821,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
             DataRow old = dataTree.put(dataRow);
 
             if (old == null)
-                lsnr.onInsert();
+                storageSize.incrementAndGet();
 
             if (indexingEnabled) {
                 GridCacheQueryManager qryMgr = cctx.queries();
@@ -846,7 +863,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
                 if (pendingEntries != null && dataRow.expireTime() != 0)
                     pendingEntries.remove(new PendingRow(dataRow.expireTime(), dataRow.link()));
 
-                lsnr.onRemove();
+                storageSize.decrementAndGet();
 
                 val = dataRow.value();
 
@@ -885,6 +902,25 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
         @Override public RowStore rowStore() {
             return rowStore;
         }
+
+        /**
+         * @return Next update index.
+         */
+        @Override public long nextUpdateCounter() {
+            return cntr.incrementAndGet();
+        }
+
+        /** {@inheritDoc} */
+        @Override public long initialUpdateCounter() {
+            return initCntr;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void init(long size, long updCntr) {
+            initCntr = updCntr;
+            storageSize.set(size);
+            cntr.set(updCntr);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f98931e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 3782eca..45a6665 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -72,8 +72,7 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDh
 /**
  * Key partition.
  */
-public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>, GridReservable,
GridCacheConcurrentMap,
-    CacheDataStore.SizeTracker {
+public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>, GridReservable,
GridCacheConcurrentMap {
     /** Maximum size for delete queue. */
     public static final int MAX_DELETE_QUEUE_SIZE = Integer.getInteger(IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE,
         200_000);
@@ -121,18 +120,9 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
     /** Group reservations. */
     private final CopyOnWriteArrayList<GridDhtPartitionsReservation> reservations =
new CopyOnWriteArrayList<>();
 
-    /** Update counter. */
-    private final AtomicLong cntr = new AtomicLong();
-
-    /** Initialized update counter. */
-    private long initCntr;
-
     /** */
     private final CacheDataStore store;
 
-    /** Partition size. */
-    private final AtomicLong storageSize = new AtomicLong();
-
     /** Partition updates. */
     private ConcurrentNavigableMap<Long, Boolean> updates = new ConcurrentSkipListMap<>();
 
@@ -171,7 +161,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
         rmvQueue = new GridCircularBuffer<>(U.ceilPow2(delQueueSize));
 
         try {
-            store = cctx.offheap().createCacheDataStore(id, this);
+            store = cctx.offheap().createCacheDataStore(id);
         }
         catch (IgniteCheckedException e) {
             // TODO ignite-db
@@ -187,17 +177,6 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
     }
 
     /**
-     * @param size Partition size.
-     * @param partCntr Partition counter.
-     */
-    public void init(long size, long partCntr) {
-        storageSize.set(size);
-        cntr.set(partCntr);
-
-        initCntr = partCntr;
-    }
-
-    /**
      * Adds group reservation to this partition.
      *
      * @param r Reservation.
@@ -311,22 +290,12 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
 
     /** {@inheritDoc} */
     @Override public int size() {
-        return (int)storageSize.get();
+        return (int)store.size();
     }
 
     /** {@inheritDoc} */
     @Override public int publicSize() {
-        return (int)storageSize.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onInsert() {
-        storageSize.incrementAndGet();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onRemove() {
-        storageSize.decrementAndGet();
+        return (int)store.size();
     }
 
     /** {@inheritDoc} */
@@ -801,36 +770,28 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
      * @return Next update index.
      */
     public long nextUpdateCounter() {
-        return cntr.incrementAndGet();
+        return store.nextUpdateCounter();
     }
 
     /**
      * @return Current update index.
      */
     public long updateCounter() {
-        return cntr.get();
+        return store.updateCounter();
     }
 
     /**
      * @return Initial update counter.
      */
     public long initialUpdateCounter() {
-        return initCntr;
+        return store.initialUpdateCounter();
     }
 
     /**
      * @param val Update index value.
      */
     public void updateCounter(long val) {
-        while (true) {
-            long val0 = cntr.get();
-
-            if (val0 >= val)
-                break;
-
-            if (cntr.compareAndSet(val0, val))
-                break;
-        }
+        store.updateCounter(val);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f98931e/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 b50800c..ee75bd3 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
@@ -36,7 +36,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheMapEntryFactory;
 import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
 import org.apache.ignite.internal.processors.cache.GridCachePreloader;
 import org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter;
-import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -49,8 +48,7 @@ import org.jetbrains.annotations.Nullable;
 /**
  * Local cache implementation.
  */
-public class GridLocalCache<K, V> extends GridCacheAdapter<K, V>
-    implements IgniteCacheOffheapManager.CacheDataStore.SizeTracker {
+public class GridLocalCache<K, V> extends GridCacheAdapter<K, V> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -242,20 +240,6 @@ public class GridLocalCache<K, V> extends GridCacheAdapter<K,
V>
     }
 
     /** {@inheritDoc} */
-    @Override public void onInsert() {
-        storageSize.incrementAndGet();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onRemove() {
-        storageSize.decrementAndGet();
-    }
-
-    @Override public long updateCounter() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
     @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException
{
         PeekModes modes = parsePeekModes(peekModes, true);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f98931e/modules/core/src/main/java/org/apache/ignite/internal/util/GridDebug.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridDebug.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridDebug.java
index ec3323e..a8af0fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridDebug.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridDebug.java
@@ -70,7 +70,7 @@ public class GridDebug {
     /** */
     static {
         if (LOGS_PATH != null) {
-            File log = new File(LOGS_PATH + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-").format(new
Date()) +
+            File log = new File(new File(LOGS_PATH), new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-").format(new
Date()) +
                     ManagementFactory.getRuntimeMXBean().getName() + ".log");
 
             assert !log.exists();


Mime
View raw message