WIP.

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

Branch: refs/heads/ignite-2813
Commit: 063e72fbfd382c65ea76d7398393c3b90e521a57
Parents: be1aaeb
Author: vozerov-gridgain <voze...@gridgain.com>
Authored: Tue Mar 15 16:05:22 2016 +0300
Committer: vozerov-gridgain <voze...@gridgain.com>
Committed: Tue Mar 15 16:05:22 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/igfs/IgfsFileInfo.java  |  9 ++++++
 .../processors/igfs/IgfsMetaManager.java        | 33 ++++++--------------
 2 files changed, 19 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/063e72fb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index fc2d70b..814b730 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -453,6 +453,15 @@ public final class IgfsFileInfo implements Externalizable {
     }
 
     /**
+     * @param name Child name.
+     * @param expId Expected child ID.
+     * @return {@code True} if child with such name exists.
+     */
+    public boolean hasChild(String name, IgniteUuid expId) {
+        return listing2 != null && F.eq(expId, listing2.get(name));
+    }
+
+    /**
      * @return Affinity key used for single-node file collocation. If {@code 
null}, usual
      *      mapper procedure is used for block affinity detection.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/063e72fb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index f5e21d6..aee1191 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -801,9 +801,7 @@ public class IgfsMetaManager extends IgfsManager {
         if (!parentInfo.isDirectory())
             throw fsException(new IgfsPathIsNotDirectoryException("Parent file 
is not a directory: " + parentInfo));
 
-        Map<String, IgniteUuid> parentListing = parentInfo.listing2();
-
-        IgniteUuid fileId = parentListing.get(fileName);
+        IgniteUuid fileId = parentInfo.listing2().get(fileName);
 
         if (fileId != null)
             return fileId;
@@ -911,7 +909,7 @@ public class IgfsMetaManager extends IgfsManager {
                     assert dstTargetInfo.isDirectory();
 
                     // 7. Last check: does destination target already have 
listing entry with the same name?
-                    if (dstTargetInfo.listing2().containsKey(dstName)) {
+                    if (dstTargetInfo.hasChild(dstName)) {
                         throw new IgfsPathAlreadyExistsException("Failed to 
perform move because destination already " +
                             "contains entry with the same name existing file 
[src=" + srcPath +
                             ", dst=" + dstPath + ']');
@@ -969,14 +967,8 @@ public class IgfsMetaManager extends IgfsManager {
 
                 // If parent info is null, it doesn't exist.
                 if (parentInfo != null) {
-                    IgniteUuid childEntry = 
parentInfo.listing2().get(pathParts.get(i));
-
-                    // If expected child exists.
-                    if (childEntry != null) {
-                        // If child ID matches expected ID.
-                        if (F.eq(childEntry, expIds.get(i + 1)))
-                            continue;
-                    }
+                    if (parentInfo.hasChild(pathParts.get(i), expIds.get(i + 
1)))
+                        continue;
                 }
             }
 
@@ -1042,7 +1034,6 @@ public class IgfsMetaManager extends IgfsManager {
                 fileId + ']'));
 
         IgfsListingEntry srcEntry = srcInfo.listing().get(srcFileName);
-        IgniteUuid destEntry = destInfo.listing2().get(destFileName);
 
         // If source file does not exist or was re-created.
         if (srcEntry == null || !srcEntry.fileId().equals(fileId))
@@ -1051,10 +1042,10 @@ public class IgfsMetaManager extends IgfsManager {
                 ", srcParentId=" + srcParentId + ", srcEntry=" + srcEntry + 
']'));
 
         // If stored file already exist.
-        if (destEntry != null)
+        if (destInfo.hasChild(destFileName))
             throw fsException(new IgfsPathAlreadyExistsException("Failed to 
add file name into the destination " +
                 " directory (file already exists) [fileId=" + fileId + ", 
destFileName=" + destFileName +
-                ", destParentId=" + destParentId + ", destEntry=" + destEntry 
+ ']'));
+                ", destParentId=" + destParentId + ']'));
 
         // Remove listing entry from the source parent listing.
         id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, 
srcEntry.fileId()));
@@ -1183,7 +1174,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                     final String destFileName = victimId.toString();
 
-                    assert destInfo.listing2().get(destFileName) == null : 
"Failed to add file name into the " +
+                    assert !destInfo.hasChild(destFileName) : "Failed to add 
file name into the " +
                         "destination directory (file already exists) 
[destName=" + destFileName + ']';
 
                     IgfsFileInfo srcParentInfo = 
infoMap.get(pathIdList.get(pathIdList.size() - 2));
@@ -1541,7 +1532,7 @@ public class IgfsMetaManager extends IgfsManager {
 
                 IgniteUuid entry = listing.get(fileName);
 
-                if (entry == null || !entry.equals(fileId)) // File was 
removed or recreated.
+                if (!parentInfo.hasChild(fileName, fileId)) // File was 
removed or recreated.
                     return null;
             }
 
@@ -2974,10 +2965,8 @@ public class IgfsMetaManager extends IgfsManager {
                         throw fsException(new 
IgfsPathNotFoundException("Failed to update times " +
                             "(parent was not found): " + fileName));
 
-                    IgniteUuid entry = parentInfo.listing2().get(fileName);
-
                     // Validate listing.
-                    if (entry == null || !entry.equals(fileId))
+                    if (!parentInfo.hasChild(fileName, fileId))
                         throw fsException(new 
IgfsConcurrentModificationException("Failed to update times " +
                                 "(file concurrently modified): " + fileName));
 
@@ -3602,11 +3591,9 @@ public class IgfsMetaManager extends IgfsManager {
                                 throw new 
IgfsParentNotDirectoryException("Failed to " + (append ? "open" : "create" )
                                     + " file (parent element is not a 
directory)");
 
-                            Map<String, IgniteUuid> parentListing = 
lowermostExistingInfo.listing2();
-
                             final String uppermostFileToBeCreatedName = 
b.components.get(b.existingIdCnt - 1);
 
-                            if 
(parentListing.get(uppermostFileToBeCreatedName) == null) {
+                            if 
(!lowermostExistingInfo.hasChild(uppermostFileToBeCreatedName)) {
                                 b.doBuild();
 
                                 assert b.leafInfo != null;

Reply via email to