ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [02/16] ignite git commit: Removed listing usage from IgfsDeleteWorker.
Date Tue, 15 Mar 2016 13:35:11 GMT
Removed listing usage from IgfsDeleteWorker.


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

Branch: refs/heads/ignite-2813
Commit: d139289b29aacbb92580f8ec2b30290e06d63a59
Parents: ee08e00
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Mar 15 15:19:25 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Mar 15 15:19:25 2016 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsDeleteWorker.java       | 50 ++++++++++----------
 .../processors/igfs/IgfsMetaManager.java        | 23 ++++-----
 2 files changed, 38 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d139289b/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 ffddd3e..1570845 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,20 +175,21 @@ public class IgfsDeleteWorker extends IgfsThread {
         }
 
         if (info != null) {
-            for (Map.Entry<String, IgfsListingEntry> entry : info.listing().entrySet())
{
-                IgniteUuid fileId = entry.getValue().fileId();
+            for (Map.Entry<String, IgniteUuid> entry : info.listing2().entrySet())
{
+                String childName = entry.getKey();
+                IgniteUuid childId = entry.getValue();
 
                 if (log.isDebugEnabled())
-                    log.debug("Deleting IGFS trash entry [name=" + entry.getKey() + ", fileId="
+ fileId + ']');
+                    log.debug("Deleting IGFS trash entry [name=" + childName + ", id=" +
childId + ']');
 
                 try {
                     if (!cancelled) {
-                        if (delete(trashId, entry.getKey(), fileId)) {
+                        if (delete(trashId, childName, childId)) {
                             if (log.isDebugEnabled())
-                                log.debug("Sending delete confirmation message [name=" +
entry.getKey() +
-                                    ", fileId=" + fileId + ']');
+                                log.debug("Sending delete confirmation message [name=" +
childName +
+                                    ", id=" + childId + ']');
 
-                            sendDeleteMessage(new IgfsDeleteMessage(fileId));
+                            sendDeleteMessage(new IgfsDeleteMessage(childId));
                         }
                     }
                     else
@@ -198,9 +199,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: " + entry.getKey(),
e);
+                    U.error(log, "Failed to delete entry from the trash directory: " + childName,
e);
 
-                    sendDeleteMessage(new IgfsDeleteMessage(fileId, e));
+                    sendDeleteMessage(new IgfsDeleteMessage(childId, e));
                 }
             }
         }
@@ -276,34 +277,35 @@ public class IgfsDeleteWorker extends IgfsThread {
             if (info != null) {
                 assert info.isDirectory();
 
-                final Map<String, IgfsListingEntry> listing = info.listing();
+                final Map<String, IgniteUuid> listing = info.listing2();
 
                 if (listing.isEmpty())
                     return true; // Directory is empty.
 
-                final Map<String, IgfsListingEntry> delListing = new HashMap<>(MAX_DELETE_BATCH,
1.0f);
+                final Map<String, IgniteUuid> delListing = new HashMap<>(MAX_DELETE_BATCH,
1.0f);
 
                 final GridCompoundFuture<Object, ?> fut = new GridCompoundFuture<>();
 
                 int failedFiles = 0;
 
-                for (final Map.Entry<String, IgfsListingEntry> entry : listing.entrySet())
{
+                for (final Map.Entry<String, IgniteUuid> entry : listing.entrySet())
{
                     if (cancelled)
                         return false;
 
-                    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());
+                    String childName = entry.getKey();
+                    IgniteUuid childId = entry.getValue();
 
-                        if (fileInfo != null) {
-                            assert fileInfo.isFile();
+                    IgfsFileInfo childInfo = meta.info(childId);
 
-                            IgfsFileInfo lockedInfo = meta.lock(fileInfo.id(), true);
+                    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);
 
                             if (lockedInfo == null)
                                 // File is already locked:
@@ -313,7 +315,7 @@ public class IgfsDeleteWorker extends IgfsThread {
 
                                 fut.add(data.delete(lockedInfo));
 
-                                delListing.put(entry.getKey(), entry.getValue());
+                                delListing.put(childName, childId);
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d139289b/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 d3aae58..1fd426c 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
@@ -1318,7 +1318,7 @@ public class IgfsMetaManager extends IgfsManager {
      * @return Collection of really deleted entries.
      * @throws IgniteCheckedException If failed.
      */
-    Collection<IgniteUuid> delete(IgniteUuid parentId, Map<String, IgfsListingEntry>
listing)
+    Collection<IgniteUuid> delete(IgniteUuid parentId, Map<String, IgniteUuid>
listing)
         throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
@@ -1338,8 +1338,8 @@ public class IgfsMetaManager extends IgfsManager {
 
                     int i = 1;
 
-                    for (IgfsListingEntry entry : listing.values())
-                        allIds[i++] = entry.fileId();
+                    for (IgniteUuid childId : listing.values())
+                        allIds[i++] = childId;
 
                     Map<IgniteUuid, IgfsFileInfo> locks = lockIds(allIds);
 
@@ -1353,10 +1353,11 @@ public class IgfsMetaManager extends IgfsManager {
                         newListing.putAll(parentInfo.listing());
 
                         // Remove child entries if possible.
-                        for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet())
{
-                            IgniteUuid entryId = entry.getValue().fileId();
+                        for (Map.Entry<String, IgniteUuid> entry : listing.entrySet())
{
+                            String childName = entry.getKey();
+                            IgniteUuid childId = entry.getValue();
 
-                            IgfsFileInfo entryInfo = locks.get(entryId);
+                            IgfsFileInfo entryInfo = locks.get(childId);
 
                             if (entryInfo != null) {
                                 // File must be locked for deletion:
@@ -1364,18 +1365,18 @@ public class IgfsMetaManager extends IgfsManager {
 
                                 // Delete only files or empty folders.
                                 if (entryInfo.isFile() || entryInfo.isDirectory() &&
entryInfo.listing().isEmpty()) {
-                                    id2InfoPrj.getAndRemove(entryId);
+                                    id2InfoPrj.getAndRemove(childId);
 
-                                    newListing.remove(entry.getKey());
+                                    newListing.remove(childName);
 
-                                    res.add(entryId);
+                                    res.add(childId);
                                 }
                             }
                             else {
                                 // Entry was deleted concurrently.
-                                newListing.remove(entry.getKey());
+                                newListing.remove(childName);
 
-                                res.add(entryId);
+                                res.add(childId);
                             }
                         }
 


Mime
View raw message