ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [14/47] ignite git commit: IGNITE-5267 - Moved ignite-ps module to ignite-core
Date Sun, 11 Jun 2017 20:03:40 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
deleted file mode 100755
index 8c096f1..0000000
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/file/FilePageStoreManager.java
+++ /dev/null
@@ -1,671 +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.file;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.PersistentStoreConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
-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.store.IgnitePageStoreManager;
-import org.apache.ignite.internal.pagemem.store.PageStore;
-import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
-import org.apache.ignite.internal.processors.cache.StoredCacheData;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheSnapshotManager;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * File page store manager.
- */
-public class FilePageStoreManager extends GridCacheSharedManagerAdapter implements IgnitePageStoreManager {
-    /** File suffix. */
-    public static final String FILE_SUFFIX = ".bin";
-
-    /** Partition file prefix. */
-    public static final String PART_FILE_PREFIX = "part-";
-
-    /** */
-    public static final String INDEX_FILE_NAME = "index" + FILE_SUFFIX;
-
-    /** */
-    public static final String PART_FILE_TEMPLATE = PART_FILE_PREFIX+ "%d" + FILE_SUFFIX;
-
-    /** */
-    public static final String CACHE_DIR_PREFIX = "cache-";
-
-    /** */
-    public static final String CACHE_GRP_DIR_PREFIX = "cacheGroup-";
-
-    /** */
-    public static final String CACHE_DATA_FILENAME = "cache_data.dat";
-
-    /** Marshaller. */
-    private static final Marshaller marshaller = new JdkMarshaller();
-
-    /** */
-    private final Map<Integer, CacheStoreHolder> idxCacheStores = new ConcurrentHashMap<>();
-
-    /** */
-    private final IgniteConfiguration igniteCfg;
-
-    /** */
-    private PersistentStoreConfiguration pstCfg;
-
-    /** Absolute directory for file page store */
-    private File storeWorkDir;
-
-    /** */
-    private final long metaPageId = PageIdUtils.pageId(-1, PageMemory.FLAG_IDX, 0);
-
-    /** */
-    private final Set<Integer> grpsWithoutIdx = Collections.newSetFromMap(new ConcurrentHashMap<Integer, Boolean>());
-
-    /**
-     * @param ctx Kernal context.
-     */
-    public FilePageStoreManager(GridKernalContext ctx) {
-        igniteCfg = ctx.config();
-
-        PersistentStoreConfiguration pstCfg = igniteCfg.getPersistentStoreConfiguration();
-
-        assert pstCfg != null : "WAL should not be created if persistence is disabled.";
-
-        this.pstCfg = pstCfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void start0() throws IgniteCheckedException {
-        if (cctx.kernalContext().clientNode())
-            return;
-
-        String consId = U.maskForFileName(cctx.kernalContext().discovery().consistentId().toString());
-
-        if (pstCfg.getPersistentStorePath() != null) {
-            File workDir0 = new File(pstCfg.getPersistentStorePath());
-
-            if (!workDir0.isAbsolute())
-                workDir0 = U.resolveWorkDirectory(
-                    igniteCfg.getWorkDirectory(),
-                    pstCfg.getPersistentStorePath(),
-                    false
-                );
-
-            storeWorkDir = new File(workDir0, consId);
-        }
-        else
-            storeWorkDir = new File(U.resolveWorkDirectory(
-                igniteCfg.getWorkDirectory(),
-                "db",
-                false
-            ), consId);
-
-        U.ensureDirectory(storeWorkDir, "page store work directory", log);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop0(boolean cancel) {
-        if (log.isDebugEnabled())
-            log.debug("Stopping page store manager.");
-
-        IgniteCheckedException ex = shutdown(false);
-
-        if (ex != null)
-            U.error(log, "Failed to gracefully stop page store manager", ex);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
-        if (log.isDebugEnabled())
-            log.debug("Activate page store manager [id=" + cctx.localNodeId() +
-                " topVer=" + cctx.discovery().topologyVersionEx() + " ]");
-
-        start0();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-        if (log.isDebugEnabled())
-            log.debug("DeActivate page store manager [id=" + cctx.localNodeId() +
-                " topVer=" + cctx.discovery().topologyVersionEx() + " ]");
-
-        stop0(true);
-
-        idxCacheStores.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void beginRecover() {
-        for (CacheStoreHolder holder : idxCacheStores.values()) {
-            holder.idxStore.beginRecover();
-
-            for (FilePageStore partStore : holder.partStores)
-                partStore.beginRecover();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void finishRecover() {
-        for (CacheStoreHolder holder : idxCacheStores.values()) {
-            holder.idxStore.finishRecover();
-
-            for (FilePageStore partStore : holder.partStores)
-                partStore.finishRecover();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void initializeForCache(CacheGroupDescriptor grpDesc, StoredCacheData cacheData)
-        throws IgniteCheckedException {
-        int grpId = grpDesc.groupId();
-
-        if (!idxCacheStores.containsKey(grpId)) {
-            CacheStoreHolder holder = initForCache(grpDesc, cacheData.config());
-
-            CacheStoreHolder old = idxCacheStores.put(grpId, holder);
-
-            assert old == null : "Non-null old store holder for cache: " + cacheData.config().getName();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void storeCacheData(
-        CacheGroupDescriptor grpDesc,
-        StoredCacheData cacheData
-    ) throws IgniteCheckedException {
-
-        File cacheWorkDir = cacheWorkDirectory(grpDesc, cacheData.config());
-        File file;
-
-        checkAndInitCacheWorkDir(cacheWorkDir);
-
-        assert cacheWorkDir.exists() : "Work directory does not exist: " + cacheWorkDir;
-
-        if (grpDesc.sharedGroup())
-            file = new File(cacheWorkDir, cacheData.config().getName() + CACHE_DATA_FILENAME);
-        else
-            file = new File(cacheWorkDir, CACHE_DATA_FILENAME);
-
-        if (!file.exists() || file.length() == 0) {
-            try {
-                file.createNewFile();
-
-                try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(file))) {
-                    marshaller.marshal(cacheData, stream);
-                }
-            }
-            catch (IOException ex) {
-                throw new IgniteCheckedException("Failed to persist cache configuration: " + cacheData.config().getName(), ex);
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void shutdownForCacheGroup(CacheGroupContext grp, boolean destroy) throws IgniteCheckedException {
-        grpsWithoutIdx.remove(grp.groupId());
-
-        CacheStoreHolder old = idxCacheStores.remove(grp.groupId());
-
-        assert old != null : "Missing cache store holder [cache=" + grp.cacheOrGroupName() +
-            ", locNodeId=" + cctx.localNodeId() + ", gridName=" + cctx.igniteInstanceName() + ']';
-
-        IgniteCheckedException ex = shutdown(old, /*clean files if destroy*/destroy, null);
-
-        if (ex != null)
-            throw ex;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onPartitionCreated(int grpId, int partId) throws IgniteCheckedException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onPartitionDestroyed(int grpId, int partId, int tag) throws IgniteCheckedException {
-        assert partId <= PageIdAllocator.MAX_PARTITION_ID;
-
-        PageStore store = getStore(grpId, partId);
-
-        assert store instanceof FilePageStore : store;
-
-        ((FilePageStore)store).truncate(tag);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void read(int cacheId, long pageId, ByteBuffer pageBuf) throws IgniteCheckedException {
-        read(cacheId, pageId, pageBuf, false);
-    }
-
-    /**
-     * Will preserve crc in buffer if keepCrc is true.
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @param pageBuf Page buffer.
-     * @param keepCrc Keep CRC flag.
-     * @throws IgniteCheckedException If failed.
-     */
-    public void read(int cacheId, long pageId, ByteBuffer pageBuf, boolean keepCrc) throws IgniteCheckedException {
-        PageStore store = getStore(cacheId, PageIdUtils.partId(pageId));
-
-        store.read(pageId, pageBuf, keepCrc);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean exists(int grpId, int partId) throws IgniteCheckedException {
-        PageStore store = getStore(grpId, partId);
-
-        return store.exists();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readHeader(int cacheId, int partId, ByteBuffer buf) throws IgniteCheckedException {
-        PageStore store = getStore(cacheId, partId);
-
-        store.readHeader(buf);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(int cacheId, long pageId, ByteBuffer pageBuf,int tag) throws IgniteCheckedException {
-        writeInternal(cacheId, pageId, pageBuf, tag);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long pageOffset(int cacheId, long pageId) throws IgniteCheckedException {
-        PageStore store = getStore(cacheId, PageIdUtils.partId(pageId));
-
-        return store.pageOffset(pageId);
-    }
-
-    /**
-     * @param cacheId Cache ID to write.
-     * @param pageId Page ID.
-     * @param pageBuf Page buffer.
-     * @return PageStore to which the page has been written.
-     * @throws IgniteCheckedException If IO error occurred.
-     */
-    public PageStore writeInternal(int cacheId, long pageId, ByteBuffer pageBuf, int tag) throws IgniteCheckedException {
-        int partId = PageIdUtils.partId(pageId);
-
-        PageStore store = getStore(cacheId, partId);
-
-        store.write(pageId, pageBuf, tag);
-
-        return store;
-    }
-
-    /**
-     * @param grpDesc Cache group descriptor.
-     * @param ccfg Cache configuration.
-     * @return Cache work directory.
-     */
-    private File cacheWorkDirectory(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) {
-        String dirName;
-
-        if (grpDesc.sharedGroup())
-            dirName = CACHE_GRP_DIR_PREFIX + ccfg.getGroupName();
-        else
-            dirName = CACHE_DIR_PREFIX + ccfg.getName();
-
-        return new File(storeWorkDir, dirName);
-    }
-
-    /**
-     * @param grpDesc Cache group descriptor.
-     * @param ccfg Cache configuration.
-     * @return Cache store holder.
-     * @throws IgniteCheckedException If failed.
-     */
-    private CacheStoreHolder initForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException {
-        assert !grpDesc.sharedGroup() || ccfg.getGroupName() != null : ccfg.getName();
-
-        File cacheWorkDir = cacheWorkDirectory(grpDesc, ccfg);
-
-        boolean dirExisted = checkAndInitCacheWorkDir(cacheWorkDir);
-
-        File idxFile = new File(cacheWorkDir, INDEX_FILE_NAME);
-
-        if (dirExisted && !idxFile.exists())
-            grpsWithoutIdx.add(grpDesc.groupId());
-
-        FilePageStore idxStore = new FilePageStore(
-            PageMemory.FLAG_IDX,
-            idxFile,
-            cctx.kernalContext().config().getMemoryConfiguration());
-
-        FilePageStore[] partStores = new FilePageStore[grpDesc.config().getAffinity().partitions()];
-
-        for (int partId = 0; partId < partStores.length; partId++) {
-            FilePageStore partStore = new FilePageStore(
-                PageMemory.FLAG_DATA,
-                new File(cacheWorkDir, String.format(PART_FILE_TEMPLATE, partId)),
-                cctx.kernalContext().config().getMemoryConfiguration()
-            );
-
-            partStores[partId] = partStore;
-        }
-
-        return new CacheStoreHolder(idxStore, partStores);
-    }
-
-    private boolean checkAndInitCacheWorkDir(File cacheWorkDir) throws IgniteCheckedException {
-        boolean dirExisted = false;
-
-        if (!cacheWorkDir.exists()) {
-            boolean res = cacheWorkDir.mkdirs();
-
-            if (!res)
-                throw new IgniteCheckedException("Failed to initialize cache working directory " +
-                    "(failed to create, make sure the work folder has correct permissions): " +
-                    cacheWorkDir.getAbsolutePath());
-        }
-        else {
-            if (cacheWorkDir.isFile())
-                throw new IgniteCheckedException("Failed to initialize cache working directory " +
-                    "(a file with the same name already exists): " + cacheWorkDir.getAbsolutePath());
-
-            File lockF = new File(cacheWorkDir, IgniteCacheSnapshotManager.SNAPSHOT_RESTORE_STARTED_LOCK_FILENAME);
-
-            if (lockF.exists()) {
-                Path tmp = cacheWorkDir.toPath().getParent().resolve(cacheWorkDir.getName() + ".tmp");
-
-                boolean deleted = U.delete(cacheWorkDir);
-
-                if (Files.exists(tmp) && Files.isDirectory(tmp)) {
-                    U.warn(log, "Ignite node crashed during the snapshot restore process " +
-                        "(there is a snapshot restore lock file left for cache). But old version of cache was saved. " +
-                        "Trying to restore it. Cache - [" + cacheWorkDir.getAbsolutePath() + ']');
-
-                    try {
-                        Files.move(tmp, cacheWorkDir.toPath());
-                    }
-                    catch (IOException e) {
-                        throw new IgniteCheckedException(e);
-                    }
-                }
-                else {
-                    U.warn(log, "Ignite node crashed during the snapshot restore process " +
-                        "(there is a snapshot restore lock file left for cache). Will remove both the lock file and " +
-                        "incomplete cache directory [cacheDir=" + cacheWorkDir.getAbsolutePath() + ']');
-
-                    if (!deleted)
-                        throw new IgniteCheckedException("Failed to remove obsolete cache working directory " +
-                            "(remove the directory manually and make sure the work folder has correct permissions): " +
-                            cacheWorkDir.getAbsolutePath());
-
-                    cacheWorkDir.mkdirs();
-                }
-
-                if (!cacheWorkDir.exists())
-                    throw new IgniteCheckedException("Failed to initialize cache working directory " +
-                        "(failed to create, make sure the work folder has correct permissions): " +
-                        cacheWorkDir.getAbsolutePath());
-            }
-            else
-                dirExisted = true;
-        }
-
-        return dirExisted;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void sync(int cacheId, int partId) throws IgniteCheckedException {
-        getStore(cacheId, partId).sync();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void ensure(int cacheId, int partId) throws IgniteCheckedException {
-        getStore(cacheId, partId).ensure();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long allocatePage(int cacheId, int partId, byte flags) throws IgniteCheckedException {
-        assert partId <= PageIdAllocator.MAX_PARTITION_ID || partId == PageIdAllocator.INDEX_PARTITION;
-
-        PageStore store = getStore(cacheId, partId);
-
-        long pageIdx = store.allocatePage();
-
-        return PageIdUtils.pageId(partId, flags, (int)pageIdx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long metaPageId(final int cacheId) {
-        return metaPageId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int pages(int cacheId, int partId) throws IgniteCheckedException {
-        PageStore store = getStore(cacheId, partId);
-
-        return store.pages();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map<String, StoredCacheData> readCacheConfigurations() throws IgniteCheckedException {
-        if (cctx.kernalContext().clientNode())
-            return Collections.emptyMap();
-
-        File[] files = storeWorkDir.listFiles();
-
-        if (files == null)
-            return Collections.emptyMap();
-
-        Map<String, StoredCacheData> ccfgs = new HashMap<>();
-
-        for (File file : files) {
-            if (file.isDirectory()) {
-                if (file.getName().startsWith(CACHE_DIR_PREFIX)) {
-                    File conf = new File(file, CACHE_DATA_FILENAME);
-
-                    if (conf.exists() && conf.length() > 0) {
-                        StoredCacheData cacheData = readCacheData(conf);
-
-                        ccfgs.put(cacheData.config().getName(), cacheData);
-                    }
-                }
-                else if (file.getName().startsWith(CACHE_GRP_DIR_PREFIX))
-                    readCacheGroupCaches(file, ccfgs);
-            }
-        }
-
-        return ccfgs;
-    }
-
-    /**
-     * @param grpDir Group directory.
-     * @param ccfgs Cache configurations.
-     * @throws IgniteCheckedException If failed.
-     */
-    private void readCacheGroupCaches(File grpDir, Map<String, StoredCacheData> ccfgs) throws IgniteCheckedException {
-        File[] files = grpDir.listFiles();
-
-        if (files == null)
-            return;
-
-        for (File file : files) {
-            if (!file.isDirectory() && file.getName().endsWith(CACHE_DATA_FILENAME) && file.length() > 0) {
-                StoredCacheData cacheData = readCacheData(file);
-
-                ccfgs.put(cacheData.config().getName(), cacheData);
-            }
-        }
-    }
-
-    /**
-     * @param conf File with stored cache data.
-     * @return Cache data.
-     * @throws IgniteCheckedException If failed.
-     */
-    private StoredCacheData readCacheData(File conf) throws IgniteCheckedException {
-        try (InputStream stream = new BufferedInputStream(new FileInputStream(conf))) {
-            return marshaller.unmarshal(stream, U.resolveClassLoader(igniteCfg));
-        }
-        catch (IOException e) {
-            throw new IgniteCheckedException("Failed to read cache configuration from disk for cache: " +
-                conf.getAbsolutePath(), e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean hasIndexStore(int grpId) {
-        return !grpsWithoutIdx.contains(grpId);
-    }
-
-    /**
-     * @return Store work dir.
-     */
-    public File workDir() {
-        return storeWorkDir;
-    }
-
-    /**
-     * @param ccfg Cache configuration.
-     * @return Store dir for given cache.
-     */
-    public File cacheWorkDir(CacheConfiguration ccfg) {
-        String dirName = ccfg.getGroupName() == null ?
-            CACHE_DIR_PREFIX + ccfg.getName() : CACHE_GRP_DIR_PREFIX + ccfg.getGroupName();
-
-        return new File(storeWorkDir, dirName);
-    }
-
-    /**
-     * @param cleanFiles {@code True} if the stores should delete it's files upon close.
-     */
-    private IgniteCheckedException shutdown(boolean cleanFiles) {
-        IgniteCheckedException ex = null;
-
-        for (CacheStoreHolder holder : idxCacheStores.values())
-            ex = shutdown(holder, cleanFiles, ex);
-
-        return ex;
-    }
-
-    /**
-     * @param holder Store holder.
-     * @param cleanFile {@code True} if files should be cleaned.
-     * @param aggr Aggregating exception.
-     * @return Aggregating exception, if error occurred.
-     */
-    private IgniteCheckedException shutdown(CacheStoreHolder holder, boolean cleanFile,
-        @Nullable IgniteCheckedException aggr) {
-        aggr = shutdown(holder.idxStore, cleanFile, aggr);
-
-        for (FilePageStore store : holder.partStores) {
-            if (store != null)
-                aggr = shutdown(store, cleanFile, aggr);
-        }
-
-        return aggr;
-    }
-
-    /**
-     * @param store Store to shutdown.
-     * @param cleanFile {@code True} if files should be cleaned.
-     * @param aggr Aggregating exception.
-     * @return Aggregating exception, if error occurred.
-     */
-    private IgniteCheckedException shutdown(FilePageStore store, boolean cleanFile, IgniteCheckedException aggr) {
-        try {
-            if (store != null)
-                store.stop(cleanFile);
-        }
-        catch (IgniteCheckedException e) {
-            if (aggr == null)
-                aggr = new IgniteCheckedException("Failed to gracefully shutdown store");
-
-            aggr.addSuppressed(e);
-        }
-
-        return aggr;
-    }
-
-    /**
-     * @param grpId Cache group ID.
-     * @param partId Partition ID.
-     * @return Page store for the corresponding parameters.
-     * @throws IgniteCheckedException If cache or partition with the given ID was not created.
-     *
-     * Note: visible for testing.
-     */
-    public PageStore getStore(int grpId, int partId) throws IgniteCheckedException {
-        CacheStoreHolder holder = idxCacheStores.get(grpId);
-
-        if (holder == null)
-            throw new IgniteCheckedException("Failed to get page store for the given cache ID " +
-                "(cache has not been started): " + grpId);
-
-        if (partId == PageIdAllocator.INDEX_PARTITION)
-            return holder.idxStore;
-
-        if (partId > PageIdAllocator.MAX_PARTITION_ID)
-            throw new IgniteCheckedException("Partition ID is reserved: " + partId);
-
-        FilePageStore store = holder.partStores[partId];
-
-        if (store == null)
-            throw new IgniteCheckedException("Failed to get page store for the given partition ID " +
-                "(partition has not been created) [grpId=" + grpId + ", partId=" + partId + ']');
-
-        return store;
-    }
-
-    /**
-     *
-     */
-    private static class CacheStoreHolder {
-        /** Index store. */
-        private final FilePageStore idxStore;
-
-        /** Partition stores. */
-        private final FilePageStore[] partStores;
-
-        /**
-         *
-         */
-        public CacheStoreHolder(FilePageStore idxStore, FilePageStore[] partStores) {
-            this.idxStore = idxStore;
-            this.partStores = partStores;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/CheckpointMetricsTracker.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/CheckpointMetricsTracker.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/CheckpointMetricsTracker.java
deleted file mode 100644
index e6b88d3..0000000
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/CheckpointMetricsTracker.java
+++ /dev/null
@@ -1,183 +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.pagemem;
-
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-
-/**
- * Tracks various checkpoint phases and stats.
- *
- * Assumed sequence of events:
- * <ol>
- *     <li>Checkpoint start</li>
- *     <li>CP Lock wait start</li>
- *     <li>CP mark start</li>
- *     <li>CP Lock release</li>
- *     <li>Pages write start</li>
- *     <li>fsync start</li>
- *     <li>Checkpoint end</li>
- * </ol>
- */
-public class CheckpointMetricsTracker {
-    /** */
-    private static final AtomicIntegerFieldUpdater<CheckpointMetricsTracker> DATA_PAGES_UPDATER =
-        AtomicIntegerFieldUpdater.newUpdater(CheckpointMetricsTracker.class, "dataPages");
-
-    /** */
-    private static final AtomicIntegerFieldUpdater<CheckpointMetricsTracker> COW_PAGES_UPDATER =
-        AtomicIntegerFieldUpdater.newUpdater(CheckpointMetricsTracker.class, "cowPages");
-
-    /** */
-    private volatile int dataPages;
-
-    /** */
-    private volatile int cowPages;
-
-    /** */
-    private long cpStart = System.currentTimeMillis();
-
-    /** */
-    private long cpLockWaitStart;
-
-    /** */
-    private long cpMarkStart;
-
-    /** */
-    private long cpLockRelease;
-
-    /** */
-    private long cpPagesWriteStart;
-
-    /** */
-    private long cpFsyncStart;
-
-    /** */
-    private long cpEnd;
-
-    /**
-     *
-     */
-    public void onCowPageWritten() {
-        COW_PAGES_UPDATER.incrementAndGet(this);
-    }
-
-    /**
-     *
-     */
-    public void onDataPageWritten() {
-        DATA_PAGES_UPDATER.incrementAndGet(this);
-    }
-
-    /**
-     * @return COW pages.
-     */
-    public int cowPagesWritten() {
-        return cowPages;
-    }
-
-    /**
-     * @return Data pages written.
-     */
-    public int dataPagesWritten() {
-        return dataPages;
-    }
-
-    /**
-     *
-     */
-    public void onLockWaitStart() {
-        cpLockWaitStart = System.currentTimeMillis();
-    }
-
-    /**
-     *
-     */
-    public void onMarkStart() {
-        cpMarkStart = System.currentTimeMillis();
-    }
-
-    /**
-     *
-     */
-    public void onLockRelease() {
-        cpLockRelease = System.currentTimeMillis();
-    }
-
-    /**
-     *
-     */
-    public void onPagesWriteStart() {
-        cpPagesWriteStart = System.currentTimeMillis();
-    }
-
-    /**
-     *
-     */
-    public void onFsyncStart() {
-        cpFsyncStart = System.currentTimeMillis();
-    }
-
-    /**
-     *
-     */
-    public void onEnd() {
-        cpEnd = System.currentTimeMillis();
-    }
-
-    /**
-     * @return Total checkpoint duration.
-     */
-    public long totalDuration() {
-        return cpEnd - cpStart;
-    }
-
-    /**
-     * @return Checkpoint lock wait duration.
-     */
-    public long lockWaitDuration() {
-        return cpMarkStart - cpLockWaitStart;
-    }
-
-    /**
-     * @return Checkpoint mark duration.
-     */
-    public long markDuration() {
-        return cpPagesWriteStart - cpMarkStart;
-    }
-
-    /**
-     * @return Checkpoint lock hold duration.
-     */
-    public long lockHoldDuration() {
-        return cpLockRelease - cpMarkStart;
-    }
-
-    /**
-     * @return Pages write duration.
-     */
-    public long pagesWriteDuration() {
-        return cpFsyncStart - cpPagesWriteStart;
-    }
-
-    /**
-     * @return Checkpoint fsync duration.
-     */
-    public long fsyncDuration() {
-        return cpEnd - cpFsyncStart;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/EvictCandidate.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/EvictCandidate.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/EvictCandidate.java
deleted file mode 100644
index 906871f..0000000
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/EvictCandidate.java
+++ /dev/null
@@ -1,77 +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.pagemem;
-
-import org.apache.ignite.internal.pagemem.FullPageId;
-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;
-
-/**
- *
- */
-public class EvictCandidate {
-    /** */
-    private int tag;
-
-    /** */
-    @GridToStringExclude
-    private long relPtr;
-
-    /** */
-    @GridToStringInclude
-    private FullPageId fullId;
-
-    /**
-     * @param tag Tag.
-     * @param relPtr Relative pointer.
-     * @param fullId Full page ID.
-     */
-    public EvictCandidate(int tag, long relPtr, FullPageId fullId) {
-        this.tag = tag;
-        this.relPtr = relPtr;
-        this.fullId = fullId;
-    }
-
-    /**
-     * @return Tag.
-     */
-    public int tag() {
-        return tag;
-    }
-
-    /**
-     * @return Relative pointer.
-     */
-    public long relativePointer() {
-        return relPtr;
-    }
-
-    /**
-     * @return Index.
-     */
-    public FullPageId fullId() {
-        return fullId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(EvictCandidate.class, this, "relPtr", U.hexLong(relPtr));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/FullPageIdTable.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/FullPageIdTable.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/FullPageIdTable.java
deleted file mode 100644
index 01d7bce..0000000
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/FullPageIdTable.java
+++ /dev/null
@@ -1,556 +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.pagemem;
-
-import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageIdUtils;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.lang.GridPredicate3;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiInClosure;
-
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_LONG_HASH_MAP_LOAD_FACTOR;
-import static org.apache.ignite.IgniteSystemProperties.getFloat;
-
-/**
- *
- */
-public class FullPageIdTable {
-    /** Load factor. */
-    private static final float LOAD_FACTOR = getFloat(IGNITE_LONG_LONG_HASH_MAP_LOAD_FACTOR, 2.5f);
-
-    /** */
-    private static final int BYTES_PER_ENTRY = /*cache ID*/4 + /*partition tag*/4 + /*page ID*/8 + /*pointer*/8;
-
-    /** */
-    private static final FullPageId EMPTY_FULL_PAGE_ID = new FullPageId(0, 0);
-
-    /** */
-    private static final long EMPTY_PAGE_ID = EMPTY_FULL_PAGE_ID.pageId();
-
-    /** */
-    private static final int EMPTY_CACHE_ID = EMPTY_FULL_PAGE_ID.cacheId();
-
-    /** */
-    private static final long REMOVED_PAGE_ID = 0x8000000000000000L;
-
-    /** */
-    private static final int REMOVED_CACHE_ID = 0;
-
-    /** */
-    private static final int EQUAL = 0;
-
-    /** */
-    private static final int EMPTY = 1;
-
-    /** */
-    private static final int REMOVED = -1;
-
-    /** */
-    private static final int NOT_EQUAL = 2;
-
-    /** */
-    private static final int OUTDATED = -3;
-
-    /** Max size, in elements. */
-    protected int capacity;
-
-    /** Maximum number of steps to try before failing. */
-    protected int maxSteps;
-
-    /** Pointer to the values array. */
-    protected long valPtr;
-
-    /**
-     * @return Estimated memory size required for this map to store the given number of elements.
-     */
-    public static long requiredMemory(long elementCnt) {
-        assert LOAD_FACTOR != 0;
-
-        return ((long)(elementCnt * LOAD_FACTOR)) * BYTES_PER_ENTRY + 8;
-    }
-
-    /**
-     * @param addr Base address.
-     * @param len Allocated memory length.
-     * @param clear If {@code true}, then memory is considered dirty and will be cleared. Otherwise,
-     *      map will assume that the given memory region is in valid state.
-     */
-    public FullPageIdTable(long addr, long len, boolean clear) {
-        valPtr = addr;
-        capacity = (int)((len - 8) / BYTES_PER_ENTRY);
-
-        maxSteps = capacity;
-
-        if (clear)
-            clear();
-    }
-
-    /**
-     * @return Current number of entries in the map.
-     */
-    public final int size() {
-        return GridUnsafe.getInt(valPtr);
-    }
-
-    /**
-     * @return Maximum number of entries in the map. This maximum can not be always reached.
-     */
-    public final int capacity() {
-        return capacity;
-    }
-
-    /**
-     * Gets value associated with the given key.
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @return A value associated with the given key.
-     */
-    public long get(int cacheId, long pageId, int tag, long absent, long outdated) {
-        assert assertKey(cacheId, pageId);
-
-        int idx = getKey(cacheId, pageId, tag, false);
-
-        if (idx == -1)
-            return absent;
-
-        if (idx == -2)
-            return outdated;
-
-        return valueAt(idx);
-    }
-
-    /**
-     * Refresh outdated value.
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @param tag Partition tag.
-     * @return A value associated with the given key.
-     */
-    public long refresh(int cacheId, long pageId, int tag) {
-        assert assertKey(cacheId, pageId);
-
-        int idx = getKey(cacheId, pageId, tag, true);
-
-        assert idx >= 0 : "[idx=" + idx + ", tag=" + tag + ", cacheId=" + cacheId +
-            ", pageId=" + U.hexLong(pageId) + ']';
-
-        assert tagAt(idx) < tag : "[idx=" + idx + ", tag=" + tag + ", cacheId=" + cacheId +
-            ", pageId=" + U.hexLong(pageId) + ", tagAtIdx=" + tagAt(idx) + ']';
-
-        setTagAt(idx, tag);
-
-        return valueAt(idx);
-    }
-
-    /**
-     * Associates the given key with the given value.
-     *  @param cacheId Cache ID
-     * @param pageId Page ID.
-     * @param value Value to set.
-     */
-    public void put(int cacheId, long pageId, long value, int tag) {
-        assert assertKey(cacheId, pageId);
-
-        int index = putKey(cacheId, pageId, tag);
-
-        setValueAt(index, value);
-    }
-
-    /**
-     * Removes key-value association for the given key.
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     */
-    public void remove(int cacheId, long pageId, int tag) {
-        assert assertKey(cacheId, pageId);
-
-        int index = removeKey(cacheId, pageId, tag);
-
-        if (index >= 0)
-            setValueAt(index, 0);
-    }
-
-    /**
-     * Find nearest value from specified position to the right.
-     *
-     * @param idx Index to start searching from.
-     * @param absent Default value that will be returned if no values present.
-     * @return Closest value to the index and it's partition tag or {@code absent} and -1 if no values found.
-     */
-    public EvictCandidate getNearestAt(final int idx, final long absent) {
-        for (int i = idx; i < capacity + idx; i++) {
-            final int idx2 = i >= capacity ? i - capacity : i;
-
-            if (isValuePresentAt(idx2)) {
-                long base = entryBase(idx2);
-
-                int cacheId = GridUnsafe.getInt(base);
-                int tag = GridUnsafe.getInt(base + 4);
-                long pageId = GridUnsafe.getLong(base + 8);
-                long val = GridUnsafe.getLong(base + 16);
-
-                return new EvictCandidate(tag, val, new FullPageId(pageId, cacheId));
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * @param idx Index to clear value at.
-     * @param pred Test predicate.
-     * @param absent Value to return if the cell is empty.
-     * @return Value at the given index.
-     */
-    public long clearAt(int idx, GridPredicate3<Integer, Long, Integer> pred, long absent) {
-        long base = entryBase(idx);
-
-        int cacheId = GridUnsafe.getInt(base);
-        int tag = GridUnsafe.getInt(base + 4);
-        long pageId = GridUnsafe.getLong(base + 8);
-
-        if ((pageId == REMOVED_PAGE_ID && cacheId == REMOVED_CACHE_ID)
-            || (pageId == EMPTY_PAGE_ID && cacheId == EMPTY_CACHE_ID))
-            return absent;
-
-        if (pred.apply(cacheId, pageId, tag)) {
-            long res = valueAt(idx);
-
-            setKeyAt(idx, REMOVED_CACHE_ID, REMOVED_PAGE_ID);
-            setValueAt(idx, 0);
-
-            return res;
-        }
-        else
-            return absent;
-    }
-
-    /**
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @return Key index.
-     */
-    private int putKey(int cacheId, long pageId, int tag) {
-        int step = 1;
-
-        int index = U.safeAbs(FullPageId.hashCode(cacheId, pageId)) % capacity;
-
-        int foundIndex = -1;
-        int res;
-
-        do {
-            res = testKeyAt(index, cacheId, pageId, tag);
-
-            if (res == OUTDATED) {
-                foundIndex = index;
-
-                break;
-            }
-            else if (res == EMPTY) {
-                if (foundIndex == -1)
-                    foundIndex = index;
-
-                break;
-            }
-            else if (res == REMOVED) {
-                // Must continue search to the first empty slot to ensure there are no duplicate mappings.
-                if (foundIndex == -1)
-                    foundIndex = index;
-            }
-            else if (res == EQUAL)
-                return index;
-            else
-                assert res == NOT_EQUAL;
-
-            index++;
-
-            if (index >= capacity)
-                index -= capacity;
-        }
-        while (++step <= maxSteps);
-
-        if (foundIndex != -1) {
-            setKeyAt(foundIndex, cacheId, pageId);
-            setTagAt(foundIndex, tag);
-
-            if (res != OUTDATED)
-                incrementSize();
-
-            return foundIndex;
-        }
-
-        throw new IgniteOutOfMemoryException("No room for a new key");
-    }
-
-    /**
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @return Key index.
-     */
-    private int getKey(int cacheId, long pageId, int tag, boolean refresh) {
-        int step = 1;
-
-        int index = U.safeAbs(FullPageId.hashCode(cacheId, pageId)) % capacity;
-
-        do {
-            long res = testKeyAt(index, cacheId, pageId, tag);
-
-            if (res == EQUAL)
-                return index;
-            else if (res == EMPTY)
-                return -1;
-            else if (res == OUTDATED)
-                return !refresh ? -2 : index;
-            else
-                assert res == REMOVED || res == NOT_EQUAL;
-
-            index++;
-
-            if (index >= capacity)
-                index -= capacity;
-        }
-        while (++step <= maxSteps);
-
-        return -1;
-    }
-
-    /**
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @return Key index.
-     */
-    private int removeKey(int cacheId, long pageId, int tag) {
-        int step = 1;
-
-        int index = U.safeAbs(FullPageId.hashCode(cacheId, pageId)) % capacity;
-
-        int foundIndex = -1;
-
-        do {
-            long res = testKeyAt(index, cacheId, pageId, tag);
-
-            if (res == EQUAL || res == OUTDATED) {
-                foundIndex = index;
-
-                break;
-            }
-            else if (res == EMPTY)
-                return -1;
-            else
-                assert res == REMOVED || res == NOT_EQUAL;
-
-            index++;
-
-            if (index >= capacity)
-                index -= capacity;
-        }
-        while (++step <= maxSteps);
-
-        if (foundIndex != -1) {
-            setKeyAt(foundIndex, REMOVED_CACHE_ID, REMOVED_PAGE_ID);
-
-            decrementSize();
-        }
-
-        return foundIndex;
-    }
-
-    /**
-     * @param index Entry index.
-     * @return Key value.
-     */
-    private int testKeyAt(int index, int testCacheId, long testPageId, int testTag) {
-        long base = entryBase(index);
-
-        int cacheId = GridUnsafe.getInt(base);
-        int tag = GridUnsafe.getInt(base + 4);
-        long pageId = GridUnsafe.getLong(base + 8);
-
-        if (pageId == REMOVED_PAGE_ID && cacheId == REMOVED_CACHE_ID)
-            return REMOVED;
-        else if (pageId == testPageId && cacheId == testCacheId && tag >= testTag)
-            return EQUAL;
-        else if (pageId == testPageId && cacheId == testCacheId && tag < testTag)
-            return OUTDATED;
-        else if (pageId == EMPTY_PAGE_ID && cacheId == EMPTY_CACHE_ID)
-            return EMPTY;
-        else
-            return NOT_EQUAL;
-    }
-
-    /**
-     * @param idx Index to test.
-     * @return {@code True} if value set for index.
-     */
-    private boolean isValuePresentAt(final int idx) {
-        long base = entryBase(idx);
-
-        int cacheId = GridUnsafe.getInt(base);
-        long pageId = GridUnsafe.getLong(base + 8);
-
-        return !((pageId == REMOVED_PAGE_ID && cacheId == REMOVED_CACHE_ID)
-            || (pageId == EMPTY_PAGE_ID && cacheId == EMPTY_CACHE_ID));
-    }
-
-    /**
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @return {@code True} if checks succeeded.
-     */
-    private boolean assertKey(int cacheId, long pageId) {
-        assert cacheId != EMPTY_CACHE_ID && PageIdUtils.isEffectivePageId(pageId):
-            "cacheId=" + cacheId + ", pageId=" + U.hexLong(pageId);
-
-        return true;
-    }
-
-    /**
-     * @param index Entry index.
-     * @param cacheId Cache ID to write.
-     * @param pageId Page ID to write.
-     */
-    private void setKeyAt(int index, int cacheId, long pageId) {
-        long base = entryBase(index);
-
-        GridUnsafe.putInt(base, cacheId);
-        GridUnsafe.putLong(base + 8, pageId);
-    }
-
-    /**
-     * Gets distance from the ideal key location to the actual location if this entry is present in the table,
-     * or returns negative distance that needed to be scanned to determine the absence of the mapping.
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @param tag Tag.
-     * @return Distance scanned if the entry is found or negative distance scanned, if entry was not found.
-     */
-    public int distanceFromIdeal(int cacheId, long pageId, int tag) {
-        int step = 1;
-
-        int index = U.safeAbs(FullPageId.hashCode(cacheId, pageId)) % capacity;
-
-        int scans = 0;
-        boolean found = false;
-
-        do {
-            scans++;
-
-            long res = testKeyAt(index, cacheId, pageId, tag);
-
-            if (res == EQUAL || res == OUTDATED) {
-                found = true;
-
-                break;
-            }
-            else if (res == EMPTY)
-                break;
-            else
-                assert res == REMOVED || res == NOT_EQUAL;
-
-            index++;
-
-            if (index >= capacity)
-                index -= capacity;
-        }
-        while (++step <= maxSteps);
-
-        return found ? scans : -scans;
-    }
-
-    /**
-     * Scans all the elements in this table.
-     *
-     * @param visitor Visitor.
-     */
-    public void visitAll(IgniteBiInClosure<FullPageId, Long> visitor) {
-        for (int i = 0; i < capacity; i++) {
-            if (isValuePresentAt(i)) {
-                long base = entryBase(i);
-
-                int cacheId = GridUnsafe.getInt(base);
-                long pageId = GridUnsafe.getLong(base + 8);
-                long val = GridUnsafe.getLong(base + 16);
-
-                visitor.apply(new FullPageId(pageId, cacheId), val);
-            }
-        }
-    }
-
-    /**
-     * @param index Entry index.
-     * @return Value.
-     */
-    private long valueAt(int index) {
-        return GridUnsafe.getLong(entryBase(index) + 16);
-    }
-
-    /**
-     * @param index Entry index.
-     * @param value Value.
-     */
-    private void setValueAt(int index, long value) {
-        GridUnsafe.putLong(entryBase(index) + 16, value);
-    }
-
-    private long entryBase(int index) {
-        return valPtr + 8 + (long)index * BYTES_PER_ENTRY;
-    }
-
-    /**
-     * @param index Index to get tag for.
-     * @return Tag at the given index.
-     */
-    private int tagAt(int index) {
-        return GridUnsafe.getInt(entryBase(index) + 4);
-    }
-
-    /**
-     * @param index Index to set tag for.
-     * @param tag Tag to set at the given index.
-     */
-    private void setTagAt(int index, int tag) {
-        GridUnsafe.putInt(entryBase(index) + 4, tag);
-    }
-
-    /**
-     *
-     */
-    public void clear() {
-        GridUnsafe.setMemory(valPtr, (long)capacity * BYTES_PER_ENTRY + 8, (byte)0);
-    }
-
-    /**
-     *
-     */
-    private void incrementSize() {
-        GridUnsafe.putInt(valPtr, GridUnsafe.getInt(valPtr) + 1);
-    }
-
-    /**
-     *
-     */
-    private void decrementSize() {
-        GridUnsafe.putInt(valPtr, GridUnsafe.getInt(valPtr) - 1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryEx.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryEx.java b/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryEx.java
deleted file mode 100644
index 56d1be9..0000000
--- a/modules/pds/src/main/java/org/apache/ignite/internal/processors/cache/database/pagemem/PageMemoryEx.java
+++ /dev/null
@@ -1,149 +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.pagemem;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-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.util.GridMultiCollectionWrapper;
-import org.apache.ignite.internal.util.lang.GridPredicate3;
-import org.jetbrains.annotations.Nullable;
-
-/**
- *
- */
-public interface PageMemoryEx extends PageMemory {
-    /**
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @param page Page pointer.
-     * @param restore Determines if the page is locked for restore.
-     * @return ByteBuffer for modifying the page.
-     */
-    long writeLock(int cacheId, long pageId, long page, boolean restore);
-
-    /**
-     *
-     * @param cacheId Cache ID.
-     * @param pageId Page ID.
-     * @param page Page pointer.
-     * @param walPlc {@code True} if page should be recorded to WAL, {@code false} if the page must not
-     *                                be recorded and {@code null} for the default behavior.
-     * @param dirtyFlag Determines whether the page was modified since the last checkpoint.
-     * @param restore Determines if the page is locked for restore.
-     */
-    void writeUnlock(int cacheId, long pageId, long page, Boolean walPlc,
-        boolean dirtyFlag, boolean restore);
-
-    /**
-     * Gets or allocates metadata page for specified cacheId.
-     *
-     * @param cacheId Cache ID.
-     * @return Meta page for cacheId.
-     * @throws IgniteCheckedException If failed.
-     */
-    public long metaPageId(int cacheId) throws IgniteCheckedException;
-
-    /**
-     * Gets or allocates partition metadata page for specified cacheId and partId.
-     *
-     * @param cacheId Cache ID.
-     * @param partId Partition ID.
-     * @return Meta page for cacheId and partId.
-     * @throws IgniteCheckedException If failed.
-     */
-    public long partitionMetaPageId(int cacheId, int partId) throws IgniteCheckedException;
-
-    /**
-     * @see #acquirePage(int, long)
-     * Will not read page from file if it is not present in memory
-     *
-     * @param cacheId Cache id.
-     * @param pageId Page id.
-     * @param restore Get page for restore
-     * @throws IgniteCheckedException If failed.
-     * @return Page.
-     */
-    public long acquirePage(int cacheId, long pageId, boolean restore) throws IgniteCheckedException;
-
-    /**
-     * Heuristic method which allows a thread to check if it safe to start memory struture modifications
-     * in regard with checkpointing.
-     *
-     * @return {@code False} if there are too many dirty pages and a thread should wait for a
-     *      checkpoint to begin.
-     */
-    public boolean safeToUpdate();
-
-    /**
-     * Gets a collection of dirty page IDs since the last checkpoint. If a dirty page is being written after
-     * the checkpointing operation begun, the modifications will be written to a temporary buffer which will
-     * be flushed to the main memory after the checkpointing finished. This method must be called when no
-     * concurrent operations on pages are performed.
-     *
-     * @return Collection of dirty page IDs.
-     * @throws IgniteException If checkpoint has been already started and was not finished.
-     */
-    public GridMultiCollectionWrapper<FullPageId> beginCheckpoint() throws IgniteException;
-
-    /**
-     * Finishes checkpoint operation.
-     */
-    public void finishCheckpoint();
-
-    /**
-     * Gets page byte buffer for the checkpoint procedure.
-     *
-     * @param pageId Page ID to get byte buffer for. The page ID must be present in the collection returned by
-     *      the {@link #beginCheckpoint()} method call.
-     * @param tmpBuf Temporary buffer to write changes into.
-     * @param tracker Checkpoint metrics tracker.
-     * @return {@code True} if data were read, {@code false} otherwise (data already saved to storage).
-     * @throws IgniteException If failed to obtain page data.
-     */
-    @Nullable public Integer getForCheckpoint(FullPageId pageId, ByteBuffer tmpBuf, CheckpointMetricsTracker tracker);
-
-    /**
-     * Marks partition as invalid / outdated.
-     *
-     * @param cacheId Cache ID.
-     * @param partId Partition ID.
-     * @return New partition tag.
-     */
-    public int invalidate(int cacheId, int partId);
-
-    /**
-     * Clears internal metadata of destroyed cache group.
-     *
-     * @param grpId Cache group ID.
-     */
-    public void onCacheGroupDestroyed(int grpId);
-
-    /**
-     * Asynchronously clears pages satisfying the given predicate.
-     *
-     * @param pred Predicate for cache group id, pageId and partition tag.
-     * @param cleanDirty Flag indicating that dirty pages collection should be cleaned.
-     * @return Future that will be completed when all pages are cleared.
-     */
-    public IgniteInternalFuture<Void> clearAsync(GridPredicate3<Integer, Long, Integer> pred, boolean cleanDirty);
-}


Mime
View raw message