http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java
deleted file mode 100644
index 0ecace5..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java
+++ /dev/null
@@ -1,50 +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.cache.eviction.fifo;
-
-import org.apache.ignite.mxbean.*;
-
-/**
- * MBean for {@code FIFO} eviction policy.
- */
-@MXBeanDescription("MBean for FIFO cache eviction policy.")
-public interface CacheFifoEvictionPolicyMBean {
-    /**
-     * Gets maximum allowed cache size.
-     *
-     * @return Maximum allowed cache size.
-     */
-    @MXBeanDescription("Maximum allowed cache size.")
-    public int getMaxSize();
-
-    /**
-     * Sets maximum allowed cache size.
-     *
-     * @param max Maximum allowed cache size.
-     */
-    @MXBeanDescription("Set maximum allowed cache size.")
-    public void setMaxSize(int max);
-
-    /**
-     * Gets current queue size.
-     *
-     * @return Current queue size.
-     */
-    @MXBeanDescription("Current FIFO queue size.")
-    public int getCurrentSize();
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
new file mode 100644
index 0000000..d32c746
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.fifo;
+
+import org.apache.ignite.cache.eviction.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jsr166.*;
+import org.jsr166.ConcurrentLinkedDeque8.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Eviction policy based on {@code First In First Out (FIFO)} algorithm. This
+ * implementation is very efficient since it does not create any additional
+ * table-like data structures. The {@code FIFO} ordering information is
+ * maintained by attaching ordering metadata to cache entries.
+ */
+public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K, V>, 
FifoEvictionPolicyMBean, Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Maximum size. */
+    private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE;
+
+    /** FIFO queue. */
+    private final ConcurrentLinkedDeque8<EvictableEntry<K, V>> queue =
+        new ConcurrentLinkedDeque8<>();
+
+    /**
+     * Constructs FIFO eviction policy with all defaults.
+     */
+    public FifoEvictionPolicy() {
+        // No-op.
+    }
+
+    /**
+     * Constructs FIFO eviction policy with maximum size. Empty entries are 
allowed.
+     *
+     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
+     */
+    public FifoEvictionPolicy(int max) {
+        A.ensure(max > 0, "max > 0");
+
+        this.max = max;
+    }
+
+    /**
+     * Gets maximum allowed size of cache before entry will start getting 
evicted.
+     *
+     * @return Maximum allowed size of cache before entry will start getting 
evicted.
+     */
+    @Override public int getMaxSize() {
+        return max;
+    }
+
+    /**
+     * Sets maximum allowed size of cache before entry will start getting 
evicted.
+     *
+     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
+     */
+    @Override public void setMaxSize(int max) {
+        A.ensure(max > 0, "max > 0");
+
+        this.max = max;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentSize() {
+        return queue.size();
+    }
+
+    /**
+     * Gets read-only view on internal {@code FIFO} queue in proper order.
+     *
+     * @return Read-only view ono internal {@code 'FIFO'} queue.
+     */
+    public Collection<EvictableEntry<K, V>> queue() {
+        return Collections.unmodifiableCollection(queue);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> 
entry) {
+        if (!rmv) {
+            if (!entry.isCached())
+                return;
+
+            // Shrink only if queue was changed.
+            if (touch(entry))
+                shrink();
+        }
+        else {
+            Node<EvictableEntry<K, V>> node = entry.removeMeta();
+
+            if (node != null)
+                queue.unlinkx(node);
+        }
+    }
+
+    /**
+     * @param entry Entry to touch.
+     * @return {@code True} if queue has been changed by this call.
+     */
+    private boolean touch(EvictableEntry<K, V> entry) {
+        Node<EvictableEntry<K, V>> node = entry.meta();
+
+        // Entry has not been enqueued yet.
+        if (node == null) {
+            while (true) {
+                node = queue.offerLastx(entry);
+
+                if (entry.putMetaIfAbsent(node) != null) {
+                    // Was concurrently added, need to clear it from queue.
+                    queue.unlinkx(node);
+
+                    // Queue has not been changed.
+                    return false;
+                }
+                else if (node.item() != null) {
+                    if (!entry.isCached()) {
+                        // Was concurrently evicted, need to clear it from 
queue.
+                        queue.unlinkx(node);
+
+                        return false;
+                    }
+
+                    return true;
+                }
+                // If node was unlinked by concurrent shrink() call, we must 
repeat the whole cycle.
+                else if (!entry.removeMeta(node))
+                    return false;
+            }
+        }
+
+        // Entry is already in queue.
+        return false;
+    }
+
+    /**
+     * Shrinks FIFO queue to maximum allowed size.
+     */
+    private void shrink() {
+        int max = this.max;
+
+        int startSize = queue.sizex();
+
+        for (int i = 0; i < startSize && queue.sizex() > max; i++) {
+            EvictableEntry<K, V> entry = queue.poll();
+
+            if (entry == null)
+                break;
+
+            if (!entry.evict()) {
+                entry.removeMeta();
+
+                touch(entry);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(max);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        max = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(FifoEvictionPolicy.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicyMBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicyMBean.java
new file mode 100644
index 0000000..4827e95
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicyMBean.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.fifo;
+
+import org.apache.ignite.mxbean.*;
+
+/**
+ * MBean for {@code FIFO} eviction policy.
+ */
+@MXBeanDescription("MBean for FIFO cache eviction policy.")
+public interface FifoEvictionPolicyMBean {
+    /**
+     * Gets maximum allowed cache size.
+     *
+     * @return Maximum allowed cache size.
+     */
+    @MXBeanDescription("Maximum allowed cache size.")
+    public int getMaxSize();
+
+    /**
+     * Sets maximum allowed cache size.
+     *
+     * @param max Maximum allowed cache size.
+     */
+    @MXBeanDescription("Set maximum allowed cache size.")
+    public void setMaxSize(int max);
+
+    /**
+     * Gets current queue size.
+     *
+     * @return Current queue size.
+     */
+    @MXBeanDescription("Current FIFO queue size.")
+    public int getCurrentSize();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsEvictionFilter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsEvictionFilter.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsEvictionFilter.java
deleted file mode 100644
index 47f97e5..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsEvictionFilter.java
+++ /dev/null
@@ -1,38 +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.cache.eviction.igfs;
-
-import org.apache.ignite.cache.eviction.*;
-import org.apache.ignite.internal.processors.igfs.*;
-
-import javax.cache.*;
-
-/**
- * IGFS eviction filter which will not evict blocks of particular files.
- */
-public class CacheIgfsEvictionFilter implements CacheEvictionFilter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** {@inheritDoc} */
-    @Override public boolean evictAllowed(Cache.Entry entry) {
-        Object key = entry.getKey();
-
-        return !(key instanceof IgfsBlockKey && 
((IgfsBlockKey)key).evictExclude());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicy.java
deleted file mode 100644
index 83b7d9b..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicy.java
+++ /dev/null
@@ -1,378 +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.cache.eviction.igfs;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.eviction.*;
-import org.apache.ignite.igfs.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.igfs.*;
-import org.jsr166.*;
-import org.jsr166.ConcurrentLinkedDeque8.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.atomic.*;
-import java.util.regex.*;
-
-/**
- * IGFS eviction policy which evicts particular blocks.
- */
-public class CacheIgfsPerBlockLruEvictionPolicy implements 
CacheEvictionPolicy<IgfsBlockKey, byte[]>,
-    CacheIgfsPerBlockLruEvictionPolicyMXBean, Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Maximum size. When reached, eviction begins. */
-    private volatile long maxSize;
-
-    /** Maximum amount of blocks. When reached, eviction begins. */
-    private volatile int maxBlocks;
-
-    /** Collection of regex for paths which must not be evicted. */
-    private volatile Collection<String> excludePaths;
-
-    /** Exclusion patterns. */
-    private volatile Collection<Pattern> excludePatterns;
-
-    /** Whether patterns must be recompiled during the next call. */
-    private final AtomicBoolean excludeRecompile = new AtomicBoolean(true);
-
-    /** Queue. */
-    private final ConcurrentLinkedDeque8<CacheEvictableEntry<IgfsBlockKey, 
byte[]>> queue =
-        new ConcurrentLinkedDeque8<>();
-
-    /** Current size of all enqueued blocks in bytes. */
-    private final LongAdder8 curSize = new LongAdder8();
-
-    /**
-     * Default constructor.
-     */
-    public CacheIgfsPerBlockLruEvictionPolicy() {
-        // No-op.
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param maxSize Maximum size. When reached, eviction begins.
-     * @param maxBlocks Maximum amount of blocks. When reached, eviction 
begins.
-     */
-    public CacheIgfsPerBlockLruEvictionPolicy(long maxSize, int maxBlocks) {
-        this(maxSize, maxBlocks, null);
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param maxSize Maximum size. When reached, eviction begins.
-     * @param maxBlocks Maximum amount of blocks. When reached, eviction 
begins.
-     * @param excludePaths Collection of regex for path which must not be 
evicted.
-     */
-    public CacheIgfsPerBlockLruEvictionPolicy(long maxSize, int maxBlocks,
-        @Nullable Collection<String> excludePaths) {
-        this.maxSize = maxSize;
-        this.maxBlocks = maxBlocks;
-        this.excludePaths = excludePaths;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onEntryAccessed(boolean rmv, 
CacheEvictableEntry<IgfsBlockKey, byte[]> entry) {
-        if (!rmv) {
-            if (!entry.isCached())
-                return;
-
-            if (touch(entry))
-                shrink();
-        }
-        else {
-            MetaEntry meta = entry.removeMeta();
-
-            if (meta != null && queue.unlinkx(meta.node()))
-                changeSize(-meta.size());
-        }
-    }
-
-    /**
-     * @param entry Entry to touch.
-     * @return {@code True} if new node has been added to queue by this call.
-     */
-    private boolean touch(CacheEvictableEntry<IgfsBlockKey, byte[]> entry) {
-        byte[] val = peek(entry);
-
-        int blockSize = val != null ? val.length : 0;
-
-        MetaEntry meta = entry.meta();
-
-        // Entry has not been enqueued yet.
-        if (meta == null) {
-            while (true) {
-                Node<CacheEvictableEntry<IgfsBlockKey, byte[]>> node = 
queue.offerLastx(entry);
-
-                meta = new MetaEntry(node, blockSize);
-
-                if (entry.putMetaIfAbsent(meta) != null) {
-                    // Was concurrently added, need to clear it from queue.
-                    queue.unlinkx(node);
-
-                    // Queue has not been changed.
-                    return false;
-                }
-                else if (node.item() != null) {
-                    if (!entry.isCached()) {
-                        // Was concurrently evicted, need to clear it from 
queue.
-                        queue.unlinkx(node);
-
-                        return false;
-                    }
-
-                    // Increment current size.
-                    changeSize(blockSize);
-
-                    return true;
-                }
-                // If node was unlinked by concurrent shrink() call, we must 
repeat the whole cycle.
-                else if (!entry.removeMeta(node))
-                    return false;
-            }
-        }
-        else {
-            int oldBlockSize = meta.size();
-
-            Node<CacheEvictableEntry<IgfsBlockKey, byte[]>> node = meta.node();
-
-            if (queue.unlinkx(node)) {
-                // Move node to tail.
-                Node<CacheEvictableEntry<IgfsBlockKey, byte[]>> newNode = 
queue.offerLastx(entry);
-
-                int delta = blockSize - oldBlockSize;
-
-                if (!entry.replaceMeta(meta, new MetaEntry(newNode, 
blockSize))) {
-                    // Was concurrently added, need to clear it from queue.
-                    if (queue.unlinkx(newNode))
-                        delta -= blockSize;
-                }
-
-                if (delta != 0) {
-                    changeSize(delta);
-
-                   if (delta > 0)
-                       // Total size increased, so shrinking could be needed.
-                       return true;
-                }
-            }
-        }
-
-        // Entry is already in queue.
-        return false;
-    }
-
-    /**
-     * @param entry Entry.
-     * @return Peeked value.
-     */
-    @Nullable private byte[] peek(CacheEvictableEntry<IgfsBlockKey, byte[]> 
entry) {
-        return (byte[])((CacheEvictableEntryImpl)entry).peek();
-    }
-
-    /**
-     * Shrinks queue to maximum allowed size.
-     */
-    private void shrink() {
-        long maxSize = this.maxSize;
-        int maxBlocks = this.maxBlocks;
-
-        int cnt = queue.sizex();
-
-        for (int i = 0; i < cnt && (maxBlocks > 0 && queue.sizex() > maxBlocks 
||
-            maxSize > 0 && curSize.longValue() > maxSize); i++) {
-            CacheEvictableEntry<IgfsBlockKey, byte[]> entry = queue.poll();
-
-            if (entry == null)
-                break; // Queue is empty.
-
-            byte[] val = peek(entry);
-
-            if (val != null)
-                changeSize(-val.length); // Change current size as we polled 
entry from the queue.
-
-            if (!entry.evict()) {
-                // Reorder entries which we failed to evict.
-                entry.removeMeta();
-
-                touch(entry);
-            }
-        }
-    }
-
-    /**
-     * Change current size.
-     *
-     * @param delta Delta in bytes.
-     */
-    private void changeSize(int delta) {
-        if (delta != 0)
-            curSize.add(delta);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getMaxSize() {
-        return maxSize;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setMaxSize(long maxSize) {
-        this.maxSize = maxSize;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaxBlocks() {
-        return maxBlocks;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setMaxBlocks(int maxBlocks) {
-        this.maxBlocks = maxBlocks;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<String> getExcludePaths() {
-        return Collections.unmodifiableCollection(excludePaths);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setExcludePaths(@Nullable Collection<String> 
excludePaths) {
-        this.excludePaths = excludePaths;
-
-        excludeRecompile.set(true);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long getCurrentSize() {
-        return curSize.longValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentBlocks() {
-        return queue.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeLong(maxSize);
-        out.writeInt(maxBlocks);
-        out.writeObject(excludePaths);
-        out.writeObject(excludePatterns);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        maxSize = in.readLong();
-        maxBlocks = in.readInt();
-        excludePaths = (Collection<String>)in.readObject();
-        excludePatterns = (Collection<Pattern>)in.readObject();
-    }
-
-    /**
-     * Check whether provided path must be excluded from evictions.
-     *
-     * @param path Path.
-     * @return {@code True} in case non block of related file must be excluded.
-     * @throws IgniteCheckedException In case of faulty patterns.
-     */
-    public boolean exclude(IgfsPath path) throws IgniteCheckedException {
-        assert path != null;
-
-        Collection<Pattern> excludePatterns0;
-
-        if (excludeRecompile.compareAndSet(true, false)) {
-            // Recompile.
-            Collection<String> excludePaths0 = excludePaths;
-
-            if (excludePaths0 != null) {
-                excludePatterns0 = new HashSet<>(excludePaths0.size(), 1.0f);
-
-                for (String excludePath : excludePaths0) {
-                    try {
-                        excludePatterns0.add(Pattern.compile(excludePath));
-                    }
-                    catch (PatternSyntaxException ignore) {
-                        throw new IgniteCheckedException("Invalid regex 
pattern: " + excludePath);
-                    }
-                }
-
-                excludePatterns = excludePatterns0;
-            }
-            else
-                excludePatterns0 = excludePatterns = null;
-        }
-        else
-            excludePatterns0 = excludePatterns;
-
-        if (excludePatterns0 != null) {
-            String pathStr = path.toString();
-
-            for (Pattern pattern : excludePatterns0) {
-                if (pattern.matcher(pathStr).matches())
-                    return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * Meta entry.
-     */
-    private static class MetaEntry {
-        /** Queue node. */
-        private final Node<CacheEvictableEntry<IgfsBlockKey, byte[]>> node;
-
-        /** Data size. */
-        private final int size;
-
-        /**
-         * Constructor.
-         *
-         * @param node Queue node.
-         * @param size Data size.
-         */
-        private MetaEntry(Node<CacheEvictableEntry<IgfsBlockKey, byte[]>> 
node, int size) {
-            assert node != null;
-            assert size >= 0;
-
-            this.node = node;
-            this.size = size;
-        }
-
-        /**
-         * @return Queue node.
-         */
-        private Node<CacheEvictableEntry<IgfsBlockKey, byte[]>> node() {
-            return node;
-        }
-
-        /**
-         * @return Data size.
-         */
-        private int size() {
-            return size;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicyMXBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicyMXBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicyMXBean.java
deleted file mode 100644
index e3abc29..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/CacheIgfsPerBlockLruEvictionPolicyMXBean.java
+++ /dev/null
@@ -1,93 +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.cache.eviction.igfs;
-
-import org.apache.ignite.mxbean.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * MBean for {@code IGFS per-block LRU} eviction policy.
- */
-@MXBeanDescription("MBean for IGFS per-block LRU cache eviction policy.")
-public interface CacheIgfsPerBlockLruEvictionPolicyMXBean {
-    /**
-     * Gets maximum allowed size of all blocks in bytes.
-     *
-     * @return Maximum allowed size of all blocks in bytes.
-     */
-    @MXBeanDescription("Maximum allowed size of all blocks in bytes.")
-    public long getMaxSize();
-
-    /**
-     * Sets maximum allowed size of data in all blocks in bytes.
-     *
-     * @param maxSize Maximum allowed size of data in all blocks in bytes.
-     */
-    @MXBeanDescription("Sets aximum allowed size of data in all blocks in 
bytes.")
-    public void setMaxSize(long maxSize);
-
-    /**
-     * Gets maximum allowed amount of blocks.
-     *
-     * @return Maximum allowed amount of blocks.
-     */
-    @MXBeanDescription("Maximum allowed amount of blocks.")
-    public int getMaxBlocks();
-
-    /**
-     * Sets maximum allowed amount of blocks.
-     *
-     * @param maxBlocks Maximum allowed amount of blocks.
-     */
-    @MXBeanDescription("Sets maximum allowed amount of blocks.")
-    public void setMaxBlocks(int maxBlocks);
-
-    /**
-     * Gets collection of regex for paths whose blocks must not be evicted.
-     *
-     * @return Collection of regex for paths whose blocks must not be evicted.
-     */
-    @MXBeanDescription("Collection of regex for paths whose blocks must not be 
evicted.")
-    @Nullable public Collection<String> getExcludePaths();
-
-    /**
-     * Sets collection of regex for paths whose blocks must not be evicted.
-     *
-     * @param excludePaths Collection of regex for paths whose blocks must not 
be evicted.
-     */
-    @MXBeanDescription("Sets collection of regex for paths whose blocks must 
not be evicted.")
-    public void setExcludePaths(@Nullable Collection<String> excludePaths);
-
-    /**
-     * Gets current size of data in all blocks.
-     *
-     * @return Current size of data in all blocks.
-     */
-    @MXBeanDescription("Current size of data in all blocks.")
-    public long getCurrentSize();
-
-    /**
-     * Gets current amount of blocks.
-     *
-     * @return Current amount of blocks.
-     */
-    @MXBeanDescription("Current amount of blocks.")
-    public int getCurrentBlocks();
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsEvictionFilter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsEvictionFilter.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsEvictionFilter.java
new file mode 100644
index 0000000..97d1dd1
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsEvictionFilter.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.igfs;
+
+import org.apache.ignite.cache.eviction.*;
+import org.apache.ignite.internal.processors.igfs.*;
+
+import javax.cache.*;
+
+/**
+ * IGFS eviction filter which will not evict blocks of particular files.
+ */
+public class IgfsEvictionFilter implements EvictionFilter {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override public boolean evictAllowed(Cache.Entry entry) {
+        Object key = entry.getKey();
+
+        return !(key instanceof IgfsBlockKey && 
((IgfsBlockKey)key).evictExclude());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
new file mode 100644
index 0000000..ff4aeea
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.igfs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.eviction.*;
+import org.apache.ignite.igfs.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.igfs.*;
+import org.jsr166.*;
+import org.jsr166.ConcurrentLinkedDeque8.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.atomic.*;
+import java.util.regex.*;
+
+/**
+ * IGFS eviction policy which evicts particular blocks.
+ */
+public class IgfsPerBlockLruEvictionPolicy implements 
EvictionPolicy<IgfsBlockKey, byte[]>, IgfsPerBlockLruEvictionPolicyMXBean, 
Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Maximum size. When reached, eviction begins. */
+    private volatile long maxSize;
+
+    /** Maximum amount of blocks. When reached, eviction begins. */
+    private volatile int maxBlocks;
+
+    /** Collection of regex for paths which must not be evicted. */
+    private volatile Collection<String> excludePaths;
+
+    /** Exclusion patterns. */
+    private volatile Collection<Pattern> excludePatterns;
+
+    /** Whether patterns must be recompiled during the next call. */
+    private final AtomicBoolean excludeRecompile = new AtomicBoolean(true);
+
+    /** Queue. */
+    private final ConcurrentLinkedDeque8<EvictableEntry<IgfsBlockKey, byte[]>> 
queue =
+        new ConcurrentLinkedDeque8<>();
+
+    /** Current size of all enqueued blocks in bytes. */
+    private final LongAdder8 curSize = new LongAdder8();
+
+    /**
+     * Default constructor.
+     */
+    public IgfsPerBlockLruEvictionPolicy() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param maxSize Maximum size. When reached, eviction begins.
+     * @param maxBlocks Maximum amount of blocks. When reached, eviction 
begins.
+     */
+    public IgfsPerBlockLruEvictionPolicy(long maxSize, int maxBlocks) {
+        this(maxSize, maxBlocks, null);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param maxSize Maximum size. When reached, eviction begins.
+     * @param maxBlocks Maximum amount of blocks. When reached, eviction 
begins.
+     * @param excludePaths Collection of regex for path which must not be 
evicted.
+     */
+    public IgfsPerBlockLruEvictionPolicy(long maxSize, int maxBlocks, 
@Nullable Collection<String> excludePaths) {
+        this.maxSize = maxSize;
+        this.maxBlocks = maxBlocks;
+        this.excludePaths = excludePaths;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onEntryAccessed(boolean rmv, 
EvictableEntry<IgfsBlockKey, byte[]> entry) {
+        if (!rmv) {
+            if (!entry.isCached())
+                return;
+
+            if (touch(entry))
+                shrink();
+        }
+        else {
+            MetaEntry meta = entry.removeMeta();
+
+            if (meta != null && queue.unlinkx(meta.node()))
+                changeSize(-meta.size());
+        }
+    }
+
+    /**
+     * @param entry Entry to touch.
+     * @return {@code True} if new node has been added to queue by this call.
+     */
+    private boolean touch(EvictableEntry<IgfsBlockKey, byte[]> entry) {
+        byte[] val = peek(entry);
+
+        int blockSize = val != null ? val.length : 0;
+
+        MetaEntry meta = entry.meta();
+
+        // Entry has not been enqueued yet.
+        if (meta == null) {
+            while (true) {
+                Node<EvictableEntry<IgfsBlockKey, byte[]>> node = 
queue.offerLastx(entry);
+
+                meta = new MetaEntry(node, blockSize);
+
+                if (entry.putMetaIfAbsent(meta) != null) {
+                    // Was concurrently added, need to clear it from queue.
+                    queue.unlinkx(node);
+
+                    // Queue has not been changed.
+                    return false;
+                }
+                else if (node.item() != null) {
+                    if (!entry.isCached()) {
+                        // Was concurrently evicted, need to clear it from 
queue.
+                        queue.unlinkx(node);
+
+                        return false;
+                    }
+
+                    // Increment current size.
+                    changeSize(blockSize);
+
+                    return true;
+                }
+                // If node was unlinked by concurrent shrink() call, we must 
repeat the whole cycle.
+                else if (!entry.removeMeta(node))
+                    return false;
+            }
+        }
+        else {
+            int oldBlockSize = meta.size();
+
+            Node<EvictableEntry<IgfsBlockKey, byte[]>> node = meta.node();
+
+            if (queue.unlinkx(node)) {
+                // Move node to tail.
+                Node<EvictableEntry<IgfsBlockKey, byte[]>> newNode = 
queue.offerLastx(entry);
+
+                int delta = blockSize - oldBlockSize;
+
+                if (!entry.replaceMeta(meta, new MetaEntry(newNode, 
blockSize))) {
+                    // Was concurrently added, need to clear it from queue.
+                    if (queue.unlinkx(newNode))
+                        delta -= blockSize;
+                }
+
+                if (delta != 0) {
+                    changeSize(delta);
+
+                   if (delta > 0)
+                       // Total size increased, so shrinking could be needed.
+                       return true;
+                }
+            }
+        }
+
+        // Entry is already in queue.
+        return false;
+    }
+
+    /**
+     * @param entry Entry.
+     * @return Peeked value.
+     */
+    @Nullable private byte[] peek(EvictableEntry<IgfsBlockKey, byte[]> entry) {
+        return (byte[])((CacheEvictableEntryImpl)entry).peek();
+    }
+
+    /**
+     * Shrinks queue to maximum allowed size.
+     */
+    private void shrink() {
+        long maxSize = this.maxSize;
+        int maxBlocks = this.maxBlocks;
+
+        int cnt = queue.sizex();
+
+        for (int i = 0; i < cnt && (maxBlocks > 0 && queue.sizex() > maxBlocks 
||
+            maxSize > 0 && curSize.longValue() > maxSize); i++) {
+            EvictableEntry<IgfsBlockKey, byte[]> entry = queue.poll();
+
+            if (entry == null)
+                break; // Queue is empty.
+
+            byte[] val = peek(entry);
+
+            if (val != null)
+                changeSize(-val.length); // Change current size as we polled 
entry from the queue.
+
+            if (!entry.evict()) {
+                // Reorder entries which we failed to evict.
+                entry.removeMeta();
+
+                touch(entry);
+            }
+        }
+    }
+
+    /**
+     * Change current size.
+     *
+     * @param delta Delta in bytes.
+     */
+    private void changeSize(int delta) {
+        if (delta != 0)
+            curSize.add(delta);
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getMaxSize() {
+        return maxSize;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setMaxSize(long maxSize) {
+        this.maxSize = maxSize;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaxBlocks() {
+        return maxBlocks;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setMaxBlocks(int maxBlocks) {
+        this.maxBlocks = maxBlocks;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<String> getExcludePaths() {
+        return Collections.unmodifiableCollection(excludePaths);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setExcludePaths(@Nullable Collection<String> 
excludePaths) {
+        this.excludePaths = excludePaths;
+
+        excludeRecompile.set(true);
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getCurrentSize() {
+        return curSize.longValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentBlocks() {
+        return queue.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeLong(maxSize);
+        out.writeInt(maxBlocks);
+        out.writeObject(excludePaths);
+        out.writeObject(excludePatterns);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        maxSize = in.readLong();
+        maxBlocks = in.readInt();
+        excludePaths = (Collection<String>)in.readObject();
+        excludePatterns = (Collection<Pattern>)in.readObject();
+    }
+
+    /**
+     * Check whether provided path must be excluded from evictions.
+     *
+     * @param path Path.
+     * @return {@code True} in case non block of related file must be excluded.
+     * @throws IgniteCheckedException In case of faulty patterns.
+     */
+    public boolean exclude(IgfsPath path) throws IgniteCheckedException {
+        assert path != null;
+
+        Collection<Pattern> excludePatterns0;
+
+        if (excludeRecompile.compareAndSet(true, false)) {
+            // Recompile.
+            Collection<String> excludePaths0 = excludePaths;
+
+            if (excludePaths0 != null) {
+                excludePatterns0 = new HashSet<>(excludePaths0.size(), 1.0f);
+
+                for (String excludePath : excludePaths0) {
+                    try {
+                        excludePatterns0.add(Pattern.compile(excludePath));
+                    }
+                    catch (PatternSyntaxException ignore) {
+                        throw new IgniteCheckedException("Invalid regex 
pattern: " + excludePath);
+                    }
+                }
+
+                excludePatterns = excludePatterns0;
+            }
+            else
+                excludePatterns0 = excludePatterns = null;
+        }
+        else
+            excludePatterns0 = excludePatterns;
+
+        if (excludePatterns0 != null) {
+            String pathStr = path.toString();
+
+            for (Pattern pattern : excludePatterns0) {
+                if (pattern.matcher(pathStr).matches())
+                    return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Meta entry.
+     */
+    private static class MetaEntry {
+        /** Queue node. */
+        private final Node<EvictableEntry<IgfsBlockKey, byte[]>> node;
+
+        /** Data size. */
+        private final int size;
+
+        /**
+         * Constructor.
+         *
+         * @param node Queue node.
+         * @param size Data size.
+         */
+        private MetaEntry(Node<EvictableEntry<IgfsBlockKey, byte[]>> node, int 
size) {
+            assert node != null;
+            assert size >= 0;
+
+            this.node = node;
+            this.size = size;
+        }
+
+        /**
+         * @return Queue node.
+         */
+        private Node<EvictableEntry<IgfsBlockKey, byte[]>> node() {
+            return node;
+        }
+
+        /**
+         * @return Data size.
+         */
+        private int size() {
+            return size;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicyMXBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicyMXBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicyMXBean.java
new file mode 100644
index 0000000..76e1016
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicyMXBean.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.igfs;
+
+import org.apache.ignite.mxbean.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ * MBean for {@code IGFS per-block LRU} eviction policy.
+ */
+@MXBeanDescription("MBean for IGFS per-block LRU cache eviction policy.")
+public interface IgfsPerBlockLruEvictionPolicyMXBean {
+    /**
+     * Gets maximum allowed size of all blocks in bytes.
+     *
+     * @return Maximum allowed size of all blocks in bytes.
+     */
+    @MXBeanDescription("Maximum allowed size of all blocks in bytes.")
+    public long getMaxSize();
+
+    /**
+     * Sets maximum allowed size of data in all blocks in bytes.
+     *
+     * @param maxSize Maximum allowed size of data in all blocks in bytes.
+     */
+    @MXBeanDescription("Sets aximum allowed size of data in all blocks in 
bytes.")
+    public void setMaxSize(long maxSize);
+
+    /**
+     * Gets maximum allowed amount of blocks.
+     *
+     * @return Maximum allowed amount of blocks.
+     */
+    @MXBeanDescription("Maximum allowed amount of blocks.")
+    public int getMaxBlocks();
+
+    /**
+     * Sets maximum allowed amount of blocks.
+     *
+     * @param maxBlocks Maximum allowed amount of blocks.
+     */
+    @MXBeanDescription("Sets maximum allowed amount of blocks.")
+    public void setMaxBlocks(int maxBlocks);
+
+    /**
+     * Gets collection of regex for paths whose blocks must not be evicted.
+     *
+     * @return Collection of regex for paths whose blocks must not be evicted.
+     */
+    @MXBeanDescription("Collection of regex for paths whose blocks must not be 
evicted.")
+    @Nullable public Collection<String> getExcludePaths();
+
+    /**
+     * Sets collection of regex for paths whose blocks must not be evicted.
+     *
+     * @param excludePaths Collection of regex for paths whose blocks must not 
be evicted.
+     */
+    @MXBeanDescription("Sets collection of regex for paths whose blocks must 
not be evicted.")
+    public void setExcludePaths(@Nullable Collection<String> excludePaths);
+
+    /**
+     * Gets current size of data in all blocks.
+     *
+     * @return Current size of data in all blocks.
+     */
+    @MXBeanDescription("Current size of data in all blocks.")
+    public long getCurrentSize();
+
+    /**
+     * Gets current amount of blocks.
+     *
+     * @return Current amount of blocks.
+     */
+    @MXBeanDescription("Current amount of blocks.")
+    public int getCurrentBlocks();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java
deleted file mode 100644
index 939b194..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java
+++ /dev/null
@@ -1,199 +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.cache.eviction.lru;
-
-import org.apache.ignite.cache.eviction.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jsr166.*;
-import org.jsr166.ConcurrentLinkedDeque8.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Eviction policy based on {@code Least Recently Used (LRU)} algorithm. This
- * implementation is very efficient since it is lock-free and does not
- * create any additional table-like data structures. The {@code LRU} ordering
- * information is maintained by attaching ordering metadata to cache entries.
- */
-public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>,
-    CacheLruEvictionPolicyMBean, Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Maximum size. */
-    private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE;
-
-    /** Queue. */
-    private final ConcurrentLinkedDeque8<CacheEvictableEntry<K, V>> queue =
-        new ConcurrentLinkedDeque8<>();
-
-    /**
-     * Constructs LRU eviction policy with all defaults.
-     */
-    public CacheLruEvictionPolicy() {
-        // No-op.
-    }
-
-    /**
-     * Constructs LRU eviction policy with maximum size.
-     *
-     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
-     */
-    public CacheLruEvictionPolicy(int max) {
-        A.ensure(max > 0, "max > 0");
-
-        this.max = max;
-    }
-
-    /**
-     * Gets maximum allowed size of cache before entry will start getting 
evicted.
-     *
-     * @return Maximum allowed size of cache before entry will start getting 
evicted.
-     */
-    @Override public int getMaxSize() {
-        return max;
-    }
-
-    /**
-     * Sets maximum allowed size of cache before entry will start getting 
evicted.
-     *
-     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
-     */
-    @Override public void setMaxSize(int max) {
-        A.ensure(max > 0, "max > 0");
-
-        this.max = max;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getCurrentSize() {
-        return queue.size();
-    }
-
-    /**
-     * Gets read-only view on internal {@code FIFO} queue in proper order.
-     *
-     * @return Read-only view ono internal {@code 'FIFO'} queue.
-     */
-    public Collection<CacheEvictableEntry<K, V>> queue() {
-        return Collections.unmodifiableCollection(queue);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onEntryAccessed(boolean rmv, CacheEvictableEntry<K, 
V> entry) {
-        if (!rmv) {
-            if (!entry.isCached())
-                return;
-
-            if (touch(entry))
-                shrink();
-        }
-        else {
-            Node<CacheEvictableEntry<K, V>> node = entry.removeMeta();
-
-            if (node != null)
-                queue.unlinkx(node);
-        }
-    }
-
-    /**
-     * @param entry Entry to touch.
-     * @return {@code True} if new node has been added to queue by this call.
-     */
-    private boolean touch(CacheEvictableEntry<K, V> entry) {
-        Node<CacheEvictableEntry<K, V>> node = entry.meta();
-
-        // Entry has not been enqueued yet.
-        if (node == null) {
-            while (true) {
-                node = queue.offerLastx(entry);
-
-                if (entry.putMetaIfAbsent(node) != null) {
-                    // Was concurrently added, need to clear it from queue.
-                    queue.unlinkx(node);
-
-                    // Queue has not been changed.
-                    return false;
-                }
-                else if (node.item() != null) {
-                    if (!entry.isCached()) {
-                        // Was concurrently evicted, need to clear it from 
queue.
-                        queue.unlinkx(node);
-
-                        return false;
-                    }
-
-                    return true;
-                }
-                // If node was unlinked by concurrent shrink() call, we must 
repeat the whole cycle.
-                else if (!entry.removeMeta(node))
-                    return false;
-            }
-        }
-        else if (queue.unlinkx(node)) {
-            // Move node to tail.
-            Node<CacheEvictableEntry<K, V>> newNode = queue.offerLastx(entry);
-
-            if (!entry.replaceMeta(node, newNode))
-                // Was concurrently added, need to clear it from queue.
-                queue.unlinkx(newNode);
-        }
-
-        // Entry is already in queue.
-        return false;
-    }
-
-    /**
-     * Shrinks queue to maximum allowed size.
-     */
-    private void shrink() {
-        int max = this.max;
-
-        int startSize = queue.sizex();
-
-        for (int i = 0; i < startSize && queue.sizex() > max; i++) {
-            CacheEvictableEntry<K, V> entry = queue.poll();
-
-            if (entry == null)
-                break;
-
-            if (!entry.evict()) {
-                entry.removeMeta();
-
-                touch(entry);
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(max);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        max = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(CacheLruEvictionPolicy.class, this, "size", 
queue.sizex());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java
deleted file mode 100644
index 49f0dcc..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java
+++ /dev/null
@@ -1,50 +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.cache.eviction.lru;
-
-import org.apache.ignite.mxbean.*;
-
-/**
- * MBean for {@code LRU} eviction policy.
- */
-@MXBeanDescription("MBean for LRU cache eviction policy.")
-public interface CacheLruEvictionPolicyMBean {
-    /**
-     * Gets maximum allowed cache size.
-     *
-     * @return Maximum allowed cache size.
-     */
-    @MXBeanDescription("Maximum allowed cache size.")
-    public int getMaxSize();
-
-    /**
-     * Sets maximum allowed cache size.
-     *
-     * @param max Maximum allowed cache size.
-     */
-    @MXBeanDescription("Sets maximum allowed cache size.")
-    public void setMaxSize(int max);
-
-    /**
-     * Gets current queue size.
-     *
-     * @return Current queue size.
-     */
-    @MXBeanDescription("Current queue size.")
-    public int getCurrentSize();
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
new file mode 100644
index 0000000..2ba3c41
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.lru;
+
+import org.apache.ignite.cache.eviction.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jsr166.*;
+import org.jsr166.ConcurrentLinkedDeque8.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Eviction policy based on {@code Least Recently Used (LRU)} algorithm. This
+ * implementation is very efficient since it is lock-free and does not
+ * create any additional table-like data structures. The {@code LRU} ordering
+ * information is maintained by attaching ordering metadata to cache entries.
+ */
+public class LruEvictionPolicy<K, V> implements EvictionPolicy<K, V>, 
LruEvictionPolicyMBean, Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Maximum size. */
+    private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE;
+
+    /** Queue. */
+    private final ConcurrentLinkedDeque8<EvictableEntry<K, V>> queue =
+        new ConcurrentLinkedDeque8<>();
+
+    /**
+     * Constructs LRU eviction policy with all defaults.
+     */
+    public LruEvictionPolicy() {
+        // No-op.
+    }
+
+    /**
+     * Constructs LRU eviction policy with maximum size.
+     *
+     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
+     */
+    public LruEvictionPolicy(int max) {
+        A.ensure(max > 0, "max > 0");
+
+        this.max = max;
+    }
+
+    /**
+     * Gets maximum allowed size of cache before entry will start getting 
evicted.
+     *
+     * @return Maximum allowed size of cache before entry will start getting 
evicted.
+     */
+    @Override public int getMaxSize() {
+        return max;
+    }
+
+    /**
+     * Sets maximum allowed size of cache before entry will start getting 
evicted.
+     *
+     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
+     */
+    @Override public void setMaxSize(int max) {
+        A.ensure(max > 0, "max > 0");
+
+        this.max = max;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getCurrentSize() {
+        return queue.size();
+    }
+
+    /**
+     * Gets read-only view on internal {@code FIFO} queue in proper order.
+     *
+     * @return Read-only view ono internal {@code 'FIFO'} queue.
+     */
+    public Collection<EvictableEntry<K, V>> queue() {
+        return Collections.unmodifiableCollection(queue);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> 
entry) {
+        if (!rmv) {
+            if (!entry.isCached())
+                return;
+
+            if (touch(entry))
+                shrink();
+        }
+        else {
+            Node<EvictableEntry<K, V>> node = entry.removeMeta();
+
+            if (node != null)
+                queue.unlinkx(node);
+        }
+    }
+
+    /**
+     * @param entry Entry to touch.
+     * @return {@code True} if new node has been added to queue by this call.
+     */
+    private boolean touch(EvictableEntry<K, V> entry) {
+        Node<EvictableEntry<K, V>> node = entry.meta();
+
+        // Entry has not been enqueued yet.
+        if (node == null) {
+            while (true) {
+                node = queue.offerLastx(entry);
+
+                if (entry.putMetaIfAbsent(node) != null) {
+                    // Was concurrently added, need to clear it from queue.
+                    queue.unlinkx(node);
+
+                    // Queue has not been changed.
+                    return false;
+                }
+                else if (node.item() != null) {
+                    if (!entry.isCached()) {
+                        // Was concurrently evicted, need to clear it from 
queue.
+                        queue.unlinkx(node);
+
+                        return false;
+                    }
+
+                    return true;
+                }
+                // If node was unlinked by concurrent shrink() call, we must 
repeat the whole cycle.
+                else if (!entry.removeMeta(node))
+                    return false;
+            }
+        }
+        else if (queue.unlinkx(node)) {
+            // Move node to tail.
+            Node<EvictableEntry<K, V>> newNode = queue.offerLastx(entry);
+
+            if (!entry.replaceMeta(node, newNode))
+                // Was concurrently added, need to clear it from queue.
+                queue.unlinkx(newNode);
+        }
+
+        // Entry is already in queue.
+        return false;
+    }
+
+    /**
+     * Shrinks queue to maximum allowed size.
+     */
+    private void shrink() {
+        int max = this.max;
+
+        int startSize = queue.sizex();
+
+        for (int i = 0; i < startSize && queue.sizex() > max; i++) {
+            EvictableEntry<K, V> entry = queue.poll();
+
+            if (entry == null)
+                break;
+
+            if (!entry.evict()) {
+                entry.removeMeta();
+
+                touch(entry);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(max);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        max = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(LruEvictionPolicy.class, this, "size", 
queue.sizex());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicyMBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicyMBean.java
new file mode 100644
index 0000000..c243374
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicyMBean.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.lru;
+
+import org.apache.ignite.mxbean.*;
+
+/**
+ * MBean for {@code LRU} eviction policy.
+ */
+@MXBeanDescription("MBean for LRU cache eviction policy.")
+public interface LruEvictionPolicyMBean {
+    /**
+     * Gets maximum allowed cache size.
+     *
+     * @return Maximum allowed cache size.
+     */
+    @MXBeanDescription("Maximum allowed cache size.")
+    public int getMaxSize();
+
+    /**
+     * Sets maximum allowed cache size.
+     *
+     * @param max Maximum allowed cache size.
+     */
+    @MXBeanDescription("Sets maximum allowed cache size.")
+    public void setMaxSize(int max);
+
+    /**
+     * Gets current queue size.
+     *
+     * @return Current queue size.
+     */
+    @MXBeanDescription("Current queue size.")
+    public int getCurrentSize();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java
deleted file mode 100644
index 844734d..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java
+++ /dev/null
@@ -1,115 +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.cache.eviction.random;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.eviction.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import javax.cache.*;
-import java.io.*;
-
-/**
- * Cache eviction policy which will select random cache entry for eviction if 
cache
- * size exceeds the {@link #getMaxSize()} parameter. This implementation is
- * extremely light weight, lock-free, and does not create any data structures 
to maintain
- * any order for eviction.
- * <p>
- * Random eviction will provide the best performance over any key set in which 
every
- * key has the same probability of being accessed.
- */
-public class CacheRandomEvictionPolicy<K, V> implements CacheEvictionPolicy<K, 
V>,
-    CacheRandomEvictionPolicyMBean, Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Maximum size. */
-    private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE;
-
-    /**
-     * Constructs random eviction policy with all defaults.
-     */
-    public CacheRandomEvictionPolicy() {
-        // No-op.
-    }
-
-    /**
-     * Constructs random eviction policy with maximum size.
-     *
-     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
-     */
-    public CacheRandomEvictionPolicy(int max) {
-        A.ensure(max > 0, "max > 0");
-
-        this.max = max;
-    }
-
-    /**
-     * Gets maximum allowed size of cache before entry will start getting 
evicted.
-     *
-     * @return Maximum allowed size of cache before entry will start getting 
evicted.
-     */
-    @Override public int getMaxSize() {
-        return max;
-    }
-
-    /**
-     * Sets maximum allowed size of cache before entry will start getting 
evicted.
-     *
-     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
-     */
-    @Override public void setMaxSize(int max) {
-        A.ensure(max > 0, "max > 0");
-
-        this.max = max;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public void onEntryAccessed(boolean rmv, CacheEvictableEntry<K, 
V> entry) {
-        if (!entry.isCached())
-            return;
-
-        IgniteCache<K, V> cache = entry.unwrap(IgniteCache.class);
-
-        int size = cache.size();
-
-        for (int i = max; i < size; i++) {
-            Cache.Entry<K, V> e = cache.randomEntry();
-
-            if (e != null)
-                e.unwrap(CacheEvictableEntry.class).evict();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeInt(max);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        max = in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(CacheRandomEvictionPolicy.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicyMBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicyMBean.java
deleted file mode 100644
index 4ef7696..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicyMBean.java
+++ /dev/null
@@ -1,42 +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.cache.eviction.random;
-
-import org.apache.ignite.mxbean.*;
-
-/**
- * MBean for {@code random} eviction policy.
- */
-@MXBeanDescription("MBean for random cache eviction policy.")
-public interface CacheRandomEvictionPolicyMBean {
-    /**
-     * Gets maximum allowed cache size.
-     *
-     * @return Maximum allowed cache size.
-     */
-    @MXBeanDescription("Maximum allowed cache size.")
-    public int getMaxSize();
-
-    /**
-     * Sets maximum allowed cache size.
-     *
-     * @param max Maximum allowed cache size.
-     */
-    @MXBeanDescription("Sets maximum allowed cache size.")
-    public void setMaxSize(int max);
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
new file mode 100644
index 0000000..c88b31d
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.random;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.eviction.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import javax.cache.*;
+import java.io.*;
+
+/**
+ * Cache eviction policy which will select random cache entry for eviction if 
cache
+ * size exceeds the {@link #getMaxSize()} parameter. This implementation is
+ * extremely light weight, lock-free, and does not create any data structures 
to maintain
+ * any order for eviction.
+ * <p>
+ * Random eviction will provide the best performance over any key set in which 
every
+ * key has the same probability of being accessed.
+ */
+public class RandomEvictionPolicy<K, V> implements EvictionPolicy<K, V>, 
RandomEvictionPolicyMBean, Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Maximum size. */
+    private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE;
+
+    /**
+     * Constructs random eviction policy with all defaults.
+     */
+    public RandomEvictionPolicy() {
+        // No-op.
+    }
+
+    /**
+     * Constructs random eviction policy with maximum size.
+     *
+     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
+     */
+    public RandomEvictionPolicy(int max) {
+        A.ensure(max > 0, "max > 0");
+
+        this.max = max;
+    }
+
+    /**
+     * Gets maximum allowed size of cache before entry will start getting 
evicted.
+     *
+     * @return Maximum allowed size of cache before entry will start getting 
evicted.
+     */
+    @Override public int getMaxSize() {
+        return max;
+    }
+
+    /**
+     * Sets maximum allowed size of cache before entry will start getting 
evicted.
+     *
+     * @param max Maximum allowed size of cache before entry will start 
getting evicted.
+     */
+    @Override public void setMaxSize(int max) {
+        A.ensure(max > 0, "max > 0");
+
+        this.max = max;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> 
entry) {
+        if (!entry.isCached())
+            return;
+
+        IgniteCache<K, V> cache = entry.unwrap(IgniteCache.class);
+
+        int size = cache.size();
+
+        for (int i = max; i < size; i++) {
+            Cache.Entry<K, V> e = cache.randomEntry();
+
+            if (e != null)
+                e.unwrap(EvictableEntry.class).evict();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(max);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        max = in.readInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(RandomEvictionPolicy.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
new file mode 100644
index 0000000..ec7fb87
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicyMBean.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.eviction.random;
+
+import org.apache.ignite.mxbean.*;
+
+/**
+ * MBean for {@code random} eviction policy.
+ */
+@MXBeanDescription("MBean for random cache eviction policy.")
+public interface RandomEvictionPolicyMBean {
+    /**
+     * Gets maximum allowed cache size.
+     *
+     * @return Maximum allowed cache size.
+     */
+    @MXBeanDescription("Maximum allowed cache size.")
+    public int getMaxSize();
+
+    /**
+     * Sets maximum allowed cache size.
+     *
+     * @param max Maximum allowed cache size.
+     */
+    @MXBeanDescription("Sets maximum allowed cache size.")
+    public void setMaxSize(int max);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 6359fe6..0c253cc 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -183,7 +183,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     private long ttl = DFLT_TIME_TO_LIVE;
 
     /** Cache expiration policy. */
-    private CacheEvictionPolicy evictPlc;
+    private EvictionPolicy evictPlc;
 
     /** Flag indicating whether eviction is synchronized. */
     private boolean evictSync = DFLT_EVICT_SYNCHRONIZED;
@@ -198,7 +198,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     private long evictSyncTimeout = DFLT_EVICT_SYNCHRONIZED_TIMEOUT;
 
     /** Eviction filter. */
-    private CacheEvictionFilter<?, ?> evictFilter;
+    private EvictionFilter<?, ?> evictFilter;
 
     /** Maximum eviction overflow ratio. */
     private float evictMaxOverflowRatio = DFLT_MAX_EVICTION_OVERFLOW_RATIO;
@@ -228,7 +228,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     private boolean loadPrevVal = DFLT_LOAD_PREV_VAL;
 
     /** Node group resolver. */
-    private CacheAffinityFunction aff;
+    private AffinityFunction aff;
 
     /** Cache mode. */
     private CacheMode cacheMode = DFLT_CACHE_MODE;
@@ -285,7 +285,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     private CacheMemoryMode memMode = DFLT_MEMORY_MODE;
 
     /** */
-    private CacheAffinityKeyMapper affMapper;
+    private AffinityKeyMapper affMapper;
 
     /** */
     private long rebalanceDelay;
@@ -459,7 +459,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      * @return Cache eviction policy or {@code null} if evictions should be 
disabled.
      */
     @SuppressWarnings({"unchecked"})
-    @Nullable public CacheEvictionPolicy<K, V> getEvictionPolicy() {
+    @Nullable public EvictionPolicy<K, V> getEvictionPolicy() {
         return evictPlc;
     }
 
@@ -468,7 +468,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      *
      * @param evictPlc Cache expiration policy.
      */
-    public void setEvictionPolicy(@Nullable CacheEvictionPolicy evictPlc) {
+    public void setEvictionPolicy(@Nullable EvictionPolicy evictPlc) {
         this.evictPlc = evictPlc;
     }
 
@@ -658,7 +658,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     /**
      * Gets eviction filter to specify which entries should not be evicted
      * (except explicit evict by calling {@link 
IgniteCache#localEvict(Collection)}).
-     * If {@link CacheEvictionFilter#evictAllowed(Cache.Entry)} method
+     * If {@link EvictionFilter#evictAllowed(Cache.Entry)} method
      * returns {@code false} then eviction policy will not be notified and 
entry will
      * never be evicted.
      * <p>
@@ -668,8 +668,8 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      * @return Eviction filter or {@code null}.
      */
     @SuppressWarnings("unchecked")
-    public CacheEvictionFilter<K, V> getEvictionFilter() {
-        return (CacheEvictionFilter<K, V>)evictFilter;
+    public EvictionFilter<K, V> getEvictionFilter() {
+        return (EvictionFilter<K, V>)evictFilter;
     }
 
     /**
@@ -677,7 +677,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      *
      * @param evictFilter Eviction filter.
      */
-    public void setEvictionFilter(CacheEvictionFilter<K, V> evictFilter) {
+    public void setEvictionFilter(EvictionFilter<K, V> evictFilter) {
         this.evictFilter = evictFilter;
     }
 
@@ -689,7 +689,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      * <p>
      * <b>Note</b> that this flag only matters for entries expiring based on
      * {@link ExpiryPolicy} and should not be confused with entry
-     * evictions based on configured {@link CacheEvictionPolicy}.
+     * evictions based on configured {@link EvictionPolicy}.
      *
      * @return Flag indicating whether Ignite will eagerly remove expired 
entries.
      */
@@ -792,7 +792,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      *
      * @return Key topology resolver to provide mapping from keys to nodes.
      */
-    public CacheAffinityFunction getAffinity() {
+    public AffinityFunction getAffinity() {
         return aff;
     }
 
@@ -801,7 +801,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      *
      * @param aff Cache key affinity.
      */
-    public void setAffinity(CacheAffinityFunction aff) {
+    public void setAffinity(AffinityFunction aff) {
         this.aff = aff;
     }
 
@@ -1231,7 +1231,7 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      * For better efficiency user should usually make sure that new nodes get 
placed on
      * the same place of consistent hash ring as the left nodes, and that 
nodes are
      * restarted before this delay expires. To place nodes on the same place 
in consistent hash ring,
-     * use {@link 
CacheRendezvousAffinityFunction#setHashIdResolver(CacheAffinityNodeHashResolver)}
+     * use {@link 
RendezvousAffinityFunction#setHashIdResolver(AffinityNodeHashResolver)}
      * to make sure that a node maps to the same hash ID event if restarted. 
As an example,
      * node IP address and port combination may be used in this case.
      * <p>
@@ -1296,21 +1296,21 @@ public class CacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
      * on the same node (they will also be backed up on the same nodes as 
well).
      * <p>
      * If not provided, then default implementation will be used. The default 
behavior
-     * is described in {@link CacheAffinityKeyMapper} documentation.
+     * is described in {@link AffinityKeyMapper} documentation.
      *
      * @return Mapper to use for affinity key mapping.
      */
-    public CacheAffinityKeyMapper getAffinityMapper() {
+    public AffinityKeyMapper getAffinityMapper() {
         return affMapper;
     }
 
     /**
      * Sets custom affinity mapper. If not provided, then default 
implementation will be used. The default behavior is
-     * described in {@link CacheAffinityKeyMapper} documentation.
+     * described in {@link AffinityKeyMapper} documentation.
      *
      * @param affMapper Affinity mapper.
      */
-    public void setAffinityMapper(CacheAffinityKeyMapper affMapper) {
+    public void setAffinityMapper(AffinityKeyMapper affMapper) {
         this.affMapper = affMapper;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/configuration/NearCacheConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/configuration/NearCacheConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/configuration/NearCacheConfiguration.java
index c77b352..0593601 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/configuration/NearCacheConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/configuration/NearCacheConfiguration.java
@@ -33,7 +33,7 @@ public class NearCacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     private static final long serialVersionUID = 0L;
 
     /** Near cache eviction policy. */
-    private CacheEvictionPolicy<K, V> nearEvictPlc;
+    private EvictionPolicy<K, V> nearEvictPlc;
 
     /** Default near cache start size. */
     private int nearStartSize = DFLT_NEAR_START_SIZE;
@@ -58,14 +58,14 @@ public class NearCacheConfiguration<K, V> extends 
MutableConfiguration<K, V> {
     /**
      * @return Near eviction policy.
      */
-    public CacheEvictionPolicy<K, V> getNearEvictionPolicy() {
+    public EvictionPolicy<K, V> getNearEvictionPolicy() {
         return nearEvictPlc;
     }
 
     /**
      * @param nearEvictPlc Near eviction policy.
      */
-    public void setNearEvictionPolicy(CacheEvictionPolicy<K, V> nearEvictPlc) {
+    public void setNearEvictionPolicy(EvictionPolicy<K, V> nearEvictPlc) {
         this.nearEvictPlc = nearEvictPlc;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java 
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 4422af7..c9c3b8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2575,7 +2575,7 @@ public class IgniteKernal implements IgniteEx, 
IgniteMXBean, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Override public <K> CacheAffinity<K> affinity(String cacheName) {
+    @Override public <K> Affinity<K> affinity(String cacheName) {
         GridCacheAdapter<K, ?> cache = ctx.cache().internalCache(cacheName);
 
         if (cache != null)

Reply via email to