ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [46/47] ignite git commit: IGNITE-5267 - Moved ignite-ps module to ignite-core
Date Sun, 11 Jun 2017 20:04:12 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRow.java
deleted file mode 100644
index cc26b21..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRow.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-
-/**
- * Cache data row.
- */
-public interface CacheDataRow extends CacheSearchRow {
-    /**
-     * @return Cache value.
-     */
-    public CacheObject value();
-
-    /**
-     * @return Cache entry version.
-     */
-    public GridCacheVersion version();
-
-    /**
-     * @return Expire time.
-     */
-    public long expireTime();
-
-    /**
-     * @return Partition for this key.
-     */
-    public int partition();
-
-    /**
-     * @param link Link for this row.
-     */
-    public void link(long link);
-
-    /**
-     * @param key Key.
-     */
-    public void key(KeyCacheObject key);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
deleted file mode 100644
index a25d794..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.pagemem.PageIdUtils;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.PageUtils;
-import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.IncompleteCacheObject;
-import org.apache.ignite.internal.processors.cache.IncompleteObject;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.database.tree.io.CacheVersionIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.DataPageIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.DataPagePayload;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.internal.pagemem.PageIdUtils.itemId;
-import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId;
-
-/**
- * Cache data row adapter.
- */
-public class CacheDataRowAdapter implements CacheDataRow {
-    /** */
-    @GridToStringExclude
-    protected long link;
-
-    /** */
-    @GridToStringInclude
-    protected KeyCacheObject key;
-
-    /** */
-    @GridToStringInclude
-    protected CacheObject val;
-
-    /** */
-    protected long expireTime = -1;
-
-    /** */
-    @GridToStringInclude
-    protected GridCacheVersion ver;
-
-    /** */
-    @GridToStringInclude
-    protected int cacheId;
-
-    /**
-     * @param link Link.
-     */
-    public CacheDataRowAdapter(long link) {
-        // Link can be 0 here.
-        this.link = link;
-    }
-
-    /**
-     * @param key Key.
-     * @param val Value.
-     * @param expireTime Expire time.
-     * @param ver Version.
-     */
-    public CacheDataRowAdapter(KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime) {
-        this.key = key;
-        this.val = val;
-        this.ver = ver;
-        this.expireTime = expireTime;
-    }
-
-    /**
-     * Read row from data pages.
-     *
-     * @param grp Cache group.
-     * @param rowData Required row data.
-     * @throws IgniteCheckedException If failed.
-     */
-    public final void initFromLink(CacheGroupContext grp, RowData rowData) throws IgniteCheckedException {
-        initFromLink(grp, grp.shared(), grp.memoryPolicy().pageMemory(), rowData);
-    }
-
-    /**
-     * Read row from data pages.
-     * Can be called with cctx == null, if cache instance is unknown, but its ID is stored in the data row.
-     *
-     * @param grp Cache group.
-     * @param sharedCtx Shared context.
-     * @param pageMem Page memory.
-     * @param rowData Row data.
-     * @throws IgniteCheckedException If failed.
-     */
-    public final void initFromLink(
-        @Nullable CacheGroupContext grp,
-        GridCacheSharedContext<?, ?> sharedCtx,
-        PageMemory pageMem,
-        RowData rowData)
-        throws IgniteCheckedException {
-        assert link != 0 : "link";
-        assert key == null : "key";
-
-        CacheObjectContext coctx = grp != null ?  grp.cacheObjectContext() : null;
-
-        boolean readCacheId = grp == null || grp.storeCacheIdInDataPage();
-
-        long nextLink = link;
-        IncompleteObject<?> incomplete = null;
-        boolean first = true;
-
-        do {
-            final long pageId = pageId(nextLink);
-
-            // Group is null if try evict page, with persistence evictions should be disabled.
-            assert grp != null || !sharedCtx.database().persistenceEnabled();
-
-            int grpId = grp != null ? grp.groupId() : 0;
-
-            final long page = pageMem.acquirePage(grpId, pageId);
-
-            try {
-                long pageAddr = pageMem.readLock(grpId, pageId, page); // Non-empty data page must not be recycled.
-
-                assert pageAddr != 0L : nextLink;
-
-                try {
-                    DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
-
-                    DataPagePayload data = io.readPayload(pageAddr,
-                        itemId(nextLink),
-                        pageMem.pageSize());
-
-                    nextLink = data.nextLink();
-
-                    if (first) {
-                        if (nextLink == 0) {
-                            // Fast path for a single page row.
-                            readFullRow(sharedCtx, coctx, pageAddr + data.offset(), rowData, readCacheId);
-
-                            return;
-                        }
-
-                        first = false;
-                    }
-
-                    ByteBuffer buf = pageMem.pageBuffer(pageAddr);
-
-                    buf.position(data.offset());
-                    buf.limit(data.offset() + data.payloadSize());
-
-                    boolean keyOnly = rowData == RowData.KEY_ONLY;
-
-                    incomplete = readFragment(sharedCtx, coctx, buf, keyOnly, readCacheId, incomplete);
-
-                    if (keyOnly && key != null)
-                        return;
-                }
-                finally {
-                    pageMem.readUnlock(grpId, pageId, page);
-                }
-            }
-            finally {
-                pageMem.releasePage(grpId, pageId, page);
-            }
-        }
-        while(nextLink != 0);
-
-        assert isReady() : "ready";
-    }
-
-    /**
-     * @param sharedCtx Cache shared context.
-     * @param coctx Cache object context.
-     * @param buf Buffer.
-     * @param keyOnly {@code true} If need to read only key object.
-     * @param readCacheId {@code true} If need to read cache ID.
-     * @param incomplete Incomplete object.
-     * @throws IgniteCheckedException If failed.
-     * @return Read object.
-     */
-    private IncompleteObject<?> readFragment(
-        GridCacheSharedContext<?, ?> sharedCtx,
-        CacheObjectContext coctx,
-        ByteBuffer buf,
-        boolean keyOnly,
-        boolean readCacheId,
-        IncompleteObject<?> incomplete
-    ) throws IgniteCheckedException {
-        if (readCacheId && cacheId == 0) {
-            incomplete = readIncompleteCacheId(buf, incomplete);
-
-            if (cacheId == 0)
-                return incomplete;
-
-            incomplete = null;
-        }
-
-        if (coctx == null) {
-            // coctx can be null only when grp is null too, this means that
-            // we are in process of eviction and cacheId is mandatory part of data.
-            assert cacheId != 0;
-
-            coctx = sharedCtx.cacheContext(cacheId).cacheObjectContext();
-        }
-
-        // Read key.
-        if (key == null) {
-            incomplete = readIncompleteKey(coctx, buf, (IncompleteCacheObject)incomplete);
-
-            if (key == null || keyOnly)
-                return incomplete;
-
-            incomplete = null;
-        }
-
-        if (expireTime == -1) {
-            incomplete = readIncompleteExpireTime(buf, incomplete);
-
-            if (expireTime == -1)
-                return incomplete;
-
-            incomplete = null;
-        }
-
-        // Read value.
-        if (val == null) {
-            incomplete = readIncompleteValue(coctx, buf, (IncompleteCacheObject)incomplete);
-
-            if (val == null)
-                return incomplete;
-
-            incomplete = null;
-        }
-
-        // Read version.
-        if (ver == null)
-            incomplete = readIncompleteVersion(buf, incomplete);
-
-        return incomplete;
-    }
-
-    /**
-     * @param sharedCtx Cache shared context.
-     * @param coctx Cache object context.
-     * @param addr Address.
-     * @param rowData Required row data.
-     * @param readCacheId {@code true} If need to read cache ID.
-     * @throws IgniteCheckedException If failed.
-     */
-    private void readFullRow(
-        GridCacheSharedContext<?, ?> sharedCtx,
-        CacheObjectContext coctx,
-        long addr,
-        RowData rowData,
-        boolean readCacheId)
-        throws IgniteCheckedException {
-        int off = 0;
-
-        if (readCacheId) {
-            cacheId = PageUtils.getInt(addr, off);
-
-            off += 4;
-        }
-
-        if (coctx == null)
-            coctx = sharedCtx.cacheContext(cacheId).cacheObjectContext();
-
-        int len = PageUtils.getInt(addr, off);
-        off += 4;
-
-        if (rowData != RowData.NO_KEY) {
-            byte type = PageUtils.getByte(addr, off);
-            off++;
-
-            byte[] bytes = PageUtils.getBytes(addr, off, len);
-            off += len;
-
-            key = coctx.kernalContext().cacheObjects().toKeyCacheObject(coctx, type, bytes);
-
-            if (rowData == RowData.KEY_ONLY)
-                return;
-        }
-        else
-            off += len + 1;
-
-        len = PageUtils.getInt(addr, off);
-        off += 4;
-
-        byte type = PageUtils.getByte(addr, off);
-        off++;
-
-        byte[] bytes = PageUtils.getBytes(addr, off, len);
-        off += len;
-
-        val = coctx.kernalContext().cacheObjects().toCacheObject(coctx, type, bytes);
-
-        ver = CacheVersionIO.read(addr + off, false);
-
-        off += CacheVersionIO.size(ver, false);
-
-        expireTime = PageUtils.getLong(addr, off);
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param incomplete Incomplete.
-     */
-    private IncompleteObject<?> readIncompleteCacheId(
-        ByteBuffer buf,
-        IncompleteObject<?> incomplete
-    ) {
-        if (incomplete == null) {
-            int remaining = buf.remaining();
-
-            if (remaining == 0)
-                return null;
-
-            int size = 4;
-
-            if (remaining >= size) {
-                cacheId = buf.getInt();
-
-                assert cacheId != 0;
-
-                return null;
-            }
-
-            incomplete = new IncompleteObject<>(new byte[size]);
-        }
-
-        incomplete.readData(buf);
-
-        if (incomplete.isReady()) {
-            final ByteBuffer timeBuf = ByteBuffer.wrap(incomplete.data());
-
-            timeBuf.order(buf.order());
-
-            cacheId = timeBuf.getInt();
-
-            assert cacheId != 0;
-        }
-
-        return incomplete;
-    }
-
-    /**
-     * @param coctx Cache object context.
-     * @param buf Buffer.
-     * @param incomplete Incomplete object.
-     * @return Incomplete object.
-     * @throws IgniteCheckedException If failed.
-     */
-    private IncompleteCacheObject readIncompleteKey(
-        CacheObjectContext coctx,
-        ByteBuffer buf,
-        IncompleteCacheObject incomplete
-    ) throws IgniteCheckedException {
-        incomplete = coctx.kernalContext().cacheObjects().toKeyCacheObject(coctx, buf, incomplete);
-
-        if (incomplete.isReady()) {
-            key = (KeyCacheObject)incomplete.object();
-
-            assert key != null;
-        }
-        else
-            assert !buf.hasRemaining();
-
-        return incomplete;
-    }
-
-    /**
-     * @param coctx Cache object context.
-     * @param buf Buffer.
-     * @param incomplete Incomplete object.
-     * @return Incomplete object.
-     * @throws IgniteCheckedException If failed.
-     */
-    private IncompleteCacheObject readIncompleteValue(
-        CacheObjectContext coctx,
-        ByteBuffer buf,
-        IncompleteCacheObject incomplete
-    ) throws IgniteCheckedException {
-        incomplete = coctx.kernalContext().cacheObjects().toCacheObject(coctx, buf, incomplete);
-
-        if (incomplete.isReady()) {
-            val = incomplete.object();
-
-            assert val != null;
-        }
-        else
-            assert !buf.hasRemaining();
-
-        return incomplete;
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param incomplete Incomplete object.
-     * @return Incomplete object.
-     */
-    private IncompleteObject<?> readIncompleteExpireTime(
-        ByteBuffer buf,
-        IncompleteObject<?> incomplete
-    ) {
-        if (incomplete == null) {
-            int remaining = buf.remaining();
-
-            if (remaining == 0)
-                return null;
-
-            int size = 8;
-
-            if (remaining >= size) {
-                expireTime = buf.getLong();
-
-                assert expireTime >= 0 : expireTime;
-
-                return null;
-            }
-
-            incomplete = new IncompleteObject<>(new byte[size]);
-        }
-
-        incomplete.readData(buf);
-
-        if (incomplete.isReady()) {
-            final ByteBuffer timeBuf = ByteBuffer.wrap(incomplete.data());
-
-            timeBuf.order(buf.order());
-
-            expireTime = timeBuf.getLong();
-
-            assert expireTime >= 0;
-        }
-
-        return incomplete;
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param incomplete Incomplete object.
-     * @return Incomplete object.
-     * @throws IgniteCheckedException If failed.
-     */
-    private IncompleteObject<?> readIncompleteVersion(
-        ByteBuffer buf,
-        IncompleteObject<?> incomplete
-    ) throws IgniteCheckedException {
-        if (incomplete == null) {
-            int remaining = buf.remaining();
-
-            if (remaining == 0)
-                return null;
-
-            int size = CacheVersionIO.readSize(buf, false);
-
-            if (remaining >= size) {
-                // If the whole version is on a single page, just read it.
-                ver = CacheVersionIO.read(buf, false);
-
-                assert !buf.hasRemaining(): buf.remaining();
-                assert ver != null;
-
-                return null;
-            }
-
-            // We have to read multipart version.
-            incomplete = new IncompleteObject<>(new byte[size]);
-        }
-
-        incomplete.readData(buf);
-
-        if (incomplete.isReady()) {
-            final ByteBuffer verBuf = ByteBuffer.wrap(incomplete.data());
-
-            verBuf.order(buf.order());
-
-            ver = CacheVersionIO.read(verBuf, false);
-
-            assert ver != null;
-        }
-
-        assert !buf.hasRemaining();
-
-        return incomplete;
-    }
-
-    /**
-     * @return {@code True} if entry is ready.
-     */
-    public boolean isReady() {
-        return ver != null && val != null && key != null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public KeyCacheObject key() {
-        assert key != null : "Key is not ready: " + this;
-
-        return key;
-    }
-
-    /**
-     * @param key Key.
-     */
-    @Override public void key(KeyCacheObject key) {
-        assert key != null;
-
-        this.key = key;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int cacheId() {
-        return cacheId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheObject value() {
-        assert val != null : "Value is not ready: " + this;
-
-        return val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheVersion version() {
-        assert ver != null : "Version is not ready: " + this;
-
-        return ver;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long expireTime() {
-        return expireTime;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int partition() {
-        return PageIdUtils.partId(link);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long link() {
-        return link;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void link(long link) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hash() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     *
-     */
-    public enum RowData {
-        /** */
-        FULL,
-
-        /** */
-        KEY_ONLY,
-
-        /** */
-        NO_KEY
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(CacheDataRowAdapter.class, this, "link", U.hexLong(link));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheSearchRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheSearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheSearchRow.java
deleted file mode 100644
index 6e429c4..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheSearchRow.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-
-/**
- *
- */
-public interface CacheSearchRow {
-    /**
-     * @return Cache key.
-     */
-    public KeyCacheObject key();
-
-    /**
-     * @return Link for this row.
-     */
-    public long link();
-
-    /**
-     * @return Key hash code.
-     */
-    public int hash();
-
-    /**
-     * @return Cache ID or {@code 0} if cache ID is not defined.
-     */
-    public int cacheId();
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CheckpointLockStateChecker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CheckpointLockStateChecker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CheckpointLockStateChecker.java
deleted file mode 100644
index df90f33..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CheckpointLockStateChecker.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-/**
- * Interface for perform checking that checkpoint lock is held by current track
- */
-public interface CheckpointLockStateChecker {
-    /**
-     * @return true if checkpoint lock is held by current thread
-     */
-    public boolean checkpointLockIsHeldByThread();
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
deleted file mode 100644
index 0e35bf4..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import java.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.pagemem.PageIdAllocator;
-import org.apache.ignite.internal.pagemem.PageIdUtils;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
-import org.apache.ignite.internal.pagemem.wal.record.delta.RecycleRecord;
-import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
-import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseBag;
-import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
-import org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler;
-import org.apache.ignite.internal.processors.cache.database.tree.util.PageLockListener;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.MAX_PARTITION_ID;
-
-/**
- * Base class for all the data structures based on {@link PageMemory}.
- */
-public abstract class DataStructure implements PageLockListener {
-    /** For tests. */
-    public static Random rnd;
-
-    /** */
-    protected final int cacheId;
-
-    /** */
-    protected final PageMemory pageMem;
-
-    /** */
-    protected final IgniteWriteAheadLogManager wal;
-
-    /** */
-    protected ReuseList reuseList;
-
-    /**
-     * @param cacheId Cache ID.
-     * @param pageMem Page memory.
-     * @param wal Write ahead log manager.
-     */
-    public DataStructure(
-        int cacheId,
-        PageMemory pageMem,
-        IgniteWriteAheadLogManager wal
-    ) {
-        assert pageMem != null;
-
-        this.cacheId = cacheId;
-        this.pageMem = pageMem;
-        this.wal = wal;
-    }
-
-    /**
-     * @return Cache ID.
-     */
-    public final int getCacheId() {
-        return cacheId;
-    }
-
-    /**
-     * @param max Max.
-     * @return Random value from {@code 0} (inclusive) to the given max value (exclusive).
-     */
-    public static int randomInt(int max) {
-        Random rnd0 = rnd != null ? rnd : ThreadLocalRandom.current();
-
-        return rnd0.nextInt(max);
-    }
-
-    /**
-     * @param bag Reuse bag.
-     * @return Allocated page.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final long allocatePage(ReuseBag bag) throws IgniteCheckedException {
-        long pageId = bag != null ? bag.pollFreePage() : 0;
-
-        if (pageId == 0 && reuseList != null)
-            pageId = reuseList.takeRecycledPage();
-
-        if (pageId == 0)
-            pageId = allocatePageNoReuse();
-
-        assert pageId != 0;
-
-        return pageId;
-    }
-
-    /**
-     * @return Page ID of newly allocated page.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected long allocatePageNoReuse() throws IgniteCheckedException {
-        return pageMem.allocatePage(cacheId, PageIdAllocator.INDEX_PARTITION, FLAG_IDX);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @return Page absolute pointer.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final long acquirePage(long pageId) throws IgniteCheckedException {
-        assert PageIdUtils.flag(pageId) == FLAG_IDX && PageIdUtils.partId(pageId) == INDEX_PARTITION ||
-            PageIdUtils.flag(pageId) == FLAG_DATA && PageIdUtils.partId(pageId) <= MAX_PARTITION_ID : U.hexLong(pageId);
-
-        return pageMem.acquirePage(cacheId, pageId);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param page  Page pointer.
-     */
-    protected final void releasePage(long pageId, long page) {
-        pageMem.releasePage(cacheId, pageId, page);
-    }
-
-    /**
-     * @param pageId Page ID
-     * @param page Page pointer.
-     * @return Page address or {@code 0} if failed to lock due to recycling.
-     */
-    protected final long tryWriteLock(long pageId, long page) {
-        return PageHandler.writeLock(pageMem, cacheId, pageId, page, this, true);
-    }
-
-    /**
-     * @param pageId Page ID
-     * @param page Page pointer.
-     * @return Page address.
-     */
-    protected final long writeLock(long pageId, long page) {
-        return PageHandler.writeLock(pageMem, cacheId, pageId, page, this, false);
-    }
-
-    /**
-     * <p>
-     * Note: Default WAL record policy will be used.
-     * </p>
-     * @param pageId Page ID
-     * @param page Page pointer.
-     * @param pageAddr Page address.
-     * @param dirty Dirty flag.
-     */
-    protected final void writeUnlock(long pageId, long page, long pageAddr, boolean dirty) {
-        writeUnlock(pageId, page, pageAddr, null, dirty);
-    }
-
-    /**
-     * @param pageId Page ID
-     * @param page Page pointer.
-     * @return Page address.
-     */
-    protected final long readLock(long pageId, long page) {
-        return PageHandler.readLock(pageMem, cacheId, pageId, page, this);
-    }
-
-    /**
-     * @param pageId Page ID
-     * @param page Page pointer.
-     * @param pageAddr  Page address.
-     */
-    protected final void readUnlock(long pageId, long page, long pageAddr) {
-        PageHandler.readUnlock(pageMem, cacheId, pageId, page, pageAddr, this);
-    }
-
-    /**
-     * @param pageId Page ID
-     * @param page Page pointer.
-     * @param pageAddr  Page address.
-     * @param walPlc Full page WAL record policy.
-     * @param dirty Dirty flag.
-     */
-    protected final void writeUnlock(long pageId, long page, long pageAddr, Boolean walPlc, boolean dirty) {
-        PageHandler.writeUnlock(pageMem, cacheId, pageId, page, pageAddr, this, walPlc, dirty);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param page Page pointer.
-     * @param walPlc Full page WAL record policy.
-     * @return {@code true} If we need to make a delta WAL record for the change in this page.
-     */
-    protected final boolean needWalDeltaRecord(long pageId, long page, Boolean walPlc) {
-        return PageHandler.isWalDeltaRecordNeeded(pageMem, cacheId, pageId, page, wal, walPlc);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param h Handler.
-     * @param intArg Argument of type {@code int}.
-     * @param lockFailed Result in case of lock failure due to page recycling.
-     * @return Handler result.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final <R> R write(
-        long pageId,
-        PageHandler<?, R> h,
-        int intArg,
-        R lockFailed) throws IgniteCheckedException {
-        return PageHandler.writePage(pageMem, cacheId, pageId, this, h, null, null, null, null, intArg, lockFailed);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param h Handler.
-     * @param arg Argument.
-     * @param intArg Argument of type {@code int}.
-     * @param lockFailed Result in case of lock failure due to page recycling.
-     * @return Handler result.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final <X, R> R write(
-        long pageId,
-        PageHandler<X, R> h,
-        X arg,
-        int intArg,
-        R lockFailed) throws IgniteCheckedException {
-        return PageHandler.writePage(pageMem, cacheId, pageId, this, h, null, null, null, arg, intArg, lockFailed);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param page Page pointer.
-     * @param h Handler.
-     * @param arg Argument.
-     * @param intArg Argument of type {@code int}.
-     * @param lockFailed Result in case of lock failure due to page recycling.
-     * @return Handler result.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final <X, R> R write(
-        long pageId,
-        long page,
-        PageHandler<X, R> h,
-        X arg,
-        int intArg,
-        R lockFailed) throws IgniteCheckedException {
-        return PageHandler.writePage(pageMem, cacheId, pageId, page, this, h, null, null, null, arg, intArg, lockFailed);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param h Handler.
-     * @param init IO for new page initialization or {@code null} if it is an existing page.
-     * @param arg Argument.
-     * @param intArg Argument of type {@code int}.
-     * @param lockFailed Result in case of lock failure due to page recycling.
-     * @return Handler result.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final <X, R> R write(
-        long pageId,
-        PageHandler<X, R> h,
-        PageIO init,
-        X arg,
-        int intArg,
-        R lockFailed) throws IgniteCheckedException {
-        return PageHandler.writePage(pageMem, cacheId, pageId, this, h, init, wal, null, arg, intArg, lockFailed);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param h Handler.
-     * @param arg Argument.
-     * @param intArg Argument of type {@code int}.
-     * @param lockFailed Result in case of lock failure due to page recycling.
-     * @return Handler result.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final <X, R> R read(
-        long pageId,
-        PageHandler<X, R> h,
-        X arg,
-        int intArg,
-        R lockFailed) throws IgniteCheckedException {
-        return PageHandler.readPage(pageMem, cacheId, pageId, this, h, arg, intArg, lockFailed);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param page Page pointer.
-     * @param h Handler.
-     * @param arg Argument.
-     * @param intArg Argument of type {@code int}.
-     * @param lockFailed Result in case of lock failure due to page recycling.
-     * @return Handler result.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final <X, R> R read(
-        long pageId,
-        long page,
-        PageHandler<X, R> h,
-        X arg,
-        int intArg,
-        R lockFailed) throws IgniteCheckedException {
-        return PageHandler.readPage(pageMem, cacheId, pageId, page, this, h, arg, intArg, lockFailed);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param init IO for new page initialization.
-     * @throws IgniteCheckedException if failed.
-     */
-    protected final void init(long pageId, PageIO init) throws IgniteCheckedException {
-        PageHandler.initPage(pageMem, cacheId, pageId, init, wal, this);
-    }
-
-    /**
-     * @param pageId Page ID.
-     * @param page Page pointer.
-     * @param pageAddr Page address.
-     * @param walPlc Full page WAL record policy.
-     * @return Rotated page ID.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final long recyclePage(
-        long pageId,
-        long page,
-        long pageAddr,
-        Boolean walPlc) throws IgniteCheckedException {
-        long rotated = PageIdUtils.rotatePageId(pageId);
-
-        PageIO.setPageId(pageAddr, rotated);
-
-        if (needWalDeltaRecord(pageId, page, walPlc))
-            wal.log(new RecycleRecord(cacheId, pageId, rotated));
-
-        return rotated;
-    }
-
-    /**
-     * @return Page size.
-     */
-    protected final int pageSize() {
-        return pageMem.pageSize();
-    }
-
-    @Override public void onBeforeWriteLock(int cacheId, long pageId, long page) {
-        // No-op.
-    }
-
-    @Override public void onWriteLock(int cacheId, long pageId, long page, long pageAddr) {
-        // No-op.
-    }
-
-    @Override public void onWriteUnlock(int cacheId, long pageId, long page, long pageAddr) {
-        // No-op.
-    }
-
-    @Override public void onBeforeReadLock(int cacheId, long pageId, long page) {
-        // No-op.
-    }
-
-    @Override public void onReadLock(int cacheId, long pageId, long page, long pageAddr) {
-        // No-op.
-    }
-
-    @Override public void onReadUnlock(int cacheId, long pageId, long page, long pageAddr) {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
deleted file mode 100644
index a4ca5d2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ /dev/null
@@ -1,968 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import javax.management.JMException;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.MemoryMetrics;
-import org.apache.ignite.PersistenceMetrics;
-import org.apache.ignite.configuration.DataPageEvictionMode;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.MemoryConfiguration;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.mem.DirectMemoryProvider;
-import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
-import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl;
-import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
-import org.apache.ignite.internal.processors.cache.database.evict.FairFifoPageEvictionTracker;
-import org.apache.ignite.internal.processors.cache.database.evict.NoOpPageEvictionTracker;
-import org.apache.ignite.internal.processors.cache.database.evict.PageEvictionTracker;
-import org.apache.ignite.internal.processors.cache.database.evict.Random2LruPageEvictionTracker;
-import org.apache.ignite.internal.processors.cache.database.evict.RandomLruPageEvictionTracker;
-import org.apache.ignite.internal.processors.cache.database.freelist.FreeList;
-import org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl;
-import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
-import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.LT;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.mxbean.MemoryMetricsMXBean;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE;
-import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
-
-/**
- *
- */
-public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdapter
-    implements IgniteChangeGlobalStateSupport, CheckpointLockStateChecker {
-    /** MemoryPolicyConfiguration name reserved for internal caches. */
-    static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
-
-    /** Minimum size of memory chunk */
-    private static final long MIN_PAGE_MEMORY_SIZE = 10 * 1024 * 1024;
-
-    /** Maximum initial size on 32-bit JVM */
-    private static final long MAX_PAGE_MEMORY_INIT_SIZE_32_BIT = 2L * 1024 * 1024 * 1024;
-
-    /** */
-    protected Map<String, MemoryPolicy> memPlcMap;
-
-    /** */
-    protected Map<String, MemoryMetrics> memMetricsMap;
-
-    /** */
-    protected MemoryPolicy dfltMemPlc;
-
-    /** */
-    private Map<String, FreeListImpl> freeListMap;
-
-    /** */
-    private FreeListImpl dfltFreeList;
-
-    /** */
-    private int pageSize;
-
-    /** {@inheritDoc} */
-    @Override protected void start0() throws IgniteCheckedException {
-        if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getMemoryConfiguration() == null)
-            return;
-
-        init();
-    }
-
-    /**
-     * @throws IgniteCheckedException If failed.
-     */
-    public void init() throws IgniteCheckedException {
-        MemoryConfiguration memCfg = cctx.kernalContext().config().getMemoryConfiguration();
-
-        assert memCfg != null;
-
-        validateConfiguration(memCfg);
-
-        pageSize = memCfg.getPageSize();
-
-        initPageMemoryPolicies(memCfg);
-
-        //registerMetricsMBeans();
-
-        startMemoryPolicies();
-
-        initPageMemoryDataStructures(memCfg);
-    }
-
-    /**
-     * Registers MBeans for all MemoryMetrics configured in this instance.
-     */
-    private void registerMetricsMBeans() {
-        IgniteConfiguration cfg = cctx.gridConfig();
-
-        for (MemoryMetrics memMetrics : memMetricsMap.values()) {
-            MemoryPolicyConfiguration memPlcCfg = memPlcMap.get(memMetrics.getName()).config();
-
-            registerMetricsMBean((MemoryMetricsImpl)memMetrics, memPlcCfg, cfg);
-        }
-    }
-
-    /**
-     * @param memMetrics Memory metrics.
-     * @param memPlcCfg Memory policy configuration.
-     * @param cfg Ignite configuration.
-     */
-    private void registerMetricsMBean(
-        MemoryMetricsImpl memMetrics,
-        MemoryPolicyConfiguration memPlcCfg,
-        IgniteConfiguration cfg
-    ) {
-        try {
-            U.registerMBean(
-                    cfg.getMBeanServer(),
-                    cfg.getIgniteInstanceName(),
-                    "MemoryMetrics",
-                    memPlcCfg.getName(),
-                    new MemoryMetricsMXBeanImpl(memMetrics, memPlcCfg),
-                    MemoryMetricsMXBean.class);
-        }
-        catch (JMException e) {
-            U.error(log, "Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'", e);
-        }
-    }
-
-    /**
-     * @param dbCfg Database config.
-     */
-    protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
-        freeListMap = U.newHashMap(memPlcMap.size());
-
-        String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
-
-        for (MemoryPolicy memPlc : memPlcMap.values()) {
-            MemoryPolicyConfiguration memPlcCfg = memPlc.config();
-
-            MemoryMetricsImpl memMetrics = (MemoryMetricsImpl) memMetricsMap.get(memPlcCfg.getName());
-
-            FreeListImpl freeList = new FreeListImpl(0,
-                    cctx.igniteInstanceName(),
-                    memMetrics,
-                    memPlc,
-                    null,
-                    cctx.wal(),
-                    0L,
-                    true);
-
-            memMetrics.freeList(freeList);
-
-            freeListMap.put(memPlcCfg.getName(), freeList);
-        }
-
-        dfltFreeList = freeListMap.get(dfltMemPlcName);
-    }
-
-    /**
-     * @return Size of page used for PageMemory regions.
-     */
-    public int pageSize() {
-        return pageSize;
-    }
-
-    /**
-     *
-     */
-    private void startMemoryPolicies() {
-        for (MemoryPolicy memPlc : memPlcMap.values()) {
-            memPlc.pageMemory().start();
-
-            memPlc.evictionTracker().start();
-        }
-    }
-
-    /**
-     * @param memCfg Database config.
-     */
-    protected void initPageMemoryPolicies(MemoryConfiguration memCfg) {
-        MemoryPolicyConfiguration[] memPlcsCfgs = memCfg.getMemoryPolicies();
-
-        if (memPlcsCfgs == null) {
-            //reserve place for default and system memory policies
-            memPlcMap = U.newHashMap(2);
-            memMetricsMap = U.newHashMap(2);
-
-            addMemoryPolicy(
-                memCfg,
-                memCfg.createDefaultPolicyConfig(),
-                DFLT_MEM_PLC_DEFAULT_NAME
-            );
-
-            U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
-        }
-        else {
-            String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
-
-            if (DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltMemPlcName) && !hasCustomDefaultMemoryPolicy(memPlcsCfgs)) {
-                //reserve additional place for default and system memory policies
-                memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
-                memMetricsMap = U.newHashMap(memPlcsCfgs.length + 2);
-
-                addMemoryPolicy(
-                    memCfg,
-                    memCfg.createDefaultPolicyConfig(),
-                    DFLT_MEM_PLC_DEFAULT_NAME
-                );
-
-                U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
-            }
-            else {
-                //reserve additional space for system memory policy only
-                memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
-                memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);
-            }
-
-            for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs)
-                addMemoryPolicy(memCfg, memPlcCfg, memPlcCfg.getName());
-        }
-
-        addMemoryPolicy(
-            memCfg,
-            createSystemMemoryPolicy(
-                memCfg.getSystemCacheInitialSize(),
-                memCfg.getSystemCacheMaxSize()
-            ),
-            SYSTEM_MEMORY_POLICY_NAME
-        );
-    }
-
-    /**
-     * @param memCfg Database config.
-     * @param memPlcCfg Memory policy config.
-     * @param memPlcName Memory policy name.
-     */
-    private void addMemoryPolicy(
-        MemoryConfiguration memCfg,
-        MemoryPolicyConfiguration memPlcCfg,
-        String memPlcName
-    ) {
-        String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
-
-        if (dfltMemPlcName == null)
-            dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
-
-        MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(memPlcCfg);
-
-        MemoryPolicy memPlc = initMemory(memCfg, memPlcCfg, memMetrics);
-
-        memPlcMap.put(memPlcName, memPlc);
-
-        memMetricsMap.put(memPlcName, memMetrics);
-
-        if (memPlcName.equals(dfltMemPlcName))
-            dfltMemPlc = memPlc;
-        else if (memPlcName.equals(DFLT_MEM_PLC_DEFAULT_NAME))
-            U.warn(log, "Memory Policy with name 'default' isn't used as a default. " +
-                    "Please check Memory Policies configuration.");
-    }
-
-    /**
-     * @param memPlcsCfgs User-defined memory policy configurations.
-     */
-    private boolean hasCustomDefaultMemoryPolicy(MemoryPolicyConfiguration[] memPlcsCfgs) {
-        for (MemoryPolicyConfiguration memPlcsCfg : memPlcsCfgs) {
-            if (DFLT_MEM_PLC_DEFAULT_NAME.equals(memPlcsCfg.getName()))
-                return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * @param dbCfg Database configuration.
-     * @param memPlcCfg MemoryPolicy configuration.
-     * @param memMetrics MemoryMetrics instance.
-     */
-    private MemoryPolicy createDefaultMemoryPolicy(MemoryConfiguration dbCfg, MemoryPolicyConfiguration memPlcCfg, MemoryMetricsImpl memMetrics) {
-        return initMemory(dbCfg, memPlcCfg, memMetrics);
-    }
-
-    /**
-     * @param sysCacheInitSize Initial size of PageMemory to be created for system cache.
-     * @param sysCacheMaxSize Maximum size of PageMemory to be created for system cache.
-     *
-     * @return {@link MemoryPolicyConfiguration configuration} of MemoryPolicy for system cache.
-     */
-    private MemoryPolicyConfiguration createSystemMemoryPolicy(long sysCacheInitSize, long sysCacheMaxSize) {
-        MemoryPolicyConfiguration res = new MemoryPolicyConfiguration();
-
-        res.setName(SYSTEM_MEMORY_POLICY_NAME);
-        res.setInitialSize(sysCacheInitSize);
-        res.setMaxSize(sysCacheMaxSize);
-
-        return res;
-    }
-
-    /**
-     * @param memCfg configuration to validate.
-     */
-    private void validateConfiguration(MemoryConfiguration memCfg) throws IgniteCheckedException {
-        MemoryPolicyConfiguration[] plcCfgs = memCfg.getMemoryPolicies();
-
-        Set<String> plcNames = (plcCfgs != null) ? U.<String>newHashSet(plcCfgs.length) : new HashSet<String>(0);
-
-        checkSystemMemoryPolicySizeConfiguration(
-            memCfg.getSystemCacheInitialSize(),
-            memCfg.getSystemCacheMaxSize()
-        );
-
-        if (plcCfgs != null) {
-            for (MemoryPolicyConfiguration plcCfg : plcCfgs) {
-                assert plcCfg != null;
-
-                checkPolicyName(plcCfg.getName(), plcNames);
-
-                checkPolicySize(plcCfg);
-
-                checkMetricsProperties(plcCfg);
-
-                checkPolicyEvictionProperties(plcCfg, memCfg);
-            }
-        }
-
-        checkDefaultPolicyConfiguration(
-            memCfg.getDefaultMemoryPolicyName(),
-            memCfg.getDefaultMemoryPolicySize(),
-            plcNames
-        );
-    }
-
-    /**
-     * @param plcCfg Memory policy config.
-     *
-     * @throws IgniteCheckedException if validation of memory metrics properties fails.
-     */
-    private static void checkMetricsProperties(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException {
-        if (plcCfg.getRateTimeInterval() <= 0)
-            throw new IgniteCheckedException("Rate time interval must be greater than zero " +
-                "(use MemoryPolicyConfiguration.rateTimeInterval property to adjust the interval) " +
-                "[name=" + plcCfg.getName() +
-                ", rateTimeInterval=" + plcCfg.getRateTimeInterval() + "]"
-            );
-        if (plcCfg.getSubIntervals() <= 0)
-            throw new IgniteCheckedException("Sub intervals must be greater than zero " +
-                "(use MemoryPolicyConfiguration.subIntervals property to adjust the sub intervals) " +
-                "[name=" + plcCfg.getName() +
-                ", subIntervals=" + plcCfg.getSubIntervals() + "]"
-            );
-
-        if (plcCfg.getRateTimeInterval() < 1_000)
-            throw new IgniteCheckedException("Rate time interval must be longer that 1 second (1_000 milliseconds) " +
-                "(use MemoryPolicyConfiguration.rateTimeInterval property to adjust the interval) " +
-                "[name=" + plcCfg.getName() +
-                ", rateTimeInterval=" + plcCfg.getRateTimeInterval() + "]");
-    }
-
-    /**
-     * @param sysCacheInitSize System cache initial size.
-     * @param sysCacheMaxSize System cache max size.
-     *
-     * @throws IgniteCheckedException In case of validation violation.
-     */
-    private static void checkSystemMemoryPolicySizeConfiguration(
-        long sysCacheInitSize,
-        long sysCacheMaxSize
-    ) throws IgniteCheckedException {
-        if (sysCacheInitSize < MIN_PAGE_MEMORY_SIZE)
-            throw new IgniteCheckedException("Initial size for system cache must have size more than 10MB (use " +
-                "MemoryConfiguration.systemCacheInitialSize property to set correct size in bytes) " +
-                "[size=" + U.readableSize(sysCacheInitSize, true) + ']'
-            );
-
-        if (U.jvm32Bit() && sysCacheInitSize > MAX_PAGE_MEMORY_INIT_SIZE_32_BIT)
-            throw new IgniteCheckedException("Initial size for system cache exceeds 2GB on 32-bit JVM (use " +
-                "MemoryPolicyConfiguration.systemCacheInitialSize property to set correct size in bytes " +
-                "or use 64-bit JVM) [size=" + U.readableSize(sysCacheInitSize, true) + ']'
-            );
-
-        if (sysCacheMaxSize < sysCacheInitSize)
-            throw new IgniteCheckedException("MaxSize of system cache must not be smaller than " +
-                "initialSize [initSize=" + U.readableSize(sysCacheInitSize, true) +
-                ", maxSize=" + U.readableSize(sysCacheMaxSize, true) + "]. " +
-                "Use MemoryConfiguration.systemCacheInitialSize/MemoryConfiguration.systemCacheMaxSize " +
-                "properties to set correct sizes in bytes."
-            );
-    }
-
-    /**
-     * @param dfltPlcName Default MemoryPolicy name.
-     * @param dfltPlcSize Default size of MemoryPolicy overridden by user (equals to -1 if wasn't specified by user).
-     * @param plcNames All MemoryPolicy names.
-     * @throws IgniteCheckedException In case of validation violation.
-     */
-    private static void checkDefaultPolicyConfiguration(
-        String dfltPlcName,
-        long dfltPlcSize,
-        Collection<String> plcNames
-    ) throws IgniteCheckedException {
-        if (dfltPlcSize != MemoryConfiguration.DFLT_MEMORY_POLICY_MAX_SIZE) {
-            if (!F.eq(dfltPlcName, MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME))
-                throw new IgniteCheckedException("User-defined MemoryPolicy configuration " +
-                    "and defaultMemoryPolicySize properties are set at the same time. " +
-                    "Delete either MemoryConfiguration.defaultMemoryPolicySize property " +
-                    "or user-defined default MemoryPolicy configuration");
-
-            if (dfltPlcSize < MIN_PAGE_MEMORY_SIZE)
-                throw new IgniteCheckedException("User-defined default MemoryPolicy size is less than 1MB. " +
-                        "Use MemoryConfiguration.defaultMemoryPolicySize property to set correct size.");
-
-            if (U.jvm32Bit() && dfltPlcSize > MAX_PAGE_MEMORY_INIT_SIZE_32_BIT)
-                throw new IgniteCheckedException("User-defined default MemoryPolicy size exceeds 2GB on 32-bit JVM " +
-                    "(use MemoryConfiguration.defaultMemoryPolicySize property to set correct size in bytes " +
-                    "or use 64-bit JVM) [size=" + U.readableSize(dfltPlcSize, true) + ']'
-                );
-        }
-
-        if (!DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltPlcName)) {
-            if (dfltPlcName.isEmpty())
-                throw new IgniteCheckedException("User-defined default MemoryPolicy name must be non-empty");
-
-            if (!plcNames.contains(dfltPlcName))
-                throw new IgniteCheckedException("User-defined default MemoryPolicy name " +
-                    "must be presented among configured MemoryPolices: " + dfltPlcName);
-        }
-    }
-
-    /**
-     * @param plcCfg MemoryPolicyConfiguration to validate.
-     * @throws IgniteCheckedException If config is invalid.
-     */
-    private void checkPolicySize(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException {
-        if (plcCfg.getInitialSize() < MIN_PAGE_MEMORY_SIZE)
-            throw new IgniteCheckedException("MemoryPolicy must have size more than 10MB (use " +
-                "MemoryPolicyConfiguration.initialSize property to set correct size in bytes) " +
-                "[name=" + plcCfg.getName() + ", size=" + U.readableSize(plcCfg.getInitialSize(), true) + "]"
-            );
-
-        if (plcCfg.getMaxSize() < plcCfg.getInitialSize()) {
-            // We will know for sure if initialSize has been changed if we compare Longs by "==".
-            if (plcCfg.getInitialSize() == DFLT_MEMORY_POLICY_INITIAL_SIZE) {
-                plcCfg.setInitialSize(plcCfg.getMaxSize());
-
-                LT.warn(log, "MemoryPolicy maxSize=" + U.readableSize(plcCfg.getMaxSize(), true) +
-                    " is smaller than defaultInitialSize=" +
-                    U.readableSize(MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE, true) +
-                    ", setting initialSize to " + U.readableSize(plcCfg.getMaxSize(), true));
-            }
-            else {
-                throw new IgniteCheckedException("MemoryPolicy maxSize must not be smaller than " +
-                    "initialSize [name=" + plcCfg.getName() +
-                    ", initSize=" + U.readableSize(plcCfg.getInitialSize(), true) +
-                    ", maxSize=" + U.readableSize(plcCfg.getMaxSize(), true) + ']');
-            }
-        }
-
-        if (U.jvm32Bit() && plcCfg.getInitialSize() > MAX_PAGE_MEMORY_INIT_SIZE_32_BIT)
-            throw new IgniteCheckedException("MemoryPolicy initialSize exceeds 2GB on 32-bit JVM (use " +
-                "MemoryPolicyConfiguration.initialSize property to set correct size in bytes or use 64-bit JVM) " +
-                "[name=" + plcCfg.getName() +
-                ", size=" + U.readableSize(plcCfg.getInitialSize(), true) + "]");
-    }
-
-    /**
-     * @param plcCfg MemoryPolicyConfiguration to validate.
-     * @param dbCfg Memory configuration.
-     * @throws IgniteCheckedException If config is invalid.
-     */
-    protected void checkPolicyEvictionProperties(MemoryPolicyConfiguration plcCfg, MemoryConfiguration dbCfg)
-        throws IgniteCheckedException {
-        if (plcCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED)
-            return;
-
-        if (plcCfg.getEvictionThreshold() < 0.5 || plcCfg.getEvictionThreshold() > 0.999) {
-            throw new IgniteCheckedException("Page eviction threshold must be between 0.5 and 0.999: " +
-                plcCfg.getName());
-        }
-
-        if (plcCfg.getEmptyPagesPoolSize() <= 10)
-            throw new IgniteCheckedException("Evicted pages pool size should be greater than 10: " + plcCfg.getName());
-
-        long maxPoolSize = plcCfg.getMaxSize() / dbCfg.getPageSize() / 10;
-
-        if (plcCfg.getEmptyPagesPoolSize() >= maxPoolSize) {
-            throw new IgniteCheckedException("Evicted pages pool size should be lesser than " + maxPoolSize +
-                ": " + plcCfg.getName());
-        }
-    }
-
-    /**
-     * @param plcName MemoryPolicy name to validate.
-     * @param observedNames Names of MemoryPolicies observed before.
-     * @throws IgniteCheckedException If config is invalid.
-     */
-    private static void checkPolicyName(String plcName, Collection<String> observedNames)
-        throws IgniteCheckedException {
-        if (plcName == null || plcName.isEmpty())
-            throw new IgniteCheckedException("User-defined MemoryPolicyConfiguration must have non-null and " +
-                "non-empty name.");
-
-        if (observedNames.contains(plcName))
-            throw new IgniteCheckedException("Two MemoryPolicies have the same name: " + plcName);
-
-        if (SYSTEM_MEMORY_POLICY_NAME.equals(plcName))
-            throw new IgniteCheckedException("'sysMemPlc' policy name is reserved for internal use.");
-
-        observedNames.add(plcName);
-    }
-
-    /**
-     * @param log Logger.
-     */
-    public void dumpStatistics(IgniteLogger log) {
-        if (freeListMap != null) {
-            for (FreeListImpl freeList : freeListMap.values())
-                freeList.dumpStatistics(log);
-        }
-    }
-
-    /**
-     * @throws IgniteCheckedException If failed.
-     */
-    public void initDataBase() throws IgniteCheckedException {
-        // No-op.
-    }
-
-    /**
-     * @return collection of all configured {@link MemoryPolicy policies}.
-     */
-    public Collection<MemoryPolicy> memoryPolicies() {
-        return memPlcMap != null ? memPlcMap.values() : null;
-    }
-
-    /**
-     * @return MemoryMetrics for all MemoryPolicies configured in Ignite instance.
-     */
-    public Collection<MemoryMetrics> memoryMetrics() {
-        if (!F.isEmpty(memMetricsMap)) {
-            // Intentionally return a collection copy to make it explicitly serializable.
-            Collection<MemoryMetrics> res = new ArrayList<>(memMetricsMap.size());
-
-            for (MemoryMetrics metrics : memMetricsMap.values())
-                res.add(new MemoryMetricsSnapshot(metrics));
-
-            return res;
-        }
-        else
-            return Collections.emptyList();
-    }
-
-    /**
-     * @return PersistenceMetrics if persistence is enabled or {@code null} otherwise.
-     */
-    public PersistenceMetrics persistentStoreMetrics() {
-        return null;
-    }
-
-    /**
-     * @param memPlcName Name of {@link MemoryPolicy} to obtain {@link MemoryMetrics} for.
-     * @return {@link MemoryMetrics} snapshot for specified {@link MemoryPolicy} or {@code null} if
-     * no {@link MemoryPolicy} is configured for specified name.
-     */
-    @Nullable public MemoryMetrics memoryMetrics(String memPlcName) {
-        if (!F.isEmpty(memMetricsMap)) {
-            MemoryMetrics memMetrics = memMetricsMap.get(memPlcName);
-
-            if (memMetrics == null)
-                return null;
-            else
-                return new MemoryMetricsSnapshot(memMetrics);
-        }
-        else
-            return null;
-    }
-
-    /**
-     * @param memPlcName Memory policy name.
-     * @return {@link MemoryPolicy} instance associated with a given {@link MemoryPolicyConfiguration}.
-     * @throws IgniteCheckedException in case of request for unknown MemoryPolicy.
-     */
-    public MemoryPolicy memoryPolicy(String memPlcName) throws IgniteCheckedException {
-        if (memPlcName == null)
-            return dfltMemPlc;
-
-        if (memPlcMap == null)
-            return null;
-
-        MemoryPolicy plc;
-
-        if ((plc = memPlcMap.get(memPlcName)) == null)
-            throw new IgniteCheckedException("Requested MemoryPolicy is not configured: " + memPlcName);
-
-        return plc;
-    }
-
-    /**
-     * @param memPlcName MemoryPolicyConfiguration name.
-     * @return {@link FreeList} instance associated with a given {@link MemoryPolicyConfiguration}.
-     */
-    public FreeList freeList(String memPlcName) {
-        if (memPlcName == null)
-            return dfltFreeList;
-
-        return freeListMap != null ? freeListMap.get(memPlcName) : null;
-    }
-
-    /**
-     * @param memPlcName MemoryPolicyConfiguration name.
-     * @return {@link ReuseList} instance associated with a given {@link MemoryPolicyConfiguration}.
-     */
-    public ReuseList reuseList(String memPlcName) {
-        if (memPlcName == null)
-            return dfltFreeList;
-
-        return freeListMap != null ? freeListMap.get(memPlcName) : null;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void stop0(boolean cancel) {
-        if (memPlcMap != null) {
-            for (MemoryPolicy memPlc : memPlcMap.values()) {
-                memPlc.pageMemory().stop();
-
-                memPlc.evictionTracker().stop();
-
-                IgniteConfiguration cfg = cctx.gridConfig();
-
-              /*  try {
-                    cfg.getMBeanServer().unregisterMBean(
-                        U.makeMBeanName(
-                            cfg.getIgniteInstanceName(),
-                            "MemoryMetrics",
-                            memPlc.memoryMetrics().getName()));
-                }
-                catch (JMException e) {
-                    U.error(log, "Failed to unregister MBean for memory metrics: " +
-                        memPlc.memoryMetrics().getName(), e);
-                }*/
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    public boolean persistenceEnabled() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean checkpointLockIsHeldByThread() {
-        return false;
-    }
-
-    /**
-     *
-     */
-    public void lock() throws IgniteCheckedException {
-
-    }
-
-    /**
-     *
-     */
-    public void unLock() {
-
-    }
-
-    /**
-     * No-op for non-persistent storage.
-     */
-    public void checkpointReadLock() {
-        // No-op.
-    }
-
-    /**
-     * No-op for non-persistent storage.
-     */
-    public void checkpointReadUnlock() {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    @Nullable public IgniteInternalFuture wakeupForCheckpoint(String reason) {
-        return null;
-    }
-
-    /**
-     * Waits until current state is checkpointed.
-     *
-     * @throws IgniteCheckedException If failed.
-     */
-    public void waitForCheckpoint(String reason) throws IgniteCheckedException {
-        // No-op
-    }
-
-    /**
-     * @param discoEvt Before exchange for the given discovery event.
-     */
-    public void beforeExchange(GridDhtPartitionsExchangeFuture discoEvt) throws IgniteCheckedException {
-        // No-op.
-    }
-
-    /**
-     * Needed action before any cache will stop
-     */
-    public void prepareCachesStop() {
-        // No-op.
-    }
-
-    /**
-     * @param stoppedGrps A collection of tuples (cache group, destroy flag).
-     */
-    public void onCacheGroupsStopped(Collection<IgniteBiTuple<CacheGroupContext, Boolean>> stoppedGrps) {
-        // No-op.
-    }
-
-    /**
-     * @param cctx Stopped cache context.
-     */
-    public void onCacheStop(GridCacheContext cctx) {
-        // No-op
-    }
-
-    /**
-     * @return Future that will be completed when indexes for given cache are restored.
-     */
-    @Nullable public IgniteInternalFuture indexRebuildFuture(int cacheId) {
-        return null;
-    }
-
-    /**
-     * Reserve update history for exchange.
-     *
-     * @return Reserved update counters per cache and partition.
-     */
-    public Map<Integer, Map<Integer, Long>> reserveHistoryForExchange() {
-        return Collections.emptyMap();
-    }
-
-    /**
-     * Release reserved update history.
-     */
-    public void releaseHistoryForExchange() {
-        // No-op
-    }
-
-    /**
-     * Reserve update history for preloading.
-     * @param grpId Cache group ID.
-     * @param partId Partition Id.
-     * @param cntr Update counter.
-     * @return True if successfully reserved.
-     */
-    public boolean reserveHistoryForPreloading(int grpId, int partId, long cntr) {
-        return false;
-    }
-
-    /**
-     * Release reserved update history.
-     */
-    public void releaseHistoryForPreloading() {
-        // No-op
-    }
-
-    /**
-     * See {@link GridCacheMapEntry#ensureFreeSpace()}
-     *
-     * @param memPlc Memory policy.
-     */
-    public void ensureFreeSpace(MemoryPolicy memPlc) throws IgniteCheckedException {
-        if (memPlc == null)
-            return;
-
-        MemoryPolicyConfiguration plcCfg = memPlc.config();
-
-        if (plcCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED)
-            return;
-
-        long memorySize = plcCfg.getMaxSize();
-
-        PageMemory pageMem = memPlc.pageMemory();
-
-        int sysPageSize = pageMem.systemPageSize();
-
-        FreeListImpl freeListImpl = freeListMap.get(plcCfg.getName());
-
-        for (;;) {
-            long allocatedPagesCnt = pageMem.loadedPages();
-
-            int emptyDataPagesCnt = freeListImpl.emptyDataPages();
-
-            boolean shouldEvict = allocatedPagesCnt > (memorySize / sysPageSize * plcCfg.getEvictionThreshold()) &&
-                emptyDataPagesCnt < plcCfg.getEmptyPagesPoolSize();
-
-            if (shouldEvict)
-                memPlc.evictionTracker().evictDataPage();
-            else
-                break;
-        }
-    }
-
-    /**
-     * @param memCfg memory configuration with common parameters.
-     * @param plcCfg memory policy with PageMemory specific parameters.
-     * @param memMetrics {@link MemoryMetrics} object to collect memory usage metrics.
-     * @return Memory policy instance.
-     */
-    private MemoryPolicy initMemory(
-        MemoryConfiguration memCfg,
-        MemoryPolicyConfiguration plcCfg,
-        MemoryMetricsImpl memMetrics
-    ) {
-        File allocPath = buildAllocPath(plcCfg);
-
-        DirectMemoryProvider memProvider = allocPath == null ?
-            new UnsafeMemoryProvider(log) :
-            new MappedFileMemoryProvider(
-                log,
-                allocPath);
-
-        PageMemory pageMem = createPageMemory(memProvider, memCfg, plcCfg, memMetrics);
-
-        return new MemoryPolicy(pageMem, plcCfg, memMetrics, createPageEvictionTracker(plcCfg, pageMem));
-    }
-
-    /**
-     * @param plc Memory Policy Configuration.
-     * @param pageMem Page memory.
-     */
-    private PageEvictionTracker createPageEvictionTracker(MemoryPolicyConfiguration plc, PageMemory pageMem) {
-        if (plc.getPageEvictionMode() == DataPageEvictionMode.DISABLED)
-            return new NoOpPageEvictionTracker();
-
-        assert pageMem instanceof PageMemoryNoStoreImpl : pageMem.getClass();
-
-        PageMemoryNoStoreImpl pageMem0 = (PageMemoryNoStoreImpl)pageMem;
-
-        if (Boolean.getBoolean("override.fair.fifo.page.eviction.tracker"))
-            return new FairFifoPageEvictionTracker(pageMem0, plc, cctx);
-
-        switch (plc.getPageEvictionMode()) {
-            case RANDOM_LRU:
-                return new RandomLruPageEvictionTracker(pageMem0, plc, cctx);
-            case RANDOM_2_LRU:
-                return new Random2LruPageEvictionTracker(pageMem0, plc, cctx);
-            default:
-                return new NoOpPageEvictionTracker();
-        }
-    }
-
-    /**
-     * Builds allocation path for memory mapped file to be used with PageMemory.
-     *
-     * @param plc MemoryPolicyConfiguration.
-     */
-    @Nullable protected File buildAllocPath(MemoryPolicyConfiguration plc) {
-        String path = plc.getSwapFilePath();
-
-        if (path == null)
-            return null;
-
-        String consId = String.valueOf(cctx.discovery().consistentId());
-
-        consId = consId.replaceAll("[:,\\.]", "_");
-
-        return buildPath(path, consId);
-    }
-
-    /**
-     * Creates PageMemory with given size and memory provider.
-     *
-     * @param memProvider Memory provider.
-     * @param memCfg Memory configuartion.
-     * @param memPlcCfg Memory policy configuration.
-     * @param memMetrics MemoryMetrics to collect memory usage metrics.
-     * @return PageMemory instance.
-     */
-    protected PageMemory createPageMemory(
-        DirectMemoryProvider memProvider,
-        MemoryConfiguration memCfg,
-        MemoryPolicyConfiguration memPlcCfg,
-        MemoryMetricsImpl memMetrics
-    ) {
-        memMetrics.persistenceEnabled(false);
-
-        return new PageMemoryNoStoreImpl(
-            log,
-            memProvider,
-            cctx,
-            memCfg.getPageSize(),
-            memPlcCfg,
-            memMetrics,
-            false
-        );
-    }
-
-    /**
-     * @param path Path to the working directory.
-     * @param consId Consistent ID of the local node.
-     * @return DB storage path.
-     */
-    protected File buildPath(String path, String consId) {
-        String igniteHomeStr = U.getIgniteHome();
-
-        File igniteHome = igniteHomeStr != null ? new File(igniteHomeStr) : null;
-
-        File workDir = igniteHome == null ? new File(path) : new File(igniteHome, path);
-
-        return new File(workDir, consId);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
-        start0();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-        stop0(true);
-    }
-
-    /**
-     * @return Name of MemoryPolicyConfiguration for internal caches.
-     */
-    public String systemMemoryPolicyName() {
-        return SYSTEM_MEMORY_POLICY_NAME;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheSnapshotManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheSnapshotManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheSnapshotManager.java
deleted file mode 100644
index 91957db..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheSnapshotManager.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import java.nio.ByteBuffer;
-import java.util.NavigableMap;
-import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.snapshot.SnapshotOperation;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
-import org.apache.ignite.internal.util.typedef.T2;
-import org.jetbrains.annotations.Nullable;
-
-/**
- *
- */
-public class IgniteCacheSnapshotManager extends GridCacheSharedManagerAdapter {
-    /** Snapshot started lock filename. */
-    public static final String SNAPSHOT_RESTORE_STARTED_LOCK_FILENAME = "snapshot-started.loc";
-
-    /**
-     * @param initiatorNodeId Initiator node id.
-     * @param snapshotOperation Snapshot operation.
-     */
-    @Nullable public IgniteInternalFuture startLocalSnapshotOperation(
-        UUID initiatorNodeId,
-        SnapshotOperation snapshotOperation
-    ) throws IgniteCheckedException {
-        return null;
-    }
-
-    /**
-     * @param snapOp current snapshot operation.
-     *
-     * @return {@code true} if next operation must be snapshot, {@code false} if checkpoint must be executed.
-     */
-    public boolean onMarkCheckPointBegin(
-        SnapshotOperation snapOp,
-        NavigableMap<T2<Integer, Integer>, T2<Integer, Integer>> map
-    ) throws IgniteCheckedException {
-        return false;
-    }
-
-    /**
-     *
-     */
-    public void restoreState() throws IgniteCheckedException {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    public void onCheckPointBegin() {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    public void beforeCheckpointPageWritten() {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    public void afterCheckpointPageWritten() {
-        // No-op.
-    }
-
-    /**
-     * @param fullId Full id.
-     */
-    public void beforePageWrite(FullPageId fullId) {
-        // No-op.
-    }
-
-    /**
-     * @param fullId Full id.
-     */
-    public void onPageWrite(FullPageId fullId, ByteBuffer tmpWriteBuf) {
-        // No-op.
-    }
-
-    /**
-     * @param cctx Cctx.
-     */
-    public void onCacheStop(GridCacheContext cctx) {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    public void onChangeTrackerPage(
-        Long page,
-        FullPageId fullId,
-        PageMemory pageMem
-    ) throws IgniteCheckedException {
-
-    }
-
-    /**
-     *
-     */
-    public void flushDirtyPageHandler(
-        FullPageId fullId,
-        ByteBuffer pageBuf,
-        Integer tag
-    ) throws IgniteCheckedException {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
deleted file mode 100644
index 2e5a78c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryMetricsImpl.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * 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.internal.processors.cache.database;
-
-import org.apache.ignite.MemoryMetrics;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl;
-import org.apache.ignite.internal.processors.cache.ratemetrics.HitRateMetrics;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.jsr166.LongAdder8;
-
-/**
- *
- */
-public class MemoryMetricsImpl implements MemoryMetrics {
-    /** */
-    private FreeListImpl freeList;
-
-    /** */
-    private final LongAdder8 totalAllocatedPages = new LongAdder8();
-
-    /**
-     * Counter for number of pages occupied by large entries (one entry is larger than one page).
-     */
-    private final LongAdder8 largeEntriesPages = new LongAdder8();
-
-    /** Counter for number of dirty pages. */
-    private LongAdder8 dirtyPages = new LongAdder8();
-
-    /** */
-    private volatile boolean metricsEnabled;
-
-    /** */
-    private boolean persistenceEnabled;
-
-    /** */
-    private volatile int subInts;
-
-    /** Allocation rate calculator. */
-    private volatile HitRateMetrics allocRate = new HitRateMetrics(60_000, 5);
-
-    /** */
-    private volatile HitRateMetrics pageReplaceRate = new HitRateMetrics(60_000, 5);
-
-    /** */
-    private final MemoryPolicyConfiguration memPlcCfg;
-
-    /** */
-    private PageMemory pageMem;
-
-    /** Time interval (in milliseconds) when allocations/evictions are counted to calculate rate. */
-    private volatile long rateTimeInterval;
-
-    /**
-     * @param memPlcCfg MemoryPolicyConfiguration.
-     */
-    public MemoryMetricsImpl(MemoryPolicyConfiguration memPlcCfg) {
-        this.memPlcCfg = memPlcCfg;
-
-        metricsEnabled = memPlcCfg.isMetricsEnabled();
-
-        rateTimeInterval = memPlcCfg.getRateTimeInterval();
-
-        subInts = memPlcCfg.getSubIntervals();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String getName() {
-        return U.maskName(memPlcCfg.getName());
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getTotalAllocatedPages() {
-        return metricsEnabled ? totalAllocatedPages.longValue() : 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getAllocationRate() {
-        if (!metricsEnabled)
-            return 0;
-
-        return ((float) allocRate.getRate()) / rateTimeInterval;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getEvictionRate() {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getLargeEntriesPagesPercentage() {
-        if (!metricsEnabled)
-            return 0;
-
-        return totalAllocatedPages.longValue() != 0 ?
-                (float) largeEntriesPages.doubleValue() / totalAllocatedPages.longValue()
-                : 0;
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getPagesFillFactor() {
-        if (!metricsEnabled || freeList == null)
-            return 0;
-
-        return freeList.fillFactor();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getDirtyPages() {
-        if (!metricsEnabled || !persistenceEnabled)
-            return 0;
-
-        return dirtyPages.longValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float getPagesReplaceRate() {
-        if (!metricsEnabled || !persistenceEnabled)
-            return 0;
-
-        return ((float) pageReplaceRate.getRate()) / rateTimeInterval;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getPhysicalMemoryPages() {
-        if (!metricsEnabled || !persistenceEnabled)
-            return 0;
-
-        assert pageMem != null;
-
-        return pageMem.loadedPages();
-    }
-
-    /**
-     * Updates pageReplaceRate metric.
-     */
-    public void updatePageReplaceRate() {
-        if (metricsEnabled)
-            pageReplaceRate.onHit();
-    }
-
-    /**
-     * Increments dirtyPages counter.
-     */
-    public void incrementDirtyPages() {
-        if (metricsEnabled)
-            dirtyPages.increment();
-    }
-
-    /**
-     * Decrements dirtyPages counter.
-     */
-    public void decrementDirtyPages() {
-        if (metricsEnabled)
-            dirtyPages.decrement();
-    }
-
-    /**
-     * Resets dirtyPages counter to zero.
-     */
-    public void resetDirtyPages() {
-        if (metricsEnabled)
-            dirtyPages.reset();
-    }
-
-    /**
-     * Increments totalAllocatedPages counter.
-     */
-    public void incrementTotalAllocatedPages() {
-        if (metricsEnabled) {
-            totalAllocatedPages.increment();
-
-            updateAllocationRateMetrics();
-        }
-    }
-
-    /**
-     *
-     */
-    private void updateAllocationRateMetrics() {
-        allocRate.onHit();
-    }
-
-    /**
-     * @param intervalNum Interval number.
-     */
-    private long subInt(int intervalNum) {
-        return (rateTimeInterval * intervalNum) / subInts;
-    }
-
-    /**
-     *
-     */
-    public void incrementLargeEntriesPages() {
-        if (metricsEnabled)
-            largeEntriesPages.increment();
-    }
-
-    /**
-     *
-     */
-    public void decrementLargeEntriesPages() {
-        if (metricsEnabled)
-            largeEntriesPages.decrement();
-    }
-
-    /**
-     * Enable metrics.
-     */
-    public void enableMetrics() {
-        metricsEnabled = true;
-    }
-
-    /**
-     * Disable metrics.
-     */
-    public void disableMetrics() {
-        metricsEnabled = false;
-    }
-
-    /**
-     * @param persistenceEnabled Persistence enabled.
-     */
-    public void persistenceEnabled(boolean persistenceEnabled) {
-        this.persistenceEnabled = persistenceEnabled;
-    }
-
-    /**
-     * @param pageMem Page mem.
-     */
-    public void pageMemory(PageMemory pageMem) {
-        this.pageMem = pageMem;
-    }
-
-    /**
-     * @param rateTimeInterval Time interval (in milliseconds) used to calculate allocation/eviction rate.
-     */
-    public void rateTimeInterval(long rateTimeInterval) {
-        this.rateTimeInterval = rateTimeInterval;
-
-        allocRate = new HitRateMetrics((int) rateTimeInterval, subInts);
-        pageReplaceRate = new HitRateMetrics((int) rateTimeInterval, subInts);
-    }
-
-    /**
-     * Sets number of subintervals the whole rateTimeInterval will be split into to calculate allocation rate.
-     *
-     * @param subInts Number of subintervals.
-     */
-    public void subIntervals(int subInts) {
-        assert subInts > 0;
-
-        if (this.subInts == subInts)
-            return;
-
-        if (rateTimeInterval / subInts < 10)
-            subInts = (int) rateTimeInterval / 10;
-
-        allocRate = new HitRateMetrics((int) rateTimeInterval, subInts);
-        pageReplaceRate = new HitRateMetrics((int) rateTimeInterval, subInts);
-    }
-
-    /**
-     * @param freeList Free list.
-     */
-    void freeList(FreeListImpl freeList) {
-        this.freeList = freeList;
-    }
-}


Mime
View raw message