ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [1/2] ignite git commit: IGNITE-5375 - Persistence metrics introduced
Date Wed, 07 Jun 2017 09:30:12 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5267 a2e173053 -> fffad68f6


http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryImpl.java
b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryImpl.java
index f807229..93ee411 100755
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryImpl.java
+++ b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryImpl.java
@@ -55,6 +55,7 @@ import org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord;
 import org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.TrackingPageIO;
 import org.apache.ignite.internal.processors.cache.database.wal.crc.IgniteDataIntegrityViolationException;
@@ -221,6 +222,9 @@ public class PageMemoryImpl implements PageMemoryEx {
     /** */
     private long[] sizes;
 
+    /** */
+    private MemoryMetricsImpl memMetrics;
+
     /**
      * @param directMemoryProvider Memory allocator to use.
      * @param sharedCtx Cache shared context.
@@ -235,7 +239,8 @@ public class PageMemoryImpl implements PageMemoryEx {
         int pageSize,
         GridInClosure3X<FullPageId, ByteBuffer, Integer> flushDirtyPage,
         GridInClosure3X<Long, FullPageId, PageMemoryEx> changeTracker,
-        CheckpointLockStateChecker stateChecker
+        CheckpointLockStateChecker stateChecker,
+        MemoryMetricsImpl memMetrics
     ) {
         assert sharedCtx != null;
 
@@ -257,6 +262,8 @@ public class PageMemoryImpl implements PageMemoryEx {
         sysPageSize = pageSize + PAGE_OVERHEAD;
 
         rwLock = new OffheapReadWriteLock(128);
+
+        this.memMetrics = memMetrics;
     }
 
     /** {@inheritDoc} */
@@ -555,6 +562,8 @@ public class PageMemoryImpl implements PageMemoryEx {
                     try {
                         ByteBuffer buf = wrapPointer(pageAddr, pageSize());
 
+                        memMetrics.updatePageReplaceRate();
+
                         storeMgr.read(cacheId, pageId, buf);
                     }
                     catch (IgniteDataIntegrityViolationException ignore) {
@@ -769,6 +778,8 @@ public class PageMemoryImpl implements PageMemoryEx {
             seg.dirtyPages = new GridConcurrentHashSet<>();
         }
 
+        memMetrics.resetDirtyPages();
+
         return new GridMultiCollectionWrapper<>(collections);
     }
 
@@ -780,7 +791,7 @@ public class PageMemoryImpl implements PageMemoryEx {
     }
 
     /** {@inheritDoc} */
-    @Override public Integer getForCheckpoint(FullPageId fullId, ByteBuffer tmpBuf) {
+    @Override public Integer getForCheckpoint(FullPageId fullId, ByteBuffer tmpBuf, CheckpointMetricsTracker
tracker) {
         assert tmpBuf.remaining() == pageSize();
 
         Segment seg = segment(fullId.cacheId(), fullId.pageId());
@@ -858,7 +869,7 @@ public class PageMemoryImpl implements PageMemoryEx {
 
         }
         else {
-            copyPageForCheckpoint(absPtr, fullId, tmpBuf);
+            copyPageForCheckpoint(absPtr, fullId, tmpBuf, tracker);
 
             return tag;
         }
@@ -869,7 +880,7 @@ public class PageMemoryImpl implements PageMemoryEx {
      * @param fullId Full id.
      * @param tmpBuf Tmp buffer.
      */
-    private void copyPageForCheckpoint(long absPtr, FullPageId fullId, ByteBuffer tmpBuf)
{
+    private void copyPageForCheckpoint(long absPtr, FullPageId fullId, ByteBuffer tmpBuf,
CheckpointMetricsTracker tracker) {
         assert absPtr != 0;
 
         long tmpRelPtr;
@@ -907,6 +918,9 @@ public class PageMemoryImpl implements PageMemoryEx {
 
         PageHeader.dirty(tmpAbsPtr, false);
 
+        if (tracker != null)
+            tracker.onCowPageWritten();
+
         checkpointPool.releaseFreePage(tmpRelPtr);
 
         // We pinned the page when allocated the temp buffer, release it now.
@@ -1264,11 +1278,19 @@ public class PageMemoryImpl implements PageMemoryEx {
         boolean wasDirty = PageHeader.dirty(absPtr, dirty);
 
         if (dirty) {
-            if (!wasDirty || forceAdd)
-                segment(pageId.cacheId(), pageId.pageId()).dirtyPages.add(pageId);
+            if (!wasDirty || forceAdd) {
+                boolean added = segment(pageId.cacheId(), pageId.pageId()).dirtyPages.add(pageId);
+
+                if (added)
+                    memMetrics.incrementDirtyPages();
+            }
+        }
+        else {
+            boolean rmv = segment(pageId.cacheId(), pageId.pageId()).dirtyPages.remove(pageId);
+
+            if (rmv)
+                memMetrics.decrementDirtyPages();
         }
-        else
-            segment(pageId.cacheId(), pageId.pageId()).dirtyPages.remove(pageId);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/wal/FileWriteAheadLogManager.java
b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/wal/FileWriteAheadLogManager.java
index 8a113ba..3113c3e 100644
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/wal/FileWriteAheadLogManager.java
+++ b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/wal/FileWriteAheadLogManager.java
@@ -55,6 +55,8 @@ import org.apache.ignite.internal.pagemem.wal.WALPointer;
 import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
+import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.PersistenceMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.wal.record.HeaderRecord;
 import org.apache.ignite.internal.processors.cache.database.wal.serializer.RecordV1Serializer;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
@@ -138,6 +140,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
     /** */
     private IgniteConfiguration igCfg;
 
+    /** Persistence metrics tracker. */
+    private PersistenceMetricsImpl metrics;
+
     /** */
     private File walWorkDir;
 
@@ -147,6 +152,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
     /** Current log segment handle */
     private volatile FileWriteHandle currentHnd;
 
+    /** */
+    private volatile long oldestArchiveSegmentIdx;
+
     /** Updater for {@link #currentHnd}, used for verify there are no concurrent update for
current log segment handle */
     private static final AtomicReferenceFieldUpdater<FileWriteAheadLogManager, FileWriteHandle>
currentHndUpd =
         AtomicReferenceFieldUpdater.newUpdater(FileWriteAheadLogManager.class, FileWriteHandle.class,
"currentHnd");
@@ -215,9 +223,17 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
 
             serializer = new RecordV1Serializer(cctx);
 
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)cctx.database();
+
+            metrics = dbMgr.persistentStoreMetricsImpl();
+
             checkOrPrepareFiles();
 
-            archiver = new FileArchiver();
+            IgniteBiTuple<Long, Long> tup = scanMinMaxArchiveIndices();
+
+            oldestArchiveSegmentIdx = tup == null ? 0 : tup.get1();
+
+            archiver = new FileArchiver(tup == null ? -1 : tup.get2());
 
             if (mode != Mode.DEFAULT) {
                 if (log.isInfoEnabled())
@@ -279,13 +295,13 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
     /** {@inheritDoc} */
     @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException
{
         if (log.isDebugEnabled())
-            log.debug("Activate file write ahead log [nodeId=" + cctx.localNodeId() +
+            log.debug("Activated file write ahead log manager [nodeId=" + cctx.localNodeId()
+
                 " topVer=" + cctx.discovery().topologyVersionEx() + " ]");
 
         start0();
 
         if (!cctx.kernalContext().clientNode()) {
-            archiver = new FileArchiver();
+            assert archiver != null;
 
             archiver.start();
         }
@@ -361,6 +377,8 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
             WALPointer ptr = current.addRecord(record);
 
             if (ptr != null) {
+                metrics.onWalRecordLogged();
+
                 lastWALPtr.set(ptr);
 
                 return ptr;
@@ -451,6 +469,10 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
         archiver0.release(((FileWALPointer)start).index());
     }
 
+    /**
+     * @param absIdx Absolulte index to check.
+     * @return {@code true} if has this index.
+     */
     private boolean hasIndex(long absIdx) {
         String name = FileDescriptor.fileName(absIdx);
 
@@ -459,7 +481,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
         if (inArchive)
             return true;
 
-        if (absIdx <= archiver.lastArchivedIndex())
+        if (absIdx <= lastArchivedIndex())
             return false;
 
         FileWriteHandle cur = currentHnd;
@@ -494,6 +516,10 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
                         desc.file.getAbsolutePath());
                 else
                     deleted++;
+
+                // Bump up the oldest archive segment index.
+                if (oldestArchiveSegmentIdx < desc.idx)
+                    oldestArchiveSegmentIdx = desc.idx;
             }
         }
 
@@ -501,6 +527,20 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
     }
 
     /** {@inheritDoc} */
+    @Override public int walArchiveSegments() {
+        long oldest = oldestArchiveSegmentIdx;
+
+        long lastArchived = archiver.lastArchivedAbsoluteIndex();
+
+        if (lastArchived == -1)
+            return 0;
+
+        int res = (int)(lastArchived - oldest);
+
+        return res >= 0 ? res : 0;
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean reserved(WALPointer ptr) {
         FileWALPointer fPtr = (FileWALPointer)ptr;
 
@@ -510,6 +550,52 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
     }
 
     /**
+     * Lists files in archive directory and returns the index of last archived file.
+     *
+     * @return The absolute index of last archived file.
+     */
+    private long lastArchivedIndex() {
+        long lastIdx = -1;
+
+        for (File file : walArchiveDir.listFiles(WAL_SEGMENT_FILE_FILTER)) {
+            try {
+                long idx = Long.parseLong(file.getName().substring(0, 16));
+
+                lastIdx = Math.max(lastIdx, idx);
+            }
+            catch (NumberFormatException | IndexOutOfBoundsException ignore) {
+
+            }
+        }
+
+        return lastIdx;
+    }
+
+    /**
+     * Lists files in archive directory and returns the index of last archived file.
+     *
+     * @return The absolute index of last archived file.
+     */
+    private IgniteBiTuple<Long, Long> scanMinMaxArchiveIndices() {
+        long minIdx = Integer.MAX_VALUE;
+        long maxIdx = -1;
+
+        for (File file : walArchiveDir.listFiles(WAL_SEGMENT_FILE_FILTER)) {
+            try {
+                long idx = Long.parseLong(file.getName().substring(0, 16));
+
+                minIdx = Math.min(minIdx, idx);
+                maxIdx = Math.max(maxIdx, idx);
+            }
+            catch (NumberFormatException | IndexOutOfBoundsException ignore) {
+
+            }
+        }
+
+        return maxIdx == -1 ? null : F.t(minIdx, maxIdx);
+    }
+
+    /**
      * Creates a directory specified by the given arguments.
      *
      * @param cfg Configured directory path, may be {@code null}.
@@ -863,10 +949,17 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
         /**
          *
          */
-        private FileArchiver() {
+        private FileArchiver(long lastAbsArchivedIdx) {
             super("wal-file-archiver%" + cctx.igniteInstanceName());
 
-            lastAbsArchivedIdx = lastArchivedIndex();
+            this.lastAbsArchivedIdx = lastAbsArchivedIdx;
+        }
+
+        /**
+         * @return Last archived segment absolute index.
+         */
+        private synchronized long lastArchivedAbsoluteIndex() {
+            return lastAbsArchivedIdx;
         }
 
         /**
@@ -1128,28 +1221,6 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
         }
 
         /**
-         * Lists files in archive directory and returns the index of last archived file.
-         *
-         * @return The absolute index of last archived file.
-         */
-        private int lastArchivedIndex() {
-            int lastIdx = -1;
-
-            for (File file : walArchiveDir.listFiles(WAL_SEGMENT_FILE_FILTER)) {
-                try {
-                    int idx = Integer.parseInt(file.getName().substring(0, 16));
-
-                    lastIdx = Math.max(lastIdx, idx);
-                }
-                catch (NumberFormatException | IndexOutOfBoundsException ignore) {
-
-                }
-            }
-
-            return lastIdx;
-        }
-
-        /**
          *
          */
         private boolean checkStop() {
@@ -1751,6 +1822,10 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
                 if (lastFsyncPos != written) {
                     assert lastFsyncPos < written; // Fsync position must be behind.
 
+                    boolean metricsEnabled = metrics.metricsEnabled();
+
+                    long start = metricsEnabled ? System.nanoTime() : 0;
+
                     try {
                         ch.force(false);
                     }
@@ -1762,6 +1837,11 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
 
                     if (fsyncDelayNanos > 0)
                         fsync.signalAll();
+
+                    long end = metricsEnabled ? System.nanoTime() : 0;
+
+                    if (metricsEnabled)
+                        metrics.onFsync(end - start);
                 }
             }
             finally {
@@ -1908,6 +1988,8 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
 
                     written += size;
 
+                    metrics.onWalBytesWritten(size);
+
                     assert written == ch.position();
                 }
                 catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java
new file mode 100644
index 0000000..fc25509
--- /dev/null
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistenceMetricsSelfTest.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.database;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.MemoryMetrics;
+import org.apache.ignite.PersistenceMetrics;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.PAX;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgnitePersistenceMetricsSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final String GROUP1 = "grp1";
+
+    /** */
+    private boolean activeOnStart = true;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        System.setProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE, "LOG_ONLY");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        System.clearProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE);
+
+        GridTestUtils.deleteDbFiles();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        GridTestUtils.deleteDbFiles();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setConsistentId(gridName);
+
+        cfg.setActiveOnStart(activeOnStart);
+
+        MemoryConfiguration memCfg = new MemoryConfiguration();
+        memCfg.setPageSize(1024);
+
+        memCfg.setDefaultMemoryPolicyName("dflt-plc");
+
+        MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
+        memPlc.setName("dflt-plc");
+        memPlc.setMaxSize(10 * 1024 * 1024);
+        memPlc.setMetricsEnabled(true);
+
+        memCfg.setMemoryPolicies(memPlc);
+
+        cfg.setMemoryConfiguration(memCfg);
+
+        cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration().setMetricsEnabled(true));
+
+        cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false));
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        cfg.setCacheConfiguration(cacheConfiguration(GROUP1, "cache", PARTITIONED, ATOMIC,
1));
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        GridTestUtils.deleteDbFiles();
+
+        super.afterTest();
+    }
+
+    /**
+     * @param grpName Cache group name.
+     * @param name Cache name.
+     * @param cacheMode Cache mode.
+     * @param atomicityMode Atomicity mode.
+     * @param backups Backups number.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration cacheConfiguration(
+        String grpName,
+        String name,
+        CacheMode cacheMode,
+        CacheAtomicityMode atomicityMode,
+        int backups
+    ) {
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setName(name);
+        ccfg.setGroupName(grpName);
+        ccfg.setAtomicityMode(atomicityMode);
+        ccfg.setBackups(backups);
+        ccfg.setCacheMode(cacheMode);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        return ccfg;
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPersistenceMetrics() throws Exception {
+        final IgniteEx ig = startGrid(0);
+
+        try {
+            IgniteCache<Object, Object> cache = ig.cache("cache");
+
+            for (int i = 0; i < 10; i++)
+                cache.put(i, new Person("first-" + i, "last-" + i));
+
+            {
+                MemoryMetrics memMetrics = ig.memoryMetrics("dflt-plc");
+
+                assertNotNull(memMetrics);
+                assertTrue(memMetrics.getDirtyPages() > 0);
+            }
+
+            ig.context().cache().context().database().waitForCheckpoint("test");
+
+            GridTestUtils.waitForCondition(new PAX() {
+                @Override public boolean applyx() {
+                    PersistenceMetrics pMetrics = ig.persistentStoreMetrics();
+
+                    assertNotNull(pMetrics);
+
+                    return pMetrics.getLastCheckpointTotalPagesNumber() != 0 &&
+                        pMetrics.getLastCheckpointDataPagesNumber() != 0;
+                }
+            }, 5_000);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    static class Person implements Serializable {
+        /** */
+        @GridToStringInclude
+        @QuerySqlField(index = true, groups = "full_name")
+        private String fName;
+
+        /** */
+        @GridToStringInclude
+        @QuerySqlField(index = true, groups = "full_name")
+        private String lName;
+
+        /**
+         * @param fName First name.
+         * @param lName Last name.
+         */
+        public Person(String fName, String lName) {
+            this.fName = fName;
+            this.lName = lName;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(Person.class, this);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            Person person = (Person)o;
+
+            return Objects.equals(fName, person.fName) &&
+                Objects.equals(lName, person.lName);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return Objects.hash(fName, lName);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreRecoveryAfterFileCorruptionTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreRecoveryAfterFileCorruptionTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreRecoveryAfterFileCorruptionTest.java
index fd73204..e10acab 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreRecoveryAfterFileCorruptionTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreRecoveryAfterFileCorruptionTest.java
@@ -294,7 +294,7 @@ public class IgnitePersistentStoreRecoveryAfterFileCorruptionTest extends
GridCo
                 if (pageIds.contains(fullId)) {
                     long cpStart = System.nanoTime();
 
-                    Integer tag = mem.getForCheckpoint(fullId, tmpBuf);
+                    Integer tag = mem.getForCheckpoint(fullId, tmpBuf, null);
 
                     if (tag == null)
                         continue;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/PageStoreCheckpointSimulationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/PageStoreCheckpointSimulationSelfTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/PageStoreCheckpointSimulationSelfTest.java
index f444505..0addcb3 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/PageStoreCheckpointSimulationSelfTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/PageStoreCheckpointSimulationSelfTest.java
@@ -602,7 +602,7 @@ public class PageStoreCheckpointSimulationSelfTest extends GridCommonAbstractTes
 
                     buf.rewind();
 
-                    mem.getForCheckpoint(fullId, buf);
+                    mem.getForCheckpoint(fullId, buf, null);
 
                     buf.position(PageIO.COMMON_HEADER_END);
 
@@ -887,7 +887,7 @@ public class PageStoreCheckpointSimulationSelfTest extends GridCommonAbstractTes
                 for (FullPageId fullId : pageIds) {
                     long cpStart = System.nanoTime();
 
-                    Integer tag = mem.getForCheckpoint(fullId, tmpBuf);
+                    Integer tag = mem.getForCheckpoint(fullId, tmpBuf, null);
 
                     if (tag == null)
                         continue;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
index 4cfc14f..b533ed1 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache.database.pagemem;
 
 import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
 import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
 import org.apache.ignite.internal.pagemem.FullPageId;
@@ -25,6 +26,7 @@ import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
 import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
 import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager;
@@ -96,7 +98,9 @@ public class BPlusTreeReuseListPageMemoryImplSelfTest extends BPlusTreeReuseSelf
                 @Override public boolean checkpointLockIsHeldByThread() {
                     return true;
                 }
-            });
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration())
+        );
 
         mem.start();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
index 82b2de4..1eab1f8 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache.database.pagemem;
 
 import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
 import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
 import org.apache.ignite.internal.pagemem.FullPageId;
@@ -25,6 +26,7 @@ import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
 import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
 import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager;
@@ -96,7 +98,8 @@ public class BPlusTreeSelfTestPageMemoryImplSelfTest extends BPlusTreeSelfTest
{
                 @Override public boolean checkpointLockIsHeldByThread() {
                     return true;
                 }
-            });
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
 
         mem.start();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
index 11e0386..c9c6c18 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.database.pagemem;
 
 import java.io.File;
 import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
 import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
 import org.apache.ignite.internal.pagemem.FullPageId;
@@ -26,6 +27,7 @@ import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
 import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
 import org.apache.ignite.internal.processors.database.MetadataStorageSelfTest;
@@ -96,6 +98,7 @@ public class MetadataStoragePageMemoryImplSelfTest extends MetadataStorageSelfTe
                 @Override public boolean checkpointLockIsHeldByThread() {
                     return true;
                 }
-            });
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java
index fec5b08..f3e1cd3 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpWALManager.java
@@ -120,4 +120,9 @@ public class NoOpWALManager implements IgniteWriteAheadLogManager {
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException
{
 
     }
+
+    /** {@inheritDoc} */
+    @Override public int walArchiveSegments() {
+        return 0;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
index 141ce82..8ff5345 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.database.pagemem;
 
 import java.io.File;
 import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
 import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
 import org.apache.ignite.internal.pagemem.FullPageId;
@@ -26,6 +27,7 @@ import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.pagemem.impl.PageMemoryNoLoadSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
 import org.apache.ignite.internal.util.lang.GridInClosure3X;
@@ -87,7 +89,8 @@ public class PageMemoryImplNoLoadSelfTest extends PageMemoryNoLoadSelfTest
{
                 @Override public boolean checkpointLockIsHeldByThread() {
                     return true;
                 }
-            });
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java
b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java
index bbcd383..b5e4549 100644
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache.database.pagemem;
 
 import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
 import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
 import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
@@ -26,6 +27,7 @@ import org.apache.ignite.internal.pagemem.PageIdAllocator;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
 import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
 import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
 import org.apache.ignite.internal.util.lang.GridInClosure3X;
@@ -109,7 +111,8 @@ public class PageMemoryImplTest extends GridCommonAbstractTest {
                 @Override public boolean checkpointLockIsHeldByThread() {
                     return true;
                 }
-            });
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
 
         mem.start();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
index 88d4d0d..1f45c25 100644
--- a/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
+++ b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.cache.database.IgnitePersistenceMetricsSelfTest;
 import org.apache.ignite.cache.database.IgnitePersistentStoreAtomicCacheRebalancingTest;
 import org.apache.ignite.cache.database.IgnitePersistentStoreContinuousRestartSelfTest;
 import org.apache.ignite.cache.database.IgnitePersistentStoreDataStructuresTest;
@@ -34,6 +35,7 @@ import org.apache.ignite.cache.database.db.file.IgniteWalHistoryReservationsSelf
 import org.apache.ignite.cache.database.db.file.IgniteWalRecoverySelfTest;
 import org.apache.ignite.cache.database.db.file.WalRecoveryTxLogicalRecordsTest;
 import org.apache.ignite.cache.database.db.wal.crc.IgniteDataIntegrityTests;
+import org.apache.ignite.internal.pagemem.impl.PageMemoryNoLoadSelfTest;
 
 /**
  *
@@ -46,11 +48,14 @@ public class IgnitePdsTestSuite2 extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Ignite persistent Store Test Suite");
 
-        // Integrity test
+        // Integrity test.
         suite.addTestSuite(IgniteDataIntegrityTests.class);
         suite.addTestSuite(IgnitePersistentStoreRecoveryAfterFileCorruptionTest.class);
         suite.addTestSuite(IgnitePersistentStorePageSizesTest.class);
 
+        // Metrics test.
+        suite.addTestSuite(IgnitePersistenceMetricsSelfTest.class);
+
         // WAL recovery test.
         suite.addTestSuite(WalRecoveryTxLogicalRecordsTest.class);
         suite.addTestSuite(IgniteWalRecoverySelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/fffad68f/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index 094c2dc..ba4811c 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -286,6 +286,13 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     }
 
     /** {@inheritDoc} */
+    @Override public PersistenceMetrics persistentStoreMetrics() {
+        checkIgnite();
+
+        return g.persistentStoreMetrics();
+    }
+
+    /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> cache(@Nullable String name) {
         checkIgnite();
 


Mime
View raw message