ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [14/16] ignite git commit: Now getting rid of listing2 (2).
Date Tue, 15 Mar 2016 13:35:23 GMT
Now getting rid of listing2 (2).


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

Branch: refs/heads/ignite-2813
Commit: 0d4d5677dec4991ed9f8cf63d62c19d291be6927
Parents: 8cabfcd
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Mar 15 16:23:47 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Mar 15 16:23:47 2016 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsDeleteWorker.java       | 57 +++++++++-----------
 .../processors/igfs/IgfsMetaManager.java        | 10 ++--
 2 files changed, 31 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0d4d5677/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index dda3612..ffddd3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -175,21 +175,20 @@ public class IgfsDeleteWorker extends IgfsThread {
         }
 
         if (info != null) {
-            for (Map.Entry<String, IgniteUuid> entry : info.listing2().entrySet())
{
-                String childName = entry.getKey();
-                IgniteUuid childId = entry.getValue();
+            for (Map.Entry<String, IgfsListingEntry> entry : info.listing().entrySet())
{
+                IgniteUuid fileId = entry.getValue().fileId();
 
                 if (log.isDebugEnabled())
-                    log.debug("Deleting IGFS trash entry [name=" + childName + ", id=" +
childId + ']');
+                    log.debug("Deleting IGFS trash entry [name=" + entry.getKey() + ", fileId="
+ fileId + ']');
 
                 try {
                     if (!cancelled) {
-                        if (delete(trashId, childName, childId)) {
+                        if (delete(trashId, entry.getKey(), fileId)) {
                             if (log.isDebugEnabled())
-                                log.debug("Sending delete confirmation message [name=" +
childName +
-                                    ", id=" + childId + ']');
+                                log.debug("Sending delete confirmation message [name=" +
entry.getKey() +
+                                    ", fileId=" + fileId + ']');
 
-                            sendDeleteMessage(new IgfsDeleteMessage(childId));
+                            sendDeleteMessage(new IgfsDeleteMessage(fileId));
                         }
                     }
                     else
@@ -199,9 +198,9 @@ public class IgfsDeleteWorker extends IgfsThread {
                     // Ignore this exception while stopping.
                 }
                 catch (IgniteCheckedException e) {
-                    U.error(log, "Failed to delete entry from the trash directory: " + childName,
e);
+                    U.error(log, "Failed to delete entry from the trash directory: " + entry.getKey(),
e);
 
-                    sendDeleteMessage(new IgfsDeleteMessage(childId, e));
+                    sendDeleteMessage(new IgfsDeleteMessage(fileId, e));
                 }
             }
         }
@@ -277,36 +276,34 @@ public class IgfsDeleteWorker extends IgfsThread {
             if (info != null) {
                 assert info.isDirectory();
 
-                final Map<String, IgniteUuid> listing = info.listing2();
+                final Map<String, IgfsListingEntry> listing = info.listing();
 
                 if (listing.isEmpty())
                     return true; // Directory is empty.
 
-                final Map<String, IgniteUuid> delListing = new HashMap<>(MAX_DELETE_BATCH,
1.0f);
+                final Map<String, IgfsListingEntry> delListing = new HashMap<>(MAX_DELETE_BATCH,
1.0f);
 
                 final GridCompoundFuture<Object, ?> fut = new GridCompoundFuture<>();
 
-                int notFoundFiles = 0;
                 int failedFiles = 0;
 
-                for (final Map.Entry<String, IgniteUuid> entry : listing.entrySet())
{
+                for (final Map.Entry<String, IgfsListingEntry> entry : listing.entrySet())
{
                     if (cancelled)
                         return false;
 
-                    String childName = entry.getKey();
-                    IgniteUuid childId = entry.getValue();
+                    if (entry.getValue().isDirectory()) {
+                        if (deleteDirectoryContents(id, entry.getValue().fileId())) // ***
Recursive call.
+                            delListing.put(entry.getKey(), entry.getValue());
+                        else
+                            failedFiles++;
+                    }
+                    else {
+                        IgfsFileInfo fileInfo = meta.info(entry.getValue().fileId());
 
-                    IgfsFileInfo childInfo = meta.info(childId);
+                        if (fileInfo != null) {
+                            assert fileInfo.isFile();
 
-                    if (childInfo != null) {
-                        if (childInfo.isDirectory()) {
-                            if (deleteDirectoryContents(id, childId)) // *** Recursive call.
-                                delListing.put(childName, childId);
-                            else
-                                failedFiles++;
-                        }
-                        else {
-                            IgfsFileInfo lockedInfo = meta.lock(childId, true);
+                            IgfsFileInfo lockedInfo = meta.lock(fileInfo.id(), true);
 
                             if (lockedInfo == null)
                                 // File is already locked:
@@ -316,12 +313,10 @@ public class IgfsDeleteWorker extends IgfsThread {
 
                                 fut.add(data.delete(lockedInfo));
 
-                                delListing.put(childName, childId);
+                                delListing.put(entry.getKey(), entry.getValue());
                             }
                         }
                     }
-                    else
-                        notFoundFiles++;
 
                     if (delListing.size() == MAX_DELETE_BATCH)
                         break;
@@ -343,10 +338,10 @@ public class IgfsDeleteWorker extends IgfsThread {
                 // Actual delete of folder content.
                 Collection<IgniteUuid> delIds = meta.delete(id, delListing);
 
-                if (listing.size() - notFoundFiles == delIds.size())
+                if (listing.size() == delIds.size())
                     return true; // All entries were deleted.
 
-                if (listing.size() - notFoundFiles == delListing.size() + failedFiles)
+                if (listing.size() == delListing.size() + failedFiles)
                     // All the files were tried, no reason to continue the loop:
                     return false;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d4d5677/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 7a3c108..105792d 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
@@ -1305,7 +1305,7 @@ public class IgfsMetaManager extends IgfsManager {
      * @return Collection of really deleted entries.
      * @throws IgniteCheckedException If failed.
      */
-    Collection<IgniteUuid> delete(IgniteUuid parentId, Map<String, IgniteUuid>
listing)
+    Collection<IgniteUuid> delete(IgniteUuid parentId, Map<String, IgfsListingEntry>
listing)
         throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
@@ -1325,8 +1325,8 @@ public class IgfsMetaManager extends IgfsManager {
 
                     int i = 1;
 
-                    for (IgniteUuid childId : listing.values())
-                        allIds[i++] = childId;
+                    for (IgfsListingEntry childEntry : listing.values())
+                        allIds[i++] = childEntry.fileId();
 
                     Map<IgniteUuid, IgfsFileInfo> locks = lockIds(allIds);
 
@@ -1341,9 +1341,9 @@ public class IgfsMetaManager extends IgfsManager {
                         newListing.putAll(parentListing);
 
                         // Remove child entries if possible.
-                        for (Map.Entry<String, IgniteUuid> entry : listing.entrySet())
{
+                        for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet())
{
                             String childName = entry.getKey();
-                            IgniteUuid childId = entry.getValue();
+                            IgniteUuid childId = entry.getValue().fileId();
 
                             IgfsFileInfo entryInfo = locks.get(childId);
 


Mime
View raw message