ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject [2/5] ignite git commit: IGNITE-3405: IGFS: Restricted path modes interleaving, so that now only DUAL -> PRIMARY and DUAL -> PROXY paths are possible.
Date Fri, 22 Jul 2016 11:21:11 GMT
IGNITE-3405: IGFS: Restricted path modes interleaving, so that now only DUAL -> PRIMARY and DUAL -> PROXY paths are possible.


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

Branch: refs/heads/master
Commit: 9b55658749d0e2a869bbb3614034d8aa1f0e95c1
Parents: 51add50
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Jul 20 14:14:50 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Jul 20 14:14:50 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/igfs/IgfsImpl.java      |  77 ++---
 .../processors/igfs/IgfsModeResolver.java       |  94 +-----
 .../internal/processors/igfs/IgfsUtils.java     |  83 +++++
 ...sCachePerBlockLruEvictionPolicySelfTest.java |   7 +-
 .../processors/igfs/IgfsMetricsSelfTest.java    |  54 +--
 .../igfs/IgfsModeResolverSelfTest.java          | 124 +++++--
 .../processors/igfs/IgfsModesSelfTest.java      |  61 ++--
 .../hadoop/fs/v2/IgniteHadoopFileSystem.java    |  22 +-
 .../igfs/HadoopFIleSystemFactorySelfTest.java   |   2 +-
 ...teHadoopFileSystemSecondaryModeSelfTest.java | 327 -------------------
 .../testsuites/IgniteHadoopTestSuite.java       |   2 -
 11 files changed, 276 insertions(+), 577 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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 efb347f..5b87698 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
@@ -94,7 +94,6 @@ import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadFactory;
@@ -210,7 +209,7 @@ public final class IgfsImpl implements IgfsEx {
         Map<String, IgfsMode> cfgModes = new LinkedHashMap<>();
         Map<String, IgfsMode> dfltModes = new LinkedHashMap<>(4, 1.0f);
 
-        if (cfg.isInitializeDefaultPathModes()) {
+        if (cfg.isInitializeDefaultPathModes() && IgfsUtils.isDualMode(dfltMode)) {
             dfltModes.put("/ignite/primary", PRIMARY);
 
             if (secondaryFs != null) {
@@ -222,8 +221,8 @@ public final class IgfsImpl implements IgfsEx {
 
         cfgModes.putAll(dfltModes);
 
-        if (igfsCtx.configuration().getPathModes() != null) {
-            for (Map.Entry<String, IgfsMode> e : igfsCtx.configuration().getPathModes().entrySet()) {
+        if (cfg.getPathModes() != null) {
+            for (Map.Entry<String, IgfsMode> e : cfg.getPathModes().entrySet()) {
                 if (!dfltModes.containsKey(e.getKey()))
                     cfgModes.put(e.getKey(), e.getValue());
                 else
@@ -249,7 +248,7 @@ public final class IgfsImpl implements IgfsEx {
             }
         }
 
-        modeRslvr = new IgfsModeResolver(dfltMode, modes);
+        modeRslvr = new IgfsModeResolver(dfltMode, IgfsUtils.preparePathModes(dfltMode, modes));
 
         Object secondaryFsPayload = null;
 
@@ -620,7 +619,7 @@ public final class IgfsImpl implements IgfsEx {
                 IgfsMode mode = resolveMode(path);
 
                 if (mode != PRIMARY) {
-                    assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+                    assert IgfsUtils.isDualMode(mode);
 
                     await(path);
 
@@ -671,8 +670,6 @@ public final class IgfsImpl implements IgfsEx {
 
                 IgfsMode mode = resolveMode(src);
 
-                Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(src);
-
                 if (src.equals(dest))
                     return null; // Rename to itself is a no-op.
 
@@ -689,8 +686,8 @@ public final class IgfsImpl implements IgfsEx {
                     throw new IgfsInvalidPathException("Cannot move file to a path with different eviction " +
                         "exclude setting (need to copy and remove)");
 
-                if (!childrenModes.equals(Collections.singleton(PRIMARY))) {
-                    assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+                if (mode != PRIMARY) {
+                    assert IgfsUtils.isDualMode(mode); // PROXY mode explicit usage is forbidden.
 
                     await(src, dest);
 
@@ -721,9 +718,9 @@ public final class IgfsImpl implements IgfsEx {
                 if (IgfsPath.SLASH.equals(path.toString()))
                     return false;
 
-                Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
+                IgfsMode mode = resolveMode(path);
 
-                boolean dual = childrenModes.contains(DUAL_SYNC) ||childrenModes.contains(DUAL_ASYNC);
+                boolean dual = IgfsUtils.isDualMode(mode);;
 
                 if (dual)
                     await(path);
@@ -767,7 +764,7 @@ public final class IgfsImpl implements IgfsEx {
                 if (mode == PRIMARY)
                     meta.mkdirs(path, props0);
                 else {
-                    assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+                    assert IgfsUtils.isDualMode(mode);;
 
                     await(path);
 
@@ -794,11 +791,9 @@ public final class IgfsImpl implements IgfsEx {
 
                 IgfsMode mode = resolveMode(path);
 
-                Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
-
                 Collection<String> files = new HashSet<>();
 
-                if (childrenModes.contains(DUAL_SYNC) || childrenModes.contains(DUAL_ASYNC)) {
+                if (IgfsUtils.isDualMode(mode)) {
                     assert secondaryFs != null;
 
                     try {
@@ -818,11 +813,8 @@ public final class IgfsImpl implements IgfsEx {
 
                 if (fileId != null)
                     files.addAll(meta.directoryListing(fileId).keySet());
-                else if (mode == PRIMARY) {
-                    checkConflictWithPrimary(path);
-
+                else if (mode == PRIMARY)
                     throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
-                }
 
                 return F.viewReadOnly(files, new C1<String, IgfsPath>() {
                     @Override public IgfsPath apply(String e) {
@@ -847,11 +839,9 @@ public final class IgfsImpl implements IgfsEx {
 
                 IgfsMode mode = resolveMode(path);
 
-                Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
-
                 Collection<IgfsFile> files = new HashSet<>();
 
-                if (childrenModes.contains(DUAL_SYNC) || childrenModes.contains(DUAL_ASYNC)) {
+                if (IgfsUtils.isDualMode(mode)) {
                     assert secondaryFs != null;
 
                     try {
@@ -894,11 +884,8 @@ public final class IgfsImpl implements IgfsEx {
                         }
                     }
                 }
-                else if (mode == PRIMARY) {
-                    checkConflictWithPrimary(path);
-
+                else if (mode == PRIMARY)
                     throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
-                }
 
                 return files;
             }
@@ -937,7 +924,7 @@ public final class IgfsImpl implements IgfsEx {
                 IgfsMode mode = resolveMode(path);
 
                 if (mode != PRIMARY) {
-                    assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+                    assert IgfsUtils.isDualMode(mode);
 
                     IgfsSecondaryInputStreamDescriptor desc = meta.openDual(secondaryFs, path, bufSize0);
 
@@ -951,11 +938,8 @@ public final class IgfsImpl implements IgfsEx {
 
                 IgfsEntryInfo info = meta.infoForPath(path);
 
-                if (info == null) {
-                    checkConflictWithPrimary(path);
-
+                if (info == null)
                     throw new IgfsPathNotFoundException("File not found: " + path);
-                }
 
                 if (!info.isFile())
                     throw new IgfsPathIsDirectoryException("Failed to open file (not a file): " + path);
@@ -1089,7 +1073,7 @@ public final class IgfsImpl implements IgfsEx {
                 IgfsFileWorkerBatch batch;
 
                 if (mode != PRIMARY) {
-                    assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+                    assert IgfsUtils.isDualMode(mode);
 
                     await(path);
 
@@ -1105,11 +1089,8 @@ public final class IgfsImpl implements IgfsEx {
                 final IgniteUuid id = ids.get(ids.size() - 1);
 
                 if (id == null) {
-                    if (!create) {
-                        checkConflictWithPrimary(path);
-
+                    if (!create)
                         throw new IgfsPathNotFoundException("File not found: " + path);
-                    }
                 }
 
                 // Prevent attempt to append to ROOT in early stage:
@@ -1160,11 +1141,8 @@ public final class IgfsImpl implements IgfsEx {
             @Override public Void call() throws Exception {
                 FileDescriptor desc = getFileDescriptor(path);
 
-                if (desc == null) {
-                    checkConflictWithPrimary(path);
-
+                if (desc == null)
                     throw new IgfsPathNotFoundException("Failed to update times (path not found): " + path);
-                }
 
                 // Cannot update times for root.
                 if (desc.parentId == null)
@@ -1177,21 +1155,6 @@ public final class IgfsImpl implements IgfsEx {
         });
     }
 
-    /**
-     * Checks if given path exists in secondary file system and throws exception if so.
-     *
-     * @param path Path to check.
-     * @throws IgniteCheckedException If path exists.
-     */
-    private void checkConflictWithPrimary(IgfsPath path) throws IgniteCheckedException {
-        if (secondaryFs != null) {
-            if (secondaryFs.info(path) != null) {
-                throw new IgfsInvalidPathException("Path mapped to a PRIMARY mode found in secondary file " +
-                     "system. Remove path from secondary file system or change path mapping: " + path);
-            }
-        }
-    }
-
     /** {@inheritDoc} */
     @Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len) {
         return affinity(path, start, len, 0L);
@@ -1218,7 +1181,7 @@ public final class IgfsImpl implements IgfsEx {
                 IgfsEntryInfo info = meta.infoForPath(path);
 
                 if (info == null && mode != PRIMARY) {
-                    assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
+                    assert IgfsUtils.isDualMode(mode);
                     assert secondaryFs != null;
 
                     // Synchronize

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
index 70da103..907051f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolver.java
@@ -17,13 +17,9 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
@@ -41,39 +37,26 @@ public class IgfsModeResolver {
     private final IgfsMode dfltMode;
 
     /** Modes for particular paths. Ordered from longest to shortest. */
-    private ArrayList<T2<IgfsPath, IgfsMode>> modes;
+    private List<T2<IgfsPath, IgfsMode>> modes;
 
     /** Cached modes per path. */
     private Map<IgfsPath, IgfsMode> modesCache;
 
-    /** Cached children modes per path. */
-    private Map<IgfsPath, Set<IgfsMode>> childrenModesCache;
-
     /**
+     * Constructor
+     *
      * @param dfltMode Default IGFS mode.
-     * @param modes List of configured modes.
+     * @param modes List of configured modes. The order is significant as modes are added in order of occurrence.
      */
     public IgfsModeResolver(IgfsMode dfltMode, @Nullable List<T2<IgfsPath, IgfsMode>> modes) {
         assert dfltMode != null;
 
         this.dfltMode = dfltMode;
 
-        if (modes != null) {
-            ArrayList<T2<IgfsPath, IgfsMode>> modes0 = new ArrayList<>(modes);
-
-            // Sort paths, longest first.
-            Collections.sort(modes0, new Comparator<Map.Entry<IgfsPath, IgfsMode>>() {
-                @Override public int compare(Map.Entry<IgfsPath, IgfsMode> o1,
-                    Map.Entry<IgfsPath, IgfsMode> o2) {
-                    return o2.getKey().components().size() - o1.getKey().components().size();
-                }
-            });
-
-            this.modes = modes0;
+        this.modes = modes;
 
+        if (modes != null)
             modesCache = new GridBoundedConcurrentLinkedHashMap<>(MAX_PATH_CACHE);
-            childrenModesCache = new GridBoundedConcurrentLinkedHashMap<>(MAX_PATH_CACHE);
-        }
     }
 
     /**
@@ -92,7 +75,7 @@ public class IgfsModeResolver {
 
             if (mode == null) {
                 for (T2<IgfsPath, IgfsMode> entry : modes) {
-                    if (startsWith(path, entry.getKey())) {
+                    if (path.isSame(entry.getKey()) || path.isSubDirectoryOf(entry.getKey())) {
                         // As modes ordered from most specific to least specific first mode found is ours.
                         mode = entry.getValue();
 
@@ -111,73 +94,10 @@ public class IgfsModeResolver {
     }
 
     /**
-     * @param path Path.
-     * @return Set of all modes that children paths could have.
-     */
-    public Set<IgfsMode> resolveChildrenModes(IgfsPath path) {
-        assert path != null;
-
-        if (modes == null)
-            return Collections.singleton(dfltMode);
-        else {
-            Set<IgfsMode> children = childrenModesCache.get(path);
-
-            if (children == null) {
-                children = new HashSet<>(IgfsMode.values().length, 1.0f);
-
-                IgfsMode pathDefault = dfltMode;
-
-                for (T2<IgfsPath, IgfsMode> child : modes) {
-                    if (startsWith(path, child.getKey())) {
-                        pathDefault = child.getValue();
-
-                        break;
-                    }
-                    else if (startsWith(child.getKey(), path))
-                        children.add(child.getValue());
-                }
-
-                children.add(pathDefault);
-
-                childrenModesCache.put(path, children);
-            }
-
-            return children;
-        }
-    }
-
-    /**
      * @return Unmodifiable copy of properly ordered modes prefixes
      *  or {@code null} if no modes set.
      */
     @Nullable public List<T2<IgfsPath, IgfsMode>> modesOrdered() {
         return modes != null ? Collections.unmodifiableList(modes) : null;
     }
-
-    /**
-     * Check if path starts with prefix.
-     *
-     * @param path Path.
-     * @param prefix Prefix.
-     * @return {@code true} if path starts with prefix, {@code false} if not.
-     */
-    private static boolean startsWith(IgfsPath path, IgfsPath prefix) {
-        List<String> p1Comps = path.components();
-        List<String> p2Comps = prefix.components();
-
-        if (p2Comps.size() > p1Comps.size())
-            return false;
-
-        for (int i = 0; i < p1Comps.size(); i++) {
-            if (i >= p2Comps.size() || p2Comps.get(i) == null)
-                // All prefix components already matched.
-                return true;
-
-            if (!p1Comps.get(i).equals(p2Comps.get(i)))
-                return false;
-        }
-
-        // Path and prefix components had same length and all of them matched.
-        return true;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 7310b4c..03b7611 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -31,6 +31,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.IgfsEvent;
 import org.apache.ignite.igfs.IgfsException;
+import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.GridKernalContext;
@@ -42,6 +43,7 @@ import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
@@ -52,12 +54,18 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ThreadLocalRandom;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_RETRIES_COUNT;
+import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
+import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGFS;
 import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
 import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -784,4 +792,79 @@ public class IgfsUtils {
 
         return false;
     }
+
+    /**
+     * Check whether mode is dual.
+     *
+     * @param mode Mode.
+     * @return {@code True} if dual.
+     */
+    public static boolean isDualMode(IgfsMode mode) {
+        return mode == DUAL_SYNC || mode == DUAL_ASYNC;
+    }
+
+    /**
+     * Answers if directory of this mode can contain a subdirectory of the given mode.
+     *
+     * @param parent Parent mode.
+     * @param child Child mode.
+     * @return {@code true} if directory of this mode can contain a directory of the given mode.
+     */
+    public static boolean canContain(IgfsMode parent, IgfsMode child) {
+        return isDualMode(parent) || parent == child;
+    }
+
+    /**
+     * Checks, filters and sorts the modes.
+     *
+     * @param dfltMode The root mode. Must always be not null.
+     * @param modes The subdirectory modes.
+     * @return Descending list of filtered and checked modes.
+     * @throws IgniteCheckedException On error or
+     */
+    public static ArrayList<T2<IgfsPath, IgfsMode>> preparePathModes(final IgfsMode dfltMode,
+        @Nullable List<T2<IgfsPath, IgfsMode>> modes) throws IgniteCheckedException {
+        if (modes == null)
+            return null;
+
+        // Sort by depth, shallow first.
+        Collections.sort(modes, new Comparator<Map.Entry<IgfsPath, IgfsMode>>() {
+            @Override public int compare(Map.Entry<IgfsPath, IgfsMode> o1, Map.Entry<IgfsPath, IgfsMode> o2) {
+                return o1.getKey().depth() - o2.getKey().depth();
+            }
+        });
+
+        ArrayList<T2<IgfsPath, IgfsMode>> resModes = new ArrayList<>(modes.size() + 1);
+
+        resModes.add(new T2<>(new IgfsPath("/"), dfltMode));
+
+        for (T2<IgfsPath, IgfsMode> mode : modes) {
+            assert mode.getKey() != null;
+
+            for (T2<IgfsPath, IgfsMode> resMode : resModes) {
+                if (mode.getKey().isSubDirectoryOf(resMode.getKey())) {
+                    assert resMode.getValue() != null;
+
+                    if (resMode.getValue() == mode.getValue())
+                        // No reason to add a sub-path of the same mode, ignore this pair.
+                        break;
+
+                    if (!canContain(resMode.getValue(), mode.getValue()))
+                        throw new IgniteCheckedException("Subdirectory " + mode.getKey() + " mode "
+                            + mode.getValue() + " is not compatible with upper level "
+                            + resMode.getKey() + " directory mode " + resMode.getValue() + ".");
+
+                    // Add to the 1st position (deep first).
+                    resModes.add(0, mode);
+
+                    break;
+                }
+            }
+        }
+
+        // Remove root, because this class contract is that root mode is not contained in the list.
+        resModes.remove(resModes.size() - 1);
+
+        return resModes;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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
index 8cb8f44..93171ba 100644
--- 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
@@ -102,14 +102,14 @@ public class IgfsCachePerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstra
         igfsCfg.setMetaCacheName("metaCache");
         igfsCfg.setName(IGFS_PRIMARY);
         igfsCfg.setBlockSize(512);
-        igfsCfg.setDefaultMode(PRIMARY);
+        igfsCfg.setDefaultMode(DUAL_SYNC);
         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);
+        pathModes.put(FILE.toString(), PRIMARY);
 
         igfsCfg.setPathModes(pathModes);
 
@@ -487,7 +487,8 @@ public class IgfsCachePerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstra
      * @param curBlocks Current blocks.
      * @param curBytes Current bytes.
      */
-    private void checkEvictionPolicy(final int curBlocks, final long curBytes) throws IgniteInterruptedCheckedException {
+    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;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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 fb1d6f7..38cfc00 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
@@ -123,12 +123,12 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         igfsCfg.setMetaCacheName("metaCache");
         igfsCfg.setName(IGFS_PRIMARY);
         igfsCfg.setBlockSize(PRIMARY_BLOCK_SIZE);
-        igfsCfg.setDefaultMode(PRIMARY);
+        igfsCfg.setDefaultMode(DUAL_SYNC);
         igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());
 
         Map<String, IgfsMode> pathModes = new HashMap<>();
 
-        pathModes.put("/fileRemote", DUAL_SYNC);
+        pathModes.put("/primary", PRIMARY);
 
         igfsCfg.setPathModes(pathModes);
 
@@ -233,35 +233,35 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
 
-        fs.mkdirs(new IgfsPath("/dir1"));
+        fs.mkdirs(new IgfsPath("/primary/dir1"));
 
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(1, m.directoriesCount());
+        assertEquals(2, m.directoriesCount());
         assertEquals(0, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
 
-        fs.mkdirs(new IgfsPath("/dir1/dir2/dir3"));
-        fs.mkdirs(new IgfsPath("/dir4"));
+        fs.mkdirs(new IgfsPath("/primary/dir1/dir2/dir3"));
+        fs.mkdirs(new IgfsPath("/primary/dir4"));
 
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(0, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
 
-        IgfsOutputStream out1 = fs.create(new IgfsPath("/dir1/file1"), false);
-        IgfsOutputStream out2 = fs.create(new IgfsPath("/dir1/file2"), false);
-        IgfsOutputStream out3 = fs.create(new IgfsPath("/dir1/dir2/file"), false);
+        IgfsOutputStream out1 = fs.create(new IgfsPath("/primary/dir1/file1"), false);
+        IgfsOutputStream out2 = fs.create(new IgfsPath("/primary/dir1/file2"), false);
+        IgfsOutputStream out3 = fs.create(new IgfsPath("/primary/dir1/dir2/file"), false);
 
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(3, m.filesOpenedForWrite());
@@ -275,7 +275,7 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(2, m.filesOpenedForWrite());
@@ -286,19 +286,19 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
 
-        IgfsOutputStream out = fs.append(new IgfsPath("/dir1/file1"), false);
+        IgfsOutputStream out = fs.append(new IgfsPath("/primary/dir1/file1"), false);
 
         out.write(new byte[20]);
 
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(1, m.filesOpenedForWrite());
@@ -310,18 +310,18 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
 
-        IgfsInputStream in1 = fs.open(new IgfsPath("/dir1/file1"));
-        IgfsInputStream in2 = fs.open(new IgfsPath("/dir1/file2"));
+        IgfsInputStream in1 = fs.open(new IgfsPath("/primary/dir1/file1"));
+        IgfsInputStream in2 = fs.open(new IgfsPath("/primary/dir1/file2"));
 
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(2, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
@@ -332,18 +332,18 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(4, m.directoriesCount());
+        assertEquals(5, m.directoriesCount());
         assertEquals(3, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
 
-        fs.delete(new IgfsPath("/dir1/file1"), false);
-        fs.delete(new IgfsPath("/dir1/dir2"), true);
+        fs.delete(new IgfsPath("/primary/dir1/file1"), false);
+        fs.delete(new IgfsPath("/primary/dir1/dir2"), true);
 
         m = fs.metrics();
 
         assertNotNull(m);
-        assertEquals(2, m.directoriesCount());
+        assertEquals(3, m.directoriesCount());
         assertEquals(1, m.filesCount());
         assertEquals(0, m.filesOpenedForRead());
         assertEquals(0, m.filesOpenedForWrite());
@@ -363,12 +363,12 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
     public void testMultipleClose() throws Exception {
         IgniteFileSystem fs = igfsPrimary[0];
 
-        IgfsOutputStream out = fs.create(new IgfsPath("/file"), false);
+        IgfsOutputStream out = fs.create(new IgfsPath("/primary/file"), false);
 
         out.close();
         out.close();
 
-        IgfsInputStream in = fs.open(new IgfsPath("/file"));
+        IgfsInputStream in = fs.open(new IgfsPath("/primary/file"));
 
         in.close();
         in.close();
@@ -388,8 +388,8 @@ public class IgfsMetricsSelfTest extends IgfsCommonAbstractTest {
         IgfsEx igfs = (IgfsEx)igfsPrimary[0];
 
         IgfsPath fileRemote = new IgfsPath("/fileRemote");
-        IgfsPath file1 = new IgfsPath("/file1");
-        IgfsPath file2 = new IgfsPath("/file2");
+        IgfsPath file1 = new IgfsPath("/primary/file1");
+        IgfsPath file2 = new IgfsPath("/primary/file2");
 
         // Create remote file and write some data to it.
         IgfsOutputStream out = igfsSecondary.create(fileRemote, 256, true, null, 1, 256, null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
index a05ddfc..f3bb516 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModeResolverSelfTest.java
@@ -18,12 +18,13 @@
 package org.apache.ignite.internal.processors.igfs;
 
 import java.util.Arrays;
-import java.util.HashSet;
+import java.util.List;
 import junit.framework.TestCase;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.util.typedef.T2;
-
+import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
 import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
 import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
 import static org.apache.ignite.igfs.IgfsMode.PROXY;
@@ -33,48 +34,109 @@ import static org.apache.ignite.igfs.IgfsMode.PROXY;
  */
 public class IgfsModeResolverSelfTest extends TestCase {
     /** */
-    private IgfsModeResolver resolver;
+    private IgfsModeResolver reslvr;
 
     /** {@inheritDoc} */
     @Override protected void setUp() throws Exception {
-        resolver = new IgfsModeResolver(DUAL_SYNC, Arrays.asList(
-            new T2<>(new IgfsPath("/a/b/"), PRIMARY),
-            new T2<>(new IgfsPath("/a/b/c/d"), PROXY)));
+        reslvr = new IgfsModeResolver(DUAL_SYNC, Arrays.asList(new T2<>(new IgfsPath("/a/b/c/d"), PROXY), new T2<>
+            (new IgfsPath("/a/P/"), PRIMARY), new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCanContain() throws Exception {
+        for (IgfsMode m: IgfsMode.values()) {
+            // Each mode can contain itself:
+            assertTrue(IgfsUtils.canContain(m, m));
+
+            // PRIMARY and PROXY can contain itself only:
+            assertTrue(IgfsUtils.canContain(PRIMARY,m) == (m == PRIMARY));
+            assertTrue(IgfsUtils.canContain(PROXY,m) == (m == PROXY));
+
+            // Any mode but PRIMARY & PROXY can contain any mode:
+            if (m != PRIMARY && m != PROXY)
+                for (IgfsMode n: IgfsMode.values())
+                    assertTrue(IgfsUtils.canContain(m,n));
+        }
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testResolve() throws Exception {
-        assertEquals(DUAL_SYNC, resolver.resolveMode(new IgfsPath("/")));
-        assertEquals(DUAL_SYNC, resolver.resolveMode(new IgfsPath("/a")));
-        assertEquals(DUAL_SYNC, resolver.resolveMode(new IgfsPath("/a/1")));
-        assertEquals(PRIMARY, resolver.resolveMode(new IgfsPath("/a/b")));
-        assertEquals(PRIMARY, resolver.resolveMode(new IgfsPath("/a/b/c")));
-        assertEquals(PRIMARY, resolver.resolveMode(new IgfsPath("/a/b/c/2")));
-        assertEquals(PROXY, resolver.resolveMode(new IgfsPath("/a/b/c/d")));
-        assertEquals(PROXY, resolver.resolveMode(new IgfsPath("/a/b/c/d/e")));
+        assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/")));
+        assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a")));
+        assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a/1")));
+
+        assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P")));
+        assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P/c")));
+        assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P/c/2")));
+
+        assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/")));
+        assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/3")));
+        assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/3/4")));
+
+        assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d")));
+        assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d/5")));
+        assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d/6")));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testResolveChildren() throws Exception {
-        assertEquals(new HashSet<IgfsMode>(){{add(DUAL_SYNC); add(PRIMARY); add(PROXY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/")));
-        assertEquals(new HashSet<IgfsMode>(){{add(DUAL_SYNC); add(PRIMARY); add(PROXY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a")));
-        assertEquals(new HashSet<IgfsMode>(){{add(DUAL_SYNC);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a/1")));
-        assertEquals(new HashSet<IgfsMode>(){{add(PRIMARY); add(PROXY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a/b")));
-        assertEquals(new HashSet<IgfsMode>(){{add(PRIMARY); add(PROXY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a/b/c")));
-        assertEquals(new HashSet<IgfsMode>(){{add(PRIMARY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a/b/c/2")));
-        assertEquals(new HashSet<IgfsMode>(){{add(PROXY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a/b/c/d")));
-        assertEquals(new HashSet<IgfsMode>(){{add(PROXY);}},
-            resolver.resolveChildrenModes(new IgfsPath("/a/b/c/d/e")));
+    public void testModesValidation() throws Exception {
+        // Another mode inside PRIMARY directory:
+        try {
+            IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+                new T2<>(new IgfsPath("/a/"), PRIMARY),
+                new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)));
+
+            fail("IgniteCheckedException expected");
+        }
+        catch (IgniteCheckedException ice) {
+            // Expected.
+        }
+
+        // PRIMARY default mode and non-primary subfolder:
+        for (IgfsMode m: IgfsMode.values()) {
+            if (m != IgfsMode.PRIMARY) {
+                try {
+                    IgfsUtils.preparePathModes(PRIMARY, Arrays.asList(new T2<>(new IgfsPath("/a/"), DUAL_ASYNC)));
+
+                    fail("IgniteCheckedException expected");
+                }
+                catch (IgniteCheckedException ice) {
+                    // Expected.
+                }
+            }
+        }
+
+        // Duplicated sub-folders should be ignored:
+        List<T2<IgfsPath, IgfsMode>> modes = IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+            new T2<>(new IgfsPath("/a"), PRIMARY),
+            new T2<>(new IgfsPath("/c/d/"), PRIMARY),
+            new T2<>(new IgfsPath("/c/d/e/f"), PRIMARY)
+        ));
+        assertNotNull(modes);
+        assertEquals(2, modes.size());
+        assertEquals(modes, Arrays.asList(
+            new T2<>(new IgfsPath("/c/d/"), PRIMARY),
+            new T2<>(new IgfsPath("/a"), PRIMARY)
+        ));
+
+        // Non-duplicated sub-folders should not be ignored:
+        modes = IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(
+            new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC),
+            new T2<>(new IgfsPath("/a/b/c"), DUAL_SYNC),
+            new T2<>(new IgfsPath("/a/b/c/d"), DUAL_ASYNC)
+        ));
+        assertNotNull(modes);
+        assertEquals(modes.size(), 3);
+        assertEquals(modes, Arrays.asList(
+            new T2<>(new IgfsPath("/a/b/c/d"), DUAL_ASYNC),
+            new T2<>(new IgfsPath("/a/b/c"), DUAL_SYNC),
+            new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC)
+        ));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/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 1e54f8c..a6b7502 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
@@ -250,7 +250,7 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
     public void testDefaultFoldersNonPrimary() throws Exception {
         setSecondaryFs = true;
 
-        mode = PRIMARY;
+        mode = DUAL_ASYNC;
 
         startUp();
 
@@ -258,43 +258,45 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
         checkMode("/ignite/proxy/", PROXY);
         checkMode("/ignite/proxy/subfolder", PROXY);
         checkMode("/ignite/proxy/folder/file.txt", PROXY);
-        checkMode("/ignite/proxyx", PRIMARY);
-        checkMode("/ignite/proxyx/", PRIMARY);
-        checkMode("/ignite/proxyx/subfolder", PRIMARY);
-        checkMode("/ignite/proxyx/folder/file.txt", PRIMARY);
+        checkMode("/ignite/proxyx", mode);
+        checkMode("/ignite/proxyx/", mode);
+        checkMode("/ignite/proxyx/subfolder", mode);
+        checkMode("/ignite/proxyx/folder/file.txt", mode);
 
-        checkMode("/userdir/ignite/proxy", PRIMARY);
-        checkMode("/userdir/ignite/proxy/", PRIMARY);
-        checkMode("/userdir/ignite/proxy/subfolder", PRIMARY);
-        checkMode("/userdir/ignite/proxy/folder/file.txt", PRIMARY);
+        checkMode("/userdir/ignite/proxy", mode);
+        checkMode("/userdir/ignite/proxy/", mode);
+        checkMode("/userdir/ignite/proxy/subfolder", mode);
+        checkMode("/userdir/ignite/proxy/folder/file.txt", mode);
 
         checkMode("/ignite/sync", DUAL_SYNC);
         checkMode("/ignite/sync/", DUAL_SYNC);
         checkMode("/ignite/sync/subfolder", DUAL_SYNC);
         checkMode("/ignite/sync/folder/file.txt", DUAL_SYNC);
-        checkMode("/ignite/syncx", PRIMARY);
-        checkMode("/ignite/syncx/", PRIMARY);
-        checkMode("/ignite/syncx/subfolder", PRIMARY);
-        checkMode("/ignite/syncx/folder/file.txt", PRIMARY);
 
-        checkMode("/userdir/ignite/sync", PRIMARY);
-        checkMode("/userdir/ignite/sync/", PRIMARY);
-        checkMode("/userdir/ignite/sync/subfolder", PRIMARY);
-        checkMode("/userdir/ignite/sync/folder/file.txt", PRIMARY);
+        checkMode("/ignite/syncx", mode);
+        checkMode("/ignite/syncx/", mode);
+        checkMode("/ignite/syncx/subfolder", mode);
+        checkMode("/ignite/syncx/folder/file.txt", mode);
+
+        checkMode("/userdir/ignite/sync", mode);
+        checkMode("/userdir/ignite/sync/", mode);
+        checkMode("/userdir/ignite/sync/subfolder", mode);
+        checkMode("/userdir/ignite/sync/folder/file.txt", mode);
 
         checkMode("/ignite/async", DUAL_ASYNC);
         checkMode("/ignite/async/", DUAL_ASYNC);
         checkMode("/ignite/async/subfolder", DUAL_ASYNC);
         checkMode("/ignite/async/folder/file.txt", DUAL_ASYNC);
-        checkMode("/ignite/asyncx", PRIMARY);
-        checkMode("/ignite/asyncx/", PRIMARY);
-        checkMode("/ignite/asyncx/subfolder", PRIMARY);
-        checkMode("/ignite/asyncx/folder/file.txt", PRIMARY);
-
-        checkMode("/userdir/ignite/async", PRIMARY);
-        checkMode("/userdir/ignite/async/", PRIMARY);
-        checkMode("/userdir/ignite/async/subfolder", PRIMARY);
-        checkMode("/userdir/ignite/async/folder/file.txt", PRIMARY);
+
+        checkMode("/ignite/asyncx", mode);
+        checkMode("/ignite/asyncx/", mode);
+        checkMode("/ignite/asyncx/subfolder", mode);
+        checkMode("/ignite/asyncx/folder/file.txt", mode);
+
+        checkMode("/userdir/ignite/async", mode);
+        checkMode("/userdir/ignite/async/", mode);
+        checkMode("/userdir/ignite/async/subfolder", mode);
+        checkMode("/userdir/ignite/async/folder/file.txt", mode);
     }
 
     /**
@@ -333,8 +335,11 @@ public class IgfsModesSelfTest extends IgfsCommonAbstractTest {
 
         mode = DUAL_ASYNC;
 
-        pathModes(F.t("/ignite/primary", PROXY), F.t("/ignite/proxy", DUAL_SYNC),
-            F.t("/ignite/sync", DUAL_ASYNC), F.t("/ignite/async", PRIMARY));
+        pathModes(
+            F.t("/ignite/primary", PROXY),
+            F.t("/ignite/proxy", DUAL_SYNC),
+            F.t("/ignite/sync", DUAL_ASYNC),
+            F.t("/ignite/async", PRIMARY));
 
         startUp();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
index 66255c9..cc02d05 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
@@ -80,7 +80,6 @@ import java.util.Collection;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_BATCH_SIZE;
@@ -653,21 +652,16 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
         try {
             IgfsPath srcPath = convert(src);
             IgfsPath dstPath = convert(dst);
-            Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(srcPath);
 
-            if (childrenModes.contains(PROXY)) {
-                if (clientLog.isLogEnabled())
-                    clientLog.logRename(srcPath, PROXY, dstPath);
+            IgfsMode srcMode = modeRslvr.resolveMode(srcPath);
 
-                secondaryFileSystem().rename(toSecondary(src), toSecondary(dst));
-            }
-            else {
-                if (clientLog.isLogEnabled())
-                    clientLog.logRename(srcPath, modeRslvr.resolveMode(srcPath), dstPath);
+            if (clientLog.isLogEnabled())
+                clientLog.logRename(srcPath, srcMode, dstPath);
 
+            if (srcMode == PROXY)
+                secondaryFileSystem().rename(toSecondary(src), toSecondary(dst));
+            else
                 rmtClient.rename(srcPath, dstPath);
-            }
-
         }
         finally {
             leaveBusy();
@@ -682,10 +676,10 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
 
         try {
             IgfsPath path = convert(f);
+
             IgfsMode mode = modeRslvr.resolveMode(path);
-            Set<IgfsMode> childrenModes = modeRslvr.resolveChildrenModes(path);
 
-            if (childrenModes.contains(PROXY)) {
+            if (mode == PROXY) {
                 if (clientLog.isLogEnabled())
                     clientLog.logDelete(path, PROXY, recursive);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
index e4c64ff..7cf1e4b 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFIleSystemFactorySelfTest.java
@@ -198,7 +198,7 @@ public class HadoopFIleSystemFactorySelfTest extends IgfsCommonAbstractTest {
         fs.setFileSystemFactory(factory);
 
         // Start.
-        return start("primary", 10500, IgfsMode.PRIMARY, fs);
+        return start("primary", 10500, IgfsMode.DUAL_ASYNC, fs);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
deleted file mode 100644
index 7255e8b..0000000
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
+++ /dev/null
@@ -1,327 +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.igfs;
-
-import java.net.URI;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
-import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
-import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
-import static org.apache.ignite.igfs.IgfsMode.PROXY;
-
-/**
- * Ensures correct modes resolution for SECONDARY paths.
- */
-public class IgniteHadoopFileSystemSecondaryModeSelfTest extends IgfsCommonAbstractTest {
-    /** Path to check. */
-    private static final Path PATH = new Path("/dir");
-
-    /** Pattern matching the path. */
-    private static final String PATTERN_MATCHES = "/dir";
-
-    /** Pattern doesn't matching the path. */
-    private static final String PATTERN_NOT_MATCHES = "/files";
-
-    /** Default IGFS mode. */
-    private IgfsMode mode;
-
-    /** Path modes. */
-    private Map<String, IgfsMode> pathModes;
-
-    /** File system. */
-    private IgniteHadoopFileSystem fs;
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        mode = null;
-        pathModes = null;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        U.closeQuiet(fs);
-
-        fs = null;
-
-        G.stopAll(true);
-    }
-
-    /**
-     * Perform initial startup.
-     *
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("NullableProblems")
-    private void startUp() throws Exception {
-        startUpSecondary();
-
-        FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
-        igfsCfg.setDataCacheName("partitioned");
-        igfsCfg.setMetaCacheName("replicated");
-        igfsCfg.setName("igfs");
-        igfsCfg.setBlockSize(512 * 1024);
-        igfsCfg.setDefaultMode(mode);
-        igfsCfg.setPathModes(pathModes);
-
-        IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();
-
-        endpointCfg.setType(IgfsIpcEndpointType.TCP);
-        endpointCfg.setPort(10500);
-
-        igfsCfg.setIpcEndpointConfiguration(endpointCfg);
-
-        igfsCfg.setManagementPort(-1);
-        igfsCfg.setSecondaryFileSystem(new IgniteHadoopIgfsSecondaryFileSystem(
-            "igfs://igfs-secondary:igfs-grid-secondary@127.0.0.1:11500/",
-            "modules/core/src/test/config/hadoop/core-site-loopback-secondary.xml"));
-
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
-        cacheCfg.setName("partitioned");
-        cacheCfg.setCacheMode(PARTITIONED);
-        cacheCfg.setNearConfiguration(null);
-        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
-        cacheCfg.setBackups(0);
-        cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
-        metaCacheCfg.setName("replicated");
-        metaCacheCfg.setCacheMode(REPLICATED);
-        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridName("igfs-grid");
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
-        cfg.setDiscoverySpi(discoSpi);
-        cfg.setCacheConfiguration(metaCacheCfg, cacheCfg);
-        cfg.setFileSystemConfiguration(igfsCfg);
-
-        cfg.setLocalHost("127.0.0.1");
-
-        G.start(cfg);
-
-        Configuration fsCfg = new Configuration();
-
-        fsCfg.addResource(U.resolveIgniteUrl("modules/core/src/test/config/hadoop/core-site-loopback.xml"));
-
-        fsCfg.setBoolean("fs.igfs.impl.disable.cache", true);
-
-        fs = (IgniteHadoopFileSystem)FileSystem.get(new URI("igfs://igfs:igfs-grid@/"), fsCfg);
-    }
-
-    /**
-     * Startup secondary file system.
-     *
-     * @throws Exception If failed.
-     */
-    private void startUpSecondary() throws Exception {
-        FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
-        igfsCfg.setDataCacheName("partitioned");
-        igfsCfg.setMetaCacheName("replicated");
-        igfsCfg.setName("igfs-secondary");
-        igfsCfg.setBlockSize(512 * 1024);
-        igfsCfg.setDefaultMode(PRIMARY);
-
-        IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();
-
-        endpointCfg.setType(IgfsIpcEndpointType.TCP);
-        endpointCfg.setPort(11500);
-
-        igfsCfg.setIpcEndpointConfiguration(endpointCfg);
-
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
-        cacheCfg.setName("partitioned");
-        cacheCfg.setCacheMode(PARTITIONED);
-        cacheCfg.setNearConfiguration(null);
-        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
-        cacheCfg.setBackups(0);
-        cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
-        metaCacheCfg.setName("replicated");
-        metaCacheCfg.setCacheMode(REPLICATED);
-        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridName("igfs-grid-secondary");
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
-        cfg.setDiscoverySpi(discoSpi);
-        cfg.setCacheConfiguration(metaCacheCfg, cacheCfg);
-        cfg.setFileSystemConfiguration(igfsCfg);
-
-        cfg.setLocalHost("127.0.0.1");
-
-        G.start(cfg);
-    }
-
-    /**
-     * Check path resolution when secondary mode is not default and there are no other exclusion paths.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSecondaryNotDefaultNoExclusions() throws Exception {
-        mode = PRIMARY;
-
-        startUp();
-
-        assert !secondary(PATH);
-        assert !secondary(PATH);
-    }
-
-    /**
-     * Check path resolution when secondary mode is not default and there is no matching exclusion paths.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSecondaryNotDefaultNonMatchingExclusion() throws Exception {
-        mode = PRIMARY;
-
-        pathModes(F.t(PATTERN_NOT_MATCHES, PROXY));
-
-        startUp();
-
-        assert !secondary(PATH);
-        assert !secondary(PATH);
-    }
-
-    /**
-     * Check path resolution when secondary mode is not default and there is matching exclusion path.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSecondaryNotDefaultMatchingExclusion() throws Exception {
-        mode = PRIMARY;
-
-        pathModes(F.t(PATTERN_NOT_MATCHES, PROXY), F.t(PATTERN_MATCHES, PROXY));
-
-        startUp();
-
-        assert secondary(PATH);
-        assert secondary(PATH);
-    }
-
-    /**
-     * Check path resolution when secondary mode is default and there is no exclusion paths.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSecondaryDefaultNoExclusions() throws Exception {
-        mode = PROXY;
-
-        startUp();
-
-        assert secondary(PATH);
-        assert secondary(PATH);
-    }
-
-    /**
-     * Check path resolution when secondary mode is default and there is no matching exclusion paths.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSecondaryDefaultNonMatchingExclusion() throws Exception {
-        mode = PROXY;
-
-        pathModes(F.t(PATTERN_NOT_MATCHES, PRIMARY));
-
-        startUp();
-
-        assert secondary(PATH);
-        assert secondary(PATH);
-    }
-
-    /**
-     * Check path resolution when secondary mode is default and there is no matching exclusion paths.
-     *
-     * @throws Exception If failed.
-     */
-    public void testSecondaryDefaultMatchingExclusion() throws Exception {
-        mode = PROXY;
-
-        pathModes(F.t(PATTERN_NOT_MATCHES, PRIMARY), F.t(PATTERN_MATCHES, PRIMARY));
-
-        startUp();
-
-        assert !secondary(PATH);
-        assert !secondary(PATH);
-    }
-
-    /**
-     * Set IGFS modes for particular paths.
-     *
-     * @param modes Modes.
-     */
-    @SafeVarargs
-    final void pathModes(IgniteBiTuple<String, IgfsMode>... modes) {
-        assert modes != null;
-
-        pathModes = new LinkedHashMap<>(modes.length, 1.0f);
-
-        for (IgniteBiTuple<String, IgfsMode> mode : modes)
-            pathModes.put(mode.getKey(), mode.getValue());
-    }
-
-    /**
-     * Check whether the given path is threaten as SECONDARY in the file system.
-     *
-     * @param path Path to check.
-     * @return {@code True} in case path is secondary.
-     * @throws Exception If failed.
-     */
-    private boolean secondary(Path path) throws Exception {
-        return fs.mode(path) == PROXY;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9b556587/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index 6900425..3374547 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -50,7 +50,6 @@ import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalDualSyncSelf
 import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalPrimarySelfTest;
 import org.apache.ignite.igfs.IgniteHadoopFileSystemLoopbackExternalSecondarySelfTest;
 import org.apache.ignite.igfs.IgniteHadoopFileSystemSecondaryFileSystemInitializationSelfTest;
-import org.apache.ignite.igfs.IgniteHadoopFileSystemSecondaryModeSelfTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopClassLoaderTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopCommandLineTest;
 import org.apache.ignite.internal.processors.hadoop.HadoopDefaultMapReducePlannerSelfTest;
@@ -144,7 +143,6 @@ public class IgniteHadoopTestSuite extends TestSuite {
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualSyncSelfTest.class.getName())));
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualAsyncSelfTest.class.getName())));
 
-        suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemSecondaryModeSelfTest.class.getName())));
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemSecondaryFileSystemInitializationSelfTest.class.getName())));
 
         suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientSelfTest.class.getName())));


Mime
View raw message