You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/03/04 10:27:18 UTC

[6/6] incubator-ignite git commit: # IGNITE-386: Interface split.

# IGNITE-386: Interface split.


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

Branch: refs/heads/ignite-386
Commit: d83c88af03901a315f27b76caa47b0bb3c362ef5
Parents: 2cbc7ea
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 4 12:26:50 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Mar 4 12:26:50 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteFileSystem.java     | 127 ++++-
 .../org/apache/ignite/igfs/IgfsInputStream.java |   4 +-
 .../internal/processors/igfs/IgfsAsyncImpl.java |   5 +-
 .../ignite/internal/processors/igfs/IgfsEx.java |   8 +
 .../internal/processors/igfs/IgfsImpl.java      |  25 +-
 .../processors/igfs/IgfsInputStreamAdapter.java |   4 +-
 .../igfs/IgfsSecondaryFileSystemImpl.java       | 121 +++++
 ...heIgfsPerBlockLruEvictionPolicySelfTest.java | 485 -------------------
 .../processors/igfs/IgfsAbstractSelfTest.java   |  66 +--
 ...sCachePerBlockLruEvictionPolicySelfTest.java | 485 +++++++++++++++++++
 .../igfs/IgfsDataManagerSelfTest.java           |   1 -
 .../igfs/IgfsDualAbstractSelfTest.java          |  10 +-
 .../processors/igfs/IgfsMetricsSelfTest.java    |   6 +-
 .../processors/igfs/IgfsModesSelfTest.java      |   2 +-
 .../ignite/testsuites/IgniteIgfsTestSuite.java  |   2 +-
 .../igfs/HadoopIgfsDualAbstractSelfTest.java    |   2 +-
 .../HadoopDefaultMapReducePlannerSelfTest.java  |  11 +-
 17 files changed, 814 insertions(+), 550 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index 280628d..7067faf 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -20,7 +20,6 @@ package org.apache.ignite;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.igfs.*;
 import org.apache.ignite.igfs.mapreduce.*;
-import org.apache.ignite.igfs.secondary.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
@@ -57,7 +56,7 @@ import java.util.*;
  * <p>
  * <b>NOTE:</b> integration with Hadoop is available only in {@code In-Memory Accelerator For Hadoop} edition.
  */
-public interface IgniteFileSystem extends IgfsSecondaryFileSystem, IgniteAsyncSupport {
+public interface IgniteFileSystem extends IgniteAsyncSupport {
     /** IGFS scheme name. */
     public static final String IGFS_SCHEME = "igfs";
 
@@ -105,7 +104,7 @@ public interface IgniteFileSystem extends IgfsSecondaryFileSystem, IgniteAsyncSu
      * @throws IgniteException In case of error.
      * @throws org.apache.ignite.igfs.IgfsFileNotFoundException If path doesn't exist.
      */
-    @Override public IgfsInputStream open(IgfsPath path, int bufSize) throws IgniteException;
+    public IgfsInputStream open(IgfsPath path, int bufSize) throws IgniteException;
 
     /**
      * Opens a file for reading.
@@ -127,7 +126,7 @@ public interface IgniteFileSystem extends IgfsSecondaryFileSystem, IgniteAsyncSu
      * @return File output stream to write data to.
      * @throws IgniteException In case of error.
      */
-    @Override public IgfsOutputStream create(IgfsPath path, boolean overwrite) throws IgniteException;
+    public IgfsOutputStream create(IgfsPath path, boolean overwrite) throws IgniteException;
 
     /**
      * Creates a file and opens it for writing.
@@ -141,7 +140,7 @@ public interface IgniteFileSystem extends IgfsSecondaryFileSystem, IgniteAsyncSu
      * @return File output stream to write data to.
      * @throws IgniteException In case of error.
      */
-    @Override public IgfsOutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
+    public IgfsOutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
         long blockSize, @Nullable Map<String, String> props) throws IgniteException;
 
     /**
@@ -184,8 +183,8 @@ public interface IgniteFileSystem extends IgfsSecondaryFileSystem, IgniteAsyncSu
      * @throws IgniteException In case of error.
      * @throws org.apache.ignite.igfs.IgfsFileNotFoundException If path doesn't exist and create flag is {@code false}.
      */
-    @Override public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create,
-        @Nullable Map<String, String> props) throws IgniteException;
+    public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create, @Nullable Map<String, String> props)
+        throws IgniteException;
 
     /**
      * Sets last access time and last modification time for a given path. If argument is {@code null},
@@ -339,6 +338,120 @@ public interface IgniteFileSystem extends IgfsSecondaryFileSystem, IgniteAsyncSu
         @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
         long maxRangeLen, @Nullable T arg) throws IgniteException;
 
+    /**
+     * Checks if the specified path exists in the file system.
+     *
+     * @param path Path to check for existence in the file system.
+     * @return {@code True} if such file exists, otherwise - {@code false}.
+     * @throws IgniteException In case of error.
+     */
+    public boolean exists(IgfsPath path);
+
+    /**
+     * Updates file information for the specified path. Existent properties, not listed in the passed collection,
+     * will not be affected. Other properties will be added or overwritten. Passed properties with {@code null} values
+     * will be removed from the stored properties or ignored if they don't exist in the file info.
+     * <p>
+     * When working in {@code DUAL_SYNC} or {@code DUAL_ASYNC} modes only the following properties will be propagated
+     * to the secondary file system:
+     * <ul>
+     * <li>{@code usrName} - file owner name;</li>
+     * <li>{@code grpName} - file owner group;</li>
+     * <li>{@code permission} - Unix-style string representing file permissions.</li>
+     * </ul>
+     *
+     * @param path File path to set properties for.
+     * @param props Properties to update.
+     * @return File information for specified path or {@code null} if such path does not exist.
+     * @throws IgniteException In case of error.
+     */
+    public IgfsFile update(IgfsPath path, Map<String, String> props) throws IgniteException;
+
+    /**
+     * Renames/moves a file.
+     * <p>
+     * You are free to rename/move data files as you wish, but directories can be only renamed.
+     * You cannot move the directory between different parent directories.
+     * <p>
+     * Examples:
+     * <ul>
+     *     <li>"/work/file.txt" => "/home/project/Presentation Scenario.txt"</li>
+     *     <li>"/work" => "/work-2012.bkp"</li>
+     *     <li>"/work" => "<strike>/backups/work</strike>" - such operation is restricted for directories.</li>
+     * </ul>
+     *
+     * @param src Source file path to rename.
+     * @param dest Destination file path. If destination path is a directory, then source file will be placed
+     *     into destination directory with original name.
+     * @throws IgniteException In case of error.
+     * @throws IgfsFileNotFoundException If source file doesn't exist.
+     */
+    public void rename(IgfsPath src, IgfsPath dest) throws IgniteException;
+
+    /**
+     * Deletes file.
+     *
+     * @param path File path to delete.
+     * @param recursive Delete non-empty directories recursively.
+     * @return {@code True} in case of success, {@code false} otherwise.
+     * @throws IgniteException In case of error.
+     */
+    public boolean delete(IgfsPath path, boolean recursive) throws IgniteException;
+
+    /**
+     * Creates directories under specified path.
+     *
+     * @param path Path of directories chain to create.
+     * @throws IgniteException In case of error.
+     */
+    public void mkdirs(IgfsPath path) throws IgniteException;
+
+    /**
+     * Creates directories under specified path with the specified properties.
+     *
+     * @param path Path of directories chain to create.
+     * @param props Metadata properties to set on created directories.
+     * @throws IgniteException In case of error.
+     */
+    public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) throws IgniteException;
+
+    /**
+     * Lists file paths under the specified path.
+     *
+     * @param path Path to list files under.
+     * @return List of files under the specified path.
+     * @throws IgniteException In case of error.
+     * @throws IgfsFileNotFoundException If path doesn't exist.
+     */
+    public Collection<IgfsPath> listPaths(IgfsPath path) throws IgniteException;
+
+    /**
+     * Lists files under the specified path.
+     *
+     * @param path Path to list files under.
+     * @return List of files under the specified path.
+     * @throws IgniteException In case of error.
+     * @throws IgfsFileNotFoundException If path doesn't exist.
+     */
+    public Collection<IgfsFile> listFiles(IgfsPath path) throws IgniteException;
+
+    /**
+     * Gets file information for the specified path.
+     *
+     * @param path Path to get information for.
+     * @return File information for specified path or {@code null} if such path does not exist.
+     * @throws IgniteException In case of error.
+     */
+    public IgfsFile info(IgfsPath path) throws IgniteException;
+
+    /**
+     * Gets used space in bytes.
+     *
+     * @return Used space in bytes.
+     * @throws IgniteException In case of error.
+     */
+    public long usedSpaceSize() throws IgniteException;
+
     /** {@inheritDoc} */
     @Override public IgniteFileSystem withAsync();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
index 79d69a8..c2ddbb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
@@ -25,7 +25,7 @@ import java.io.*;
  * {@code IGFS} input stream to read data from the file system.
  * It provides several additional methods for asynchronous access.
  */
-public abstract class IgfsInputStream extends InputStream implements IgfsSecondaryFileSystemPositionedReadable {
+public abstract class IgfsInputStream extends InputStream {
     /**
      * Gets file length during file open.
      *
@@ -78,5 +78,5 @@ public abstract class IgfsInputStream extends InputStream implements IgfsSeconda
      * @return Total number of bytes read into the buffer, or -1 if there is no more data (EOF).
      * @throws IOException In case of IO exception.
      */
-    @Override public abstract int read(long pos, byte[] buf, int off, int len) throws IOException;
+    public abstract int read(long pos, byte[] buf, int off, int len) throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
index cb8b833..7aeeb46 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.igfs.*;
 import org.apache.ignite.igfs.mapreduce.*;
+import org.apache.ignite.igfs.secondary.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
@@ -310,7 +311,7 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
     }
 
     /** {@inheritDoc} */
-    @Override public Map<String, String> properties() {
-        return igfs.properties();
+    @Override public IgfsSecondaryFileSystem asSecondary() {
+        return igfs.asSecondary();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
index 7e96c19..492218f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.igfs;
 
 import org.apache.ignite.*;
 import org.apache.ignite.igfs.*;
+import org.apache.ignite.igfs.secondary.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
@@ -152,4 +153,11 @@ public interface IgfsEx extends IgniteFileSystem {
      * @return {@code True} if proxy.
      */
     public boolean isProxy(URI path);
+
+    /**
+     * Return the given IGFS as a secondary file system.
+     *
+     * @return Secondary file system wrapper.
+     */
+    public IgfsSecondaryFileSystem asSecondary();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index c3c81f9..f3fcc83 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -125,6 +125,7 @@ public final class IgfsImpl implements IgfsEx {
      * @param igfsCtx Context.
      * @throws IgniteCheckedException In case of error.
      */
+    @SuppressWarnings("ConstantConditions")
     IgfsImpl(IgfsContext igfsCtx) throws IgniteCheckedException {
         assert igfsCtx != null;
 
@@ -939,6 +940,7 @@ public final class IgfsImpl implements IgfsEx {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override public Collection<IgfsPath> listPaths(final IgfsPath path) {
         if (enterBusy()) {
             try {
@@ -1068,11 +1070,6 @@ public final class IgfsImpl implements IgfsEx {
     }
 
     /** {@inheritDoc} */
-    @Override public Map<String, String> properties() {
-        return Collections.emptyMap();
-    }
-
-    /** {@inheritDoc} */
     @Override public IgfsInputStreamAdapter open(IgfsPath path) {
         return open(path, cfg.getStreamBufferSize(), cfg.getSequentialReadsBeforePrefetch());
     }
@@ -1194,7 +1191,7 @@ public final class IgfsImpl implements IgfsEx {
 
                 IgfsMode mode = modeRslvr.resolveMode(path);
 
-                IgfsFileWorkerBatch batch = null;
+                IgfsFileWorkerBatch batch;
 
                 if (mode == PROXY)
                     throw new IgniteException("PROXY mode cannot be used in IGFS directly: " + path);
@@ -1251,6 +1248,8 @@ public final class IgfsImpl implements IgfsEx {
 
                     IgfsFileInfo oldInfo = meta.info(oldId);
 
+                    assert oldInfo != null;
+
                     if (oldInfo.isDirectory())
                         throw new IgfsPathAlreadyExistsException("Failed to create file (path points to a " +
                             "directory): " + path);
@@ -1269,7 +1268,7 @@ public final class IgfsImpl implements IgfsEx {
                 info = meta.lock(info.id());
 
                 IgfsEventAwareOutputStream os = new IgfsEventAwareOutputStream(path, info, parentId,
-                    bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, batch);
+                    bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, null);
 
                 if (evts.isRecordable(EVT_IGFS_FILE_OPENED_WRITE))
                     evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_OPENED_WRITE));
@@ -1340,8 +1339,7 @@ public final class IgfsImpl implements IgfsEx {
                     if (parentId == null)
                         throw new IgfsInvalidPathException("Failed to resolve parent directory: " + path);
 
-                    info = new IgfsFileInfo(cfg.getBlockSize(), /**affinity key*/null, evictExclude(path,
-                        mode == PRIMARY), props);
+                    info = new IgfsFileInfo(cfg.getBlockSize(), /**affinity key*/null, evictExclude(path, true), props);
 
                     IgniteUuid oldId = meta.putIfAbsent(parentId, path.name(), info);
 
@@ -1352,6 +1350,8 @@ public final class IgfsImpl implements IgfsEx {
                         evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_CREATED));
                 }
 
+                assert info != null;
+
                 if (!info.isFile())
                     throw new IgfsInvalidPathException("Failed to open file (not a file): " + path);
 
@@ -1834,6 +1834,7 @@ public final class IgfsImpl implements IgfsEx {
      * @param arg Optional task argument.
      * @return Execution future.
      */
+    @SuppressWarnings("unchecked")
     <T, R> IgniteInternalFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
         @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
         long maxRangeLen, @Nullable T arg) {
@@ -2130,6 +2131,7 @@ public final class IgfsImpl implements IgfsEx {
      */
     private class FormatMessageListener implements GridMessageListener {
         /** {@inheritDoc} */
+        @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
         @Override public void onMessage(UUID nodeId, Object msg) {
             if (msg instanceof IgfsDeleteMessage) {
                 ClusterNode node = igfsCtx.kernalContext().discovery().node(nodeId);
@@ -2220,4 +2222,9 @@ public final class IgfsImpl implements IgfsEx {
 
         return mode == PROXY;
     }
+
+    /** {@inheritDoc} */
+    @Override public IgfsSecondaryFileSystem asSecondary() {
+        return new IgfsSecondaryFileSystemImpl(this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
index 51e57db..fc333b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
@@ -18,13 +18,15 @@
 package org.apache.ignite.internal.processors.igfs;
 
 import org.apache.ignite.igfs.*;
+import org.apache.ignite.igfs.secondary.*;
 
 import java.io.*;
 
 /**
  * Implementation adapter providing necessary methods.
  */
-public abstract class IgfsInputStreamAdapter extends IgfsInputStream {
+public abstract class IgfsInputStreamAdapter extends IgfsInputStream
+    implements IgfsSecondaryFileSystemPositionedReadable {
     /** {@inheritDoc} */
     @Override public long length() {
         return fileInfo().length();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
new file mode 100644
index 0000000..683b317
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemImpl.java
@@ -0,0 +1,121 @@
+/*
+ * 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.igfs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.igfs.*;
+import org.apache.ignite.igfs.secondary.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Secondary file system over native IGFS.
+ */
+class IgfsSecondaryFileSystemImpl implements IgfsSecondaryFileSystem {
+    /** Delegate. */
+    private final IgfsImpl igfs;
+
+    /**
+     * Constructor.
+     *
+     * @param igfs Delegate.
+     */
+    IgfsSecondaryFileSystemImpl(IgfsImpl igfs) {
+        this.igfs = igfs;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean exists(IgfsPath path) {
+        return igfs.exists(path);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgfsFile update(IgfsPath path, Map<String, String> props) throws IgniteException {
+        return igfs.update(path, props);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void rename(IgfsPath src, IgfsPath dest) throws IgniteException {
+        igfs.rename(src, dest);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean delete(IgfsPath path, boolean recursive) throws IgniteException {
+        return igfs.delete(path, recursive);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void mkdirs(IgfsPath path) throws IgniteException {
+        igfs.mkdirs(path);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void mkdirs(IgfsPath path, @Nullable Map<String, String> props) throws IgniteException {
+        igfs.mkdirs(path, props);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<IgfsPath> listPaths(IgfsPath path) throws IgniteException {
+        return igfs.listPaths(path);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<IgfsFile> listFiles(IgfsPath path) throws IgniteException {
+        return igfs.listFiles(path);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgfsSecondaryFileSystemPositionedReadable open(IgfsPath path, int bufSize)
+        throws IgniteException {
+        return igfs.open(path, bufSize);
+    }
+
+    /** {@inheritDoc} */
+    @Override public OutputStream create(IgfsPath path, boolean overwrite) throws IgniteException {
+        return igfs.create(path, overwrite);
+    }
+
+    /** {@inheritDoc} */
+    @Override public OutputStream create(IgfsPath path, int bufSize, boolean overwrite, int replication,
+        long blockSize, @Nullable Map<String, String> props) throws IgniteException {
+        return igfs.create(path, bufSize, overwrite, replication, blockSize, props);
+    }
+
+    /** {@inheritDoc} */
+    @Override public OutputStream append(IgfsPath path, int bufSize, boolean create,
+        @Nullable Map<String, String> props) throws IgniteException {
+        return igfs.append(path, bufSize, create, props);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgfsFile info(IgfsPath path) throws IgniteException {
+        return igfs.info(path);
+    }
+
+    /** {@inheritDoc} */
+    @Override public long usedSpaceSize() throws IgniteException {
+        return igfs.usedSpaceSize();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<String, String> properties() {
+        return Collections.emptyMap();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/GridCacheIgfsPerBlockLruEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/GridCacheIgfsPerBlockLruEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/GridCacheIgfsPerBlockLruEvictionPolicySelfTest.java
deleted file mode 100644
index a2e1c81..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/GridCacheIgfsPerBlockLruEvictionPolicySelfTest.java
+++ /dev/null
@@ -1,485 +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.igfs;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.eviction.igfs.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.igfs.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.util.lang.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.igfs.IgfsMode.*;
-
-/**
- * Tests for IGFS per-block LR eviction policy.
- */
-@SuppressWarnings({"ConstantConditions", "ThrowableResultOfMethodCallIgnored"})
-public class GridCacheIgfsPerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstractTest {
-    /** Primary IGFS name. */
-    private static final String IGFS_PRIMARY = "igfs-primary";
-
-    /** Primary IGFS name. */
-    private static final String IGFS_SECONDARY = "igfs-secondary";
-
-    /** Secondary file system REST endpoint configuration map. */
-    private static final Map<String, String> SECONDARY_REST_CFG = new HashMap<String, String>() {{
-        put("type", "tcp");
-        put("port", "11500");
-    }};
-
-    /** File working in PRIMARY mode. */
-    public static final IgfsPath FILE = new IgfsPath("/file");
-
-    /** File working in DUAL mode. */
-    public static final IgfsPath FILE_RMT = new IgfsPath("/fileRemote");
-
-    /** Primary IGFS instances. */
-    private static IgfsImpl igfsPrimary;
-
-    /** Secondary IGFS instance. */
-    private static IgniteFileSystem secondaryFs;
-
-    /** Primary file system data cache. */
-    private static GridCacheAdapter<IgfsBlockKey, byte[]> dataCache;
-
-    /** Eviction policy */
-    private static CacheIgfsPerBlockLruEvictionPolicy evictPlc;
-
-    /**
-     * Start a grid with the primary file system.
-     *
-     * @throws Exception If failed.
-     */
-    private void startPrimary() throws Exception {
-        IgfsConfiguration igfsCfg = new IgfsConfiguration();
-
-        igfsCfg.setDataCacheName("dataCache");
-        igfsCfg.setMetaCacheName("metaCache");
-        igfsCfg.setName(IGFS_PRIMARY);
-        igfsCfg.setBlockSize(512);
-        igfsCfg.setDefaultMode(PRIMARY);
-        igfsCfg.setPrefetchBlocks(1);
-        igfsCfg.setSequentialReadsBeforePrefetch(Integer.MAX_VALUE);
-        igfsCfg.setSecondaryFileSystem(secondaryFs);
-
-        Map<String, IgfsMode> pathModes = new HashMap<>();
-
-        pathModes.put(FILE_RMT.toString(), DUAL_SYNC);
-
-        igfsCfg.setPathModes(pathModes);
-
-        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
-
-        dataCacheCfg.setName("dataCache");
-        dataCacheCfg.setCacheMode(PARTITIONED);
-        dataCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
-        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        evictPlc = new CacheIgfsPerBlockLruEvictionPolicy();
-
-        dataCacheCfg.setEvictionPolicy(evictPlc);
-        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
-        dataCacheCfg.setBackups(0);
-        dataCacheCfg.setQueryIndexEnabled(false);
-
-        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
-        metaCacheCfg.setName("metaCache");
-        metaCacheCfg.setCacheMode(REPLICATED);
-        metaCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
-        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        metaCacheCfg.setQueryIndexEnabled(false);
-        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridName("grid-primary");
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
-        cfg.setDiscoverySpi(discoSpi);
-        cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
-        cfg.setIgfsConfiguration(igfsCfg);
-
-        cfg.setLocalHost("127.0.0.1");
-        cfg.setConnectorConfiguration(null);
-
-        Ignite g = G.start(cfg);
-
-        igfsPrimary = (IgfsImpl)g.fileSystem(IGFS_PRIMARY);
-
-        dataCache = igfsPrimary.context().kernalContext().cache().internalCache(
-            igfsPrimary.context().configuration().getDataCacheName());
-    }
-
-    /**
-     * Start a grid with the secondary file system.
-     *
-     * @throws Exception If failed.
-     */
-    private void startSecondary() throws Exception {
-        IgfsConfiguration igfsCfg = new IgfsConfiguration();
-
-        igfsCfg.setDataCacheName("dataCache");
-        igfsCfg.setMetaCacheName("metaCache");
-        igfsCfg.setName(IGFS_SECONDARY);
-        igfsCfg.setBlockSize(512);
-        igfsCfg.setDefaultMode(PRIMARY);
-        igfsCfg.setIpcEndpointConfiguration(SECONDARY_REST_CFG);
-
-        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
-
-        dataCacheCfg.setName("dataCache");
-        dataCacheCfg.setCacheMode(PARTITIONED);
-        dataCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
-        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
-        dataCacheCfg.setBackups(0);
-        dataCacheCfg.setQueryIndexEnabled(false);
-        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
-        metaCacheCfg.setName("metaCache");
-        metaCacheCfg.setCacheMode(REPLICATED);
-        metaCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
-        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        metaCacheCfg.setQueryIndexEnabled(false);
-        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridName("grid-secondary");
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
-        cfg.setDiscoverySpi(discoSpi);
-        cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
-        cfg.setIgfsConfiguration(igfsCfg);
-
-        cfg.setLocalHost("127.0.0.1");
-        cfg.setConnectorConfiguration(null);
-
-        Ignite g = G.start(cfg);
-
-        secondaryFs = g.fileSystem(IGFS_SECONDARY);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        try {
-            // Cleanup.
-            igfsPrimary.format();
-
-            while (!dataCache.isEmpty())
-                U.sleep(100);
-
-            checkEvictionPolicy(0, 0);
-        }
-        finally {
-            stopAllGrids(false);
-        }
-    }
-
-    /**
-     * Startup primary and secondary file systems.
-     *
-     * @throws Exception If failed.
-     */
-    private void start() throws Exception {
-        startSecondary();
-        startPrimary();
-
-        evictPlc.setMaxBlocks(0);
-        evictPlc.setMaxSize(0);
-        evictPlc.setExcludePaths(null);
-    }
-
-    /**
-     * Test how evictions are handled for a file working in PRIMARY mode.
-     *
-     * @throws Exception If failed.
-     */
-    public void testFilePrimary() throws Exception {
-        start();
-
-        // Create file in primary mode. It must not be propagated to eviction policy.
-        igfsPrimary.create(FILE, true).close();
-
-        checkEvictionPolicy(0, 0);
-
-        int blockSize = igfsPrimary.info(FILE).blockSize();
-
-        append(FILE, blockSize);
-
-        checkEvictionPolicy(0, 0);
-
-        read(FILE, 0, blockSize);
-
-        checkEvictionPolicy(0, 0);
-    }
-
-    /**
-     * Test how evictions are handled for a file working in PRIMARY mode.
-     *
-     * @throws Exception If failed.
-     */
-    public void testFileDual() throws Exception {
-        start();
-
-        igfsPrimary.create(FILE_RMT, true).close();
-
-        checkEvictionPolicy(0, 0);
-
-        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
-
-        // File write.
-        append(FILE_RMT, blockSize);
-
-        checkEvictionPolicy(1, blockSize);
-
-        // One more write.
-        append(FILE_RMT, blockSize);
-
-        checkEvictionPolicy(2, blockSize * 2);
-
-        // Read.
-        read(FILE_RMT, 0, blockSize);
-
-        checkEvictionPolicy(2, blockSize * 2);
-    }
-
-    /**
-     * Ensure that a DUAL mode file is not propagated to eviction policy
-     *
-     * @throws Exception If failed.
-     */
-    public void testFileDualExclusion() throws Exception {
-        start();
-
-        evictPlc.setExcludePaths(Collections.singleton(FILE_RMT.toString()));
-
-        // Create file in primary mode. It must not be propagated to eviction policy.
-        igfsPrimary.create(FILE_RMT, true).close();
-
-        checkEvictionPolicy(0, 0);
-
-        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
-
-        append(FILE_RMT, blockSize);
-
-        checkEvictionPolicy(0, 0);
-
-        read(FILE_RMT, 0, blockSize);
-
-        checkEvictionPolicy(0, 0);
-    }
-
-    /**
-     * Ensure that exception is thrown in case we are trying to rename file with one exclude setting to the file with
-     * another.
-     *
-     * @throws Exception If failed.
-     */
-    public void testRenameDifferentExcludeSettings() throws Exception {
-        start();
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                igfsPrimary.rename(FILE, FILE_RMT);
-
-                return null;
-            }
-        }, IgfsInvalidPathException.class, "Cannot move file to a path with different eviction exclude setting " +
-            "(need to copy and remove)");
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                igfsPrimary.rename(FILE_RMT, FILE);
-
-                return null;
-            }
-        }, IgfsInvalidPathException.class, "Cannot move file to a path with different eviction exclude setting " +
-            "(need to copy and remove)");
-    }
-
-    /**
-     * Test eviction caused by too much blocks.
-     *
-     * @throws Exception If failed.
-     */
-    public void testBlockCountEviction() throws Exception {
-        start();
-
-        int blockCnt = 3;
-
-        evictPlc.setMaxBlocks(blockCnt);
-
-        igfsPrimary.create(FILE_RMT, true).close();
-
-        checkEvictionPolicy(0, 0);
-
-        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
-
-        // Write blocks up to the limit.
-        append(FILE_RMT, blockSize * blockCnt);
-
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-
-        // Write one more block what should cause eviction.
-        append(FILE_RMT, blockSize);
-
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-
-        // Read the first block.
-        read(FILE_RMT, 0, blockSize);
-
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-        checkMetrics(1, 1);
-    }
-
-    /**
-     * Test eviction caused by too big data size.
-     *
-     * @throws Exception If failed.
-     */
-    public void testDataSizeEviction() throws Exception {
-        start();
-
-        igfsPrimary.create(FILE_RMT, true).close();
-
-        int blockCnt = 3;
-        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
-
-        evictPlc.setMaxSize(blockSize * blockCnt);
-
-        // Write blocks up to the limit.
-        append(FILE_RMT, blockSize * blockCnt);
-
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-
-        // Reset metrics.
-        igfsPrimary.resetMetrics();
-
-        // Read the first block what should cause reordering.
-        read(FILE_RMT, 0, blockSize);
-
-        checkMetrics(1, 0);
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-
-        // Write one more block what should cause eviction of the block 2.
-        append(FILE_RMT, blockSize);
-
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-
-        // Read the first block.
-        read(FILE_RMT, 0, blockSize);
-
-        checkMetrics(2, 0);
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-
-        // Read the second block (which was evicted).
-        read(FILE_RMT, blockSize, blockSize);
-
-        checkMetrics(3, 1);
-        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
-    }
-
-    /**
-     * Read some data from the given file with the given offset.
-     *
-     * @param path File path.
-     * @param off Offset.
-     * @param len Length.
-     * @throws Exception If failed.
-     */
-    private void read(IgfsPath path, int off, int len) throws Exception {
-        IgfsInputStream is = igfsPrimary.open(path);
-
-        is.readFully(off, new byte[len]);
-
-        is.close();
-    }
-
-    /**
-     * Append some data to the given file.
-     *
-     * @param path File path.
-     * @param len Data length.
-     * @throws Exception If failed.
-     */
-    private void append(IgfsPath path, int len) throws Exception {
-        IgfsOutputStream os = igfsPrimary.append(path, false);
-
-        os.write(new byte[len]);
-
-        os.close();
-    }
-
-    /**
-     * Check metrics counters.
-     *
-     * @param blocksRead Expected blocks read.
-     * @param blocksReadRmt Expected blocks read remote.
-     * @throws Exception If failed.
-     */
-    public void checkMetrics(final long blocksRead, final long blocksReadRmt) throws Exception {
-        assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                IgfsMetrics metrics = igfsPrimary.metrics();
-
-                return metrics.blocksReadTotal() == blocksRead && metrics.blocksReadRemote() == blocksReadRmt;
-            }
-        }, 5000) : "Unexpected metrics [expectedBlocksReadTotal=" + blocksRead + ", actualBlocksReadTotal=" +
-            igfsPrimary.metrics().blocksReadTotal() + ", expectedBlocksReadRemote=" + blocksReadRmt +
-            ", actualBlocksReadRemote=" + igfsPrimary.metrics().blocksReadRemote() + ']';
-    }
-
-    /**
-     * Check eviction policy state.
-     *
-     * @param curBlocks Current blocks.
-     * @param curBytes Current bytes.
-     */
-    private void checkEvictionPolicy(final int curBlocks, final long curBytes) throws IgniteInterruptedCheckedException {
-        assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                return evictPlc.getCurrentBlocks() == curBlocks && evictPlc.getCurrentSize() == curBytes;
-            }
-        }, 5000) : "Unexpected counts [expectedBlocks=" + curBlocks + ", actualBlocks=" + evictPlc.getCurrentBlocks() +
-            ", expectedBytes=" + curBytes + ", currentBytes=" + curBytes + ']';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 12ef0c1..31fc4a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -155,7 +155,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         igfsSecondary = (IgfsImpl) igniteSecondary.fileSystem("igfs-secondary");
 
-        Ignite ignite = startGridWithIgfs("ignite", "igfs", mode, igfsSecondary, PRIMARY_REST_CFG);
+        Ignite ignite = startGridWithIgfs("ignite", "igfs", mode, igfsSecondary.asSecondary(), PRIMARY_REST_CFG);
 
         igfs = (IgfsImpl) ignite.fileSystem("igfs");
     }
@@ -263,7 +263,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testExists() throws Exception {
-        create(igfs, paths(DIR), null);
+        create(igfs.asSecondary(), paths(DIR), null);
 
         checkExist(igfs, igfsSecondary, DIR);
     }
@@ -374,7 +374,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         IgfsPath file1 = new IgfsPath("/file1");
         IgfsPath file2 = new IgfsPath("/file2");
 
-        create(igfs, null, paths(file1));
+        create(igfs.asSecondary(), null, paths(file1));
 
         igfs.rename(file1, file2);
 
@@ -406,7 +406,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         IgfsPath dir1 = new IgfsPath("/dir1");
         IgfsPath dir2 = new IgfsPath("/dir2");
 
-        create(igfs, paths(dir1), null);
+        create(igfs.asSecondary(), paths(dir1), null);
 
         igfs.rename(dir1, dir2);
 
@@ -435,7 +435,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testMoveFileDestinationRoot() throws Exception {
-        create(igfs, paths(DIR, SUBDIR), paths(FILE));
+        create(igfs.asSecondary(), paths(DIR, SUBDIR), paths(FILE));
 
         igfs.rename(FILE, new IgfsPath());
 
@@ -527,7 +527,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testMoveDirectoryDestinationRoot() throws Exception {
-        create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), null);
+        create(igfs.asSecondary(), paths(DIR, SUBDIR, SUBSUBDIR), null);
 
         igfs.rename(SUBSUBDIR, new IgfsPath());
 
@@ -543,7 +543,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testMoveDirectorySourceParentRoot() throws Exception {
         IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name());
 
-        create(igfs, paths(DIR_NEW, SUBDIR_NEW, dir), null);
+        create(igfs.asSecondary(), paths(DIR_NEW, SUBDIR_NEW, dir), null);
 
         igfs.rename(dir, SUBDIR_NEW);
 
@@ -852,7 +852,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testOpen() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, true, chunk);
+        createFile(igfs.asSecondary(), FILE, true, chunk);
 
         checkFileContent(igfs, FILE, chunk);
     }
@@ -887,9 +887,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testCreate() throws Exception {
-        create(igfs, paths(DIR, SUBDIR), null);
+        create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, true, chunk);
+        createFile(igfs.asSecondary(), FILE, true, chunk);
 
         checkFile(igfs, igfsSecondary, FILE, chunk);
     }
@@ -902,7 +902,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testCreateParentRoot() throws Exception {
         IgfsPath file = new IgfsPath("/" + FILE.name());
 
-        createFile(igfs, file, true, chunk);
+        createFile(igfs.asSecondary(), file, true, chunk);
 
         checkFile(igfs, igfsSecondary, file, chunk);
     }
@@ -1093,7 +1093,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
                         assert igfs.exists(path);
                     }
 
-                    awaitFileClose(igfs, path);
+                    awaitFileClose(igfs.asSecondary(), path);
 
                     checkFileContent(igfs, path, chunk);
                 }
@@ -1167,7 +1167,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         fut.get();
 
-        awaitFileClose(igfs, FILE);
+        awaitFileClose(igfs.asSecondary(), FILE);
 
         if (err.get() != null)
             throw err.get();
@@ -1213,7 +1213,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testAppendNoClose() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, false);
+        createFile(igfs.asSecondary(), FILE, false);
 
         GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -1242,7 +1242,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testAppendRenameNoClose() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, false);
+        createFile(igfs.asSecondary(), FILE, false);
 
         IgfsOutputStream os = null;
 
@@ -1264,9 +1264,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testAppendRenameParentNoClose() throws Exception {
-        create(igfs, paths(DIR, SUBDIR), null);
+        create(igfs.asSecondary(), paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, false);
+        createFile(igfs.asSecondary(), FILE, false);
 
         IgfsOutputStream os = null;
 
@@ -1290,7 +1290,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testAppendDeleteNoClose() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, false);
+        createFile(igfs.asSecondary(), FILE, false);
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -1322,7 +1322,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testAppendDeleteParentNoClose() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, false);
+        createFile(igfs.asSecondary(), FILE, false);
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -1361,7 +1361,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         create(igfs, paths(DIR, SUBDIR), null);
 
-        createFile(igfs, FILE, false);
+        createFile(igfs.asSecondary(), FILE, false);
 
         IgfsOutputStream os = null;
 
@@ -1389,7 +1389,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         int threadCnt = 10;
 
         for (int i = 0; i < threadCnt; i++)
-            createFile(igfs, new IgfsPath("/file" + i), false);
+            createFile(igfs.asSecondary(), new IgfsPath("/file" + i), false);
 
         multithreaded(new Runnable() {
             @Override public void run() {
@@ -1412,7 +1412,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
                         assert igfs.exists(path);
                     }
 
-                    awaitFileClose(igfs, path);
+                    awaitFileClose(igfs.asSecondary(), path);
 
                     checkFileContent(igfs, path, chunks);
                 }
@@ -1484,7 +1484,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         fut.get();
 
-        awaitFileClose(igfs, FILE);
+        awaitFileClose(igfs.asSecondary(), FILE);
 
         if (err.get() != null)
             throw err.get();
@@ -2138,6 +2138,18 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @param files Files.
      * @throws Exception If failed.
      */
+    public static void create(IgfsImpl igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception {
+        create(igfs.asSecondary(), dirs, files);
+    }
+
+    /**
+     * Create the given directories and files in the given IGFS.
+     *
+     * @param igfs IGFS.
+     * @param dirs Directories.
+     * @param files Files.
+     * @throws Exception If failed.
+     */
     public static void create(IgfsSecondaryFileSystem igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files)
         throws Exception {
         if (dirs != null) {
@@ -2189,7 +2201,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @param chunks Data chunks.
      * @throws Exception If failed.
      */
-    protected void createFile(IgniteFileSystem igfs, IgfsPath file, boolean overwrite, long blockSize,
+    protected void createFile(IgfsImpl igfs, IgfsPath file, boolean overwrite, long blockSize,
         @Nullable byte[]... chunks) throws Exception {
         IgfsOutputStream os = null;
 
@@ -2201,7 +2213,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         finally {
             U.closeQuiet(os);
 
-            awaitFileClose(igfs, file);
+            awaitFileClose(igfs.asSecondary(), file);
         }
     }
 
@@ -2213,7 +2225,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @param chunks Data chunks.
      * @throws Exception If failed.
      */
-    protected void appendFile(IgniteFileSystem igfs, IgfsPath file, @Nullable byte[]... chunks)
+    protected void appendFile(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
         throws Exception {
         IgfsOutputStream os = null;
 
@@ -2225,7 +2237,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         finally {
             U.closeQuiet(os);
 
-            awaitFileClose(igfs, file);
+            awaitFileClose(igfs.asSecondary(), file);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
new file mode 100644
index 0000000..e4b2913
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
@@ -0,0 +1,485 @@
+/*
+ * 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.igfs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.eviction.igfs.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.igfs.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.igfs.IgfsMode.*;
+
+/**
+ * Tests for IGFS per-block LR eviction policy.
+ */
+@SuppressWarnings({"ConstantConditions", "ThrowableResultOfMethodCallIgnored"})
+public class IgfsCachePerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstractTest {
+    /** Primary IGFS name. */
+    private static final String IGFS_PRIMARY = "igfs-primary";
+
+    /** Primary IGFS name. */
+    private static final String IGFS_SECONDARY = "igfs-secondary";
+
+    /** Secondary file system REST endpoint configuration map. */
+    private static final Map<String, String> SECONDARY_REST_CFG = new HashMap<String, String>() {{
+        put("type", "tcp");
+        put("port", "11500");
+    }};
+
+    /** File working in PRIMARY mode. */
+    public static final IgfsPath FILE = new IgfsPath("/file");
+
+    /** File working in DUAL mode. */
+    public static final IgfsPath FILE_RMT = new IgfsPath("/fileRemote");
+
+    /** Primary IGFS instances. */
+    private static IgfsImpl igfsPrimary;
+
+    /** Secondary IGFS instance. */
+    private static IgfsImpl secondaryFs;
+
+    /** Primary file system data cache. */
+    private static GridCacheAdapter<IgfsBlockKey, byte[]> dataCache;
+
+    /** Eviction policy */
+    private static CacheIgfsPerBlockLruEvictionPolicy evictPlc;
+
+    /**
+     * Start a grid with the primary file system.
+     *
+     * @throws Exception If failed.
+     */
+    private void startPrimary() throws Exception {
+        IgfsConfiguration igfsCfg = new IgfsConfiguration();
+
+        igfsCfg.setDataCacheName("dataCache");
+        igfsCfg.setMetaCacheName("metaCache");
+        igfsCfg.setName(IGFS_PRIMARY);
+        igfsCfg.setBlockSize(512);
+        igfsCfg.setDefaultMode(PRIMARY);
+        igfsCfg.setPrefetchBlocks(1);
+        igfsCfg.setSequentialReadsBeforePrefetch(Integer.MAX_VALUE);
+        igfsCfg.setSecondaryFileSystem(secondaryFs.asSecondary());
+
+        Map<String, IgfsMode> pathModes = new HashMap<>();
+
+        pathModes.put(FILE_RMT.toString(), DUAL_SYNC);
+
+        igfsCfg.setPathModes(pathModes);
+
+        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
+
+        dataCacheCfg.setName("dataCache");
+        dataCacheCfg.setCacheMode(PARTITIONED);
+        dataCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
+        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+        evictPlc = new CacheIgfsPerBlockLruEvictionPolicy();
+
+        dataCacheCfg.setEvictionPolicy(evictPlc);
+        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
+        dataCacheCfg.setBackups(0);
+        dataCacheCfg.setQueryIndexEnabled(false);
+
+        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
+
+        metaCacheCfg.setName("metaCache");
+        metaCacheCfg.setCacheMode(REPLICATED);
+        metaCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
+        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        metaCacheCfg.setQueryIndexEnabled(false);
+        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setGridName("grid-primary");
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+        cfg.setDiscoverySpi(discoSpi);
+        cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+        cfg.setIgfsConfiguration(igfsCfg);
+
+        cfg.setLocalHost("127.0.0.1");
+        cfg.setConnectorConfiguration(null);
+
+        Ignite g = G.start(cfg);
+
+        igfsPrimary = (IgfsImpl)g.fileSystem(IGFS_PRIMARY);
+
+        dataCache = igfsPrimary.context().kernalContext().cache().internalCache(
+            igfsPrimary.context().configuration().getDataCacheName());
+    }
+
+    /**
+     * Start a grid with the secondary file system.
+     *
+     * @throws Exception If failed.
+     */
+    private void startSecondary() throws Exception {
+        IgfsConfiguration igfsCfg = new IgfsConfiguration();
+
+        igfsCfg.setDataCacheName("dataCache");
+        igfsCfg.setMetaCacheName("metaCache");
+        igfsCfg.setName(IGFS_SECONDARY);
+        igfsCfg.setBlockSize(512);
+        igfsCfg.setDefaultMode(PRIMARY);
+        igfsCfg.setIpcEndpointConfiguration(SECONDARY_REST_CFG);
+
+        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
+
+        dataCacheCfg.setName("dataCache");
+        dataCacheCfg.setCacheMode(PARTITIONED);
+        dataCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
+        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
+        dataCacheCfg.setBackups(0);
+        dataCacheCfg.setQueryIndexEnabled(false);
+        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
+
+        metaCacheCfg.setName("metaCache");
+        metaCacheCfg.setCacheMode(REPLICATED);
+        metaCacheCfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
+        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        metaCacheCfg.setQueryIndexEnabled(false);
+        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setGridName("grid-secondary");
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+        cfg.setDiscoverySpi(discoSpi);
+        cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+        cfg.setIgfsConfiguration(igfsCfg);
+
+        cfg.setLocalHost("127.0.0.1");
+        cfg.setConnectorConfiguration(null);
+
+        Ignite g = G.start(cfg);
+
+        secondaryFs = (IgfsImpl)g.fileSystem(IGFS_SECONDARY);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        try {
+            // Cleanup.
+            igfsPrimary.format();
+
+            while (!dataCache.isEmpty())
+                U.sleep(100);
+
+            checkEvictionPolicy(0, 0);
+        }
+        finally {
+            stopAllGrids(false);
+        }
+    }
+
+    /**
+     * Startup primary and secondary file systems.
+     *
+     * @throws Exception If failed.
+     */
+    private void start() throws Exception {
+        startSecondary();
+        startPrimary();
+
+        evictPlc.setMaxBlocks(0);
+        evictPlc.setMaxSize(0);
+        evictPlc.setExcludePaths(null);
+    }
+
+    /**
+     * Test how evictions are handled for a file working in PRIMARY mode.
+     *
+     * @throws Exception If failed.
+     */
+    public void testFilePrimary() throws Exception {
+        start();
+
+        // Create file in primary mode. It must not be propagated to eviction policy.
+        igfsPrimary.create(FILE, true).close();
+
+        checkEvictionPolicy(0, 0);
+
+        int blockSize = igfsPrimary.info(FILE).blockSize();
+
+        append(FILE, blockSize);
+
+        checkEvictionPolicy(0, 0);
+
+        read(FILE, 0, blockSize);
+
+        checkEvictionPolicy(0, 0);
+    }
+
+    /**
+     * Test how evictions are handled for a file working in PRIMARY mode.
+     *
+     * @throws Exception If failed.
+     */
+    public void testFileDual() throws Exception {
+        start();
+
+        igfsPrimary.create(FILE_RMT, true).close();
+
+        checkEvictionPolicy(0, 0);
+
+        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
+
+        // File write.
+        append(FILE_RMT, blockSize);
+
+        checkEvictionPolicy(1, blockSize);
+
+        // One more write.
+        append(FILE_RMT, blockSize);
+
+        checkEvictionPolicy(2, blockSize * 2);
+
+        // Read.
+        read(FILE_RMT, 0, blockSize);
+
+        checkEvictionPolicy(2, blockSize * 2);
+    }
+
+    /**
+     * Ensure that a DUAL mode file is not propagated to eviction policy
+     *
+     * @throws Exception If failed.
+     */
+    public void testFileDualExclusion() throws Exception {
+        start();
+
+        evictPlc.setExcludePaths(Collections.singleton(FILE_RMT.toString()));
+
+        // Create file in primary mode. It must not be propagated to eviction policy.
+        igfsPrimary.create(FILE_RMT, true).close();
+
+        checkEvictionPolicy(0, 0);
+
+        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
+
+        append(FILE_RMT, blockSize);
+
+        checkEvictionPolicy(0, 0);
+
+        read(FILE_RMT, 0, blockSize);
+
+        checkEvictionPolicy(0, 0);
+    }
+
+    /**
+     * Ensure that exception is thrown in case we are trying to rename file with one exclude setting to the file with
+     * another.
+     *
+     * @throws Exception If failed.
+     */
+    public void testRenameDifferentExcludeSettings() throws Exception {
+        start();
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                igfsPrimary.rename(FILE, FILE_RMT);
+
+                return null;
+            }
+        }, IgfsInvalidPathException.class, "Cannot move file to a path with different eviction exclude setting " +
+            "(need to copy and remove)");
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                igfsPrimary.rename(FILE_RMT, FILE);
+
+                return null;
+            }
+        }, IgfsInvalidPathException.class, "Cannot move file to a path with different eviction exclude setting " +
+            "(need to copy and remove)");
+    }
+
+    /**
+     * Test eviction caused by too much blocks.
+     *
+     * @throws Exception If failed.
+     */
+    public void testBlockCountEviction() throws Exception {
+        start();
+
+        int blockCnt = 3;
+
+        evictPlc.setMaxBlocks(blockCnt);
+
+        igfsPrimary.create(FILE_RMT, true).close();
+
+        checkEvictionPolicy(0, 0);
+
+        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
+
+        // Write blocks up to the limit.
+        append(FILE_RMT, blockSize * blockCnt);
+
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+
+        // Write one more block what should cause eviction.
+        append(FILE_RMT, blockSize);
+
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+
+        // Read the first block.
+        read(FILE_RMT, 0, blockSize);
+
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+        checkMetrics(1, 1);
+    }
+
+    /**
+     * Test eviction caused by too big data size.
+     *
+     * @throws Exception If failed.
+     */
+    public void testDataSizeEviction() throws Exception {
+        start();
+
+        igfsPrimary.create(FILE_RMT, true).close();
+
+        int blockCnt = 3;
+        int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
+
+        evictPlc.setMaxSize(blockSize * blockCnt);
+
+        // Write blocks up to the limit.
+        append(FILE_RMT, blockSize * blockCnt);
+
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+
+        // Reset metrics.
+        igfsPrimary.resetMetrics();
+
+        // Read the first block what should cause reordering.
+        read(FILE_RMT, 0, blockSize);
+
+        checkMetrics(1, 0);
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+
+        // Write one more block what should cause eviction of the block 2.
+        append(FILE_RMT, blockSize);
+
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+
+        // Read the first block.
+        read(FILE_RMT, 0, blockSize);
+
+        checkMetrics(2, 0);
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+
+        // Read the second block (which was evicted).
+        read(FILE_RMT, blockSize, blockSize);
+
+        checkMetrics(3, 1);
+        checkEvictionPolicy(blockCnt, blockCnt * blockSize);
+    }
+
+    /**
+     * Read some data from the given file with the given offset.
+     *
+     * @param path File path.
+     * @param off Offset.
+     * @param len Length.
+     * @throws Exception If failed.
+     */
+    private void read(IgfsPath path, int off, int len) throws Exception {
+        IgfsInputStream is = igfsPrimary.open(path);
+
+        is.readFully(off, new byte[len]);
+
+        is.close();
+    }
+
+    /**
+     * Append some data to the given file.
+     *
+     * @param path File path.
+     * @param len Data length.
+     * @throws Exception If failed.
+     */
+    private void append(IgfsPath path, int len) throws Exception {
+        IgfsOutputStream os = igfsPrimary.append(path, false);
+
+        os.write(new byte[len]);
+
+        os.close();
+    }
+
+    /**
+     * Check metrics counters.
+     *
+     * @param blocksRead Expected blocks read.
+     * @param blocksReadRmt Expected blocks read remote.
+     * @throws Exception If failed.
+     */
+    public void checkMetrics(final long blocksRead, final long blocksReadRmt) throws Exception {
+        assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                IgfsMetrics metrics = igfsPrimary.metrics();
+
+                return metrics.blocksReadTotal() == blocksRead && metrics.blocksReadRemote() == blocksReadRmt;
+            }
+        }, 5000) : "Unexpected metrics [expectedBlocksReadTotal=" + blocksRead + ", actualBlocksReadTotal=" +
+            igfsPrimary.metrics().blocksReadTotal() + ", expectedBlocksReadRemote=" + blocksReadRmt +
+            ", actualBlocksReadRemote=" + igfsPrimary.metrics().blocksReadRemote() + ']';
+    }
+
+    /**
+     * Check eviction policy state.
+     *
+     * @param curBlocks Current blocks.
+     * @param curBytes Current bytes.
+     */
+    private void checkEvictionPolicy(final int curBlocks, final long curBytes) throws IgniteInterruptedCheckedException {
+        assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return evictPlc.getCurrentBlocks() == curBlocks && evictPlc.getCurrentSize() == curBytes;
+            }
+        }, 5000) : "Unexpected counts [expectedBlocks=" + curBlocks + ", actualBlocks=" + evictPlc.getCurrentBlocks() +
+            ", expectedBytes=" + curBytes + ", currentBytes=" + curBytes + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
index 2e48648..2af01bf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
@@ -24,7 +24,6 @@ import org.apache.ignite.igfs.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
index 3a0f90a..f44a988 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
@@ -1120,7 +1120,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
         create(igfsSecondary, paths(DIR, SUBDIR), null);
         create(igfs, null, null);
 
-        createFile(igfsSecondary, FILE, true, chunk);
+        createFile(igfsSecondary.asSecondary(), FILE, true, chunk);
 
         checkFileContent(igfs, FILE, chunk);
     }
@@ -1148,7 +1148,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
 
         out.close();
 
-        awaitFileClose(igfsSecondary, FILE);
+        awaitFileClose(igfsSecondary.asSecondary(), FILE);
 
         // Read the first block.
         int totalRead = 0;
@@ -1227,7 +1227,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
 
         out.close();
 
-        awaitFileClose(igfsSecondary, FILE);
+        awaitFileClose(igfsSecondary.asSecondary(), FILE);
 
         // Read the first two blocks.
         int totalRead = 0;
@@ -1292,7 +1292,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
 
         igfsSecondary.update(SUBDIR, props);
 
-        createFile(igfs, FILE, true, chunk);
+        createFile(igfs.asSecondary(), FILE, true, chunk);
 
         // Ensure that directory structure was created.
         checkExist(igfs, igfsSecondary, SUBDIR);
@@ -1317,7 +1317,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
         igfsSecondary.update(DIR, propsDir);
         igfsSecondary.update(SUBDIR, propsSubDir);
 
-        createFile(igfs, FILE, true, chunk);
+        createFile(igfs.asSecondary(), FILE, true, chunk);
 
         checkExist(igfs, igfsSecondary, SUBDIR);
         checkFile(igfs, igfsSecondary, FILE, chunk);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
index d6caf27..0739148 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
@@ -59,7 +59,7 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
     private static IgniteFileSystem[] igfsPrimary;
 
     /** Secondary IGFS instance. */
-    private static IgniteFileSystem igfsSecondary;
+    private static IgfsImpl igfsSecondary;
 
     /** Primary file system block size. */
     public static final int PRIMARY_BLOCK_SIZE = 512;
@@ -108,7 +108,7 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         igfsCfg.setName(IGFS_PRIMARY);
         igfsCfg.setBlockSize(PRIMARY_BLOCK_SIZE);
         igfsCfg.setDefaultMode(PRIMARY);
-        igfsCfg.setSecondaryFileSystem(igfsSecondary);
+        igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());
 
         Map<String, IgfsMode> pathModes = new HashMap<>();
 
@@ -204,7 +204,7 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
 
         Ignite g = G.start(cfg);
 
-        igfsSecondary = g.fileSystem(IGFS_SECONDARY);
+        igfsSecondary = (IgfsImpl)g.fileSystem(IGFS_SECONDARY);
     }
 
     /** @throws Exception If failed. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
index 2b501f7..1a37e93 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
@@ -97,7 +97,7 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
         igfsCfg.setPathModes(pathModes);
 
         if (setSecondaryFs)
-            igfsCfg.setSecondaryFileSystem(igfsSecondary);
+            igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());
 
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index 8f06117..cea510a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -48,7 +48,7 @@ public class IgniteIgfsTestSuite extends TestSuite {
         if (U.isWindows())
             suite.addTest(new TestSuite(IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.class));
 
-        suite.addTest(new TestSuite(GridCacheIgfsPerBlockLruEvictionPolicySelfTest.class));
+        suite.addTest(new TestSuite(IgfsCachePerBlockLruEvictionPolicySelfTest.class));
 
         suite.addTest(new TestSuite(IgfsStreamsSelfTest.class));
         suite.addTest(new TestSuite(IgfsModesSelfTest.class));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
index a86b335..a7fa88e 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
@@ -236,7 +236,7 @@ public abstract class HadoopIgfsDualAbstractSelfTest extends IgfsCommonAbstractT
 
         out.close();
 
-        awaitFileClose(igfsSecondary, FILE);
+        awaitFileClose(igfsSecondary.asSecondary(), FILE);
 
         // Instantiate file system with overridden "seq reads before prefetch" property.
         Configuration cfg = new Configuration();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d83c88af/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
index f43419c..318dfb9 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.igfs.*;
 import org.apache.ignite.igfs.mapreduce.*;
+import org.apache.ignite.igfs.secondary.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.cluster.*;
 import org.apache.ignite.internal.processors.cache.*;
@@ -815,11 +816,6 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
         }
 
         /** {@inheritDoc} */
-        @Override public Map<String, String> properties() {
-            return Collections.emptyMap();
-        }
-
-        /** {@inheritDoc} */
         @Override public IgfsOutputStream create(IgfsPath path, boolean overwrite) {
             return null;
         }
@@ -916,6 +912,11 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
         @Override public <R> IgniteFuture<R> future() {
             return null;
         }
+
+        /** {@inheritDoc} */
+        @Override public IgfsSecondaryFileSystem asSecondary() {
+            return null;
+        }
     }
 
     /**