ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [08/50] [abbrv] incubator-ignite git commit: # IGNITE-418: Applied fix from Ivan V.. The problem was with block size handling as we use it to distinguish between files and directories (which is not very correct, honestly).
Date Wed, 11 Mar 2015 12:51:52 GMT
# IGNITE-418: Applied fix from Ivan V..
The problem was with block size handling as we use it to distinguish between files and directories
(which is not very correct, honestly).


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

Branch: refs/heads/ignite-gg-9828
Commit: acf140c40369e659c963f0b0665105dcdcb74203
Parents: dab66dc
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Mar 10 16:54:15 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Mar 10 16:58:37 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/igfs/IgfsFileImpl.java |  7 +++++++
 .../ignite/internal/processors/igfs/IgfsFileInfo.java |  3 ++-
 .../ignite/internal/processors/igfs/IgfsImpl.java     |  4 ++--
 .../fs/IgniteHadoopIgfsSecondaryFileSystem.java       |  5 ++---
 .../ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java   | 14 +++++++++++---
 .../ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java   |  8 +++++---
 6 files changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acf140c4/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
index dc1248c..fddfa20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
@@ -77,6 +77,9 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable {
 
         if (info.isFile()) {
             blockSize = info.blockSize();
+
+            assert blockSize > 0; // By contract file must have blockSize > 0, while
directory's blockSize == 0.
+
             len = info.length();
 
             grpBlockSize = info.affinityKey() == null ? globalGrpBlockSize :
@@ -107,6 +110,10 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable {
 
         blockSize = entry.blockSize();
 
+        // By contract file must have blockSize > 0, while directory's blockSize == 0:
+        assert entry.isFile() == (blockSize > 0);
+        assert entry.isDirectory() == (blockSize == 0);
+
         grpBlockSize = entry.affinityKey() == null ? globalGrpSize :
             entry.length() == 0 ? globalGrpSize : entry.length();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acf140c4/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 e88503b..de7d077 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
@@ -189,7 +189,8 @@ public final class IgfsFileInfo implements Externalizable {
      * @param evictExclude Evict exclude flag.
      */
     IgfsFileInfo(int blockSize, long len, boolean evictExclude, @Nullable Map<String,
String> props) {
-        this(false, null, blockSize, len, null, null, props, null, true, System.currentTimeMillis(),
evictExclude);
+        this(blockSize == 0, // NB The contract is: (blockSize == null) <=> isDirectory()
+            null, blockSize, len, null, null, props, null, true, System.currentTimeMillis(),
evictExclude);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acf140c4/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 abbfe1e..9ccb2a9 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
@@ -1018,8 +1018,8 @@ public final class IgfsImpl implements IgfsEx {
                     Collection<IgfsFile> children = secondaryFs.listFiles(path);
 
                     for (IgfsFile child : children) {
-                        IgfsFileInfo fsInfo = new IgfsFileInfo(cfg.getBlockSize(), child.length(),
-                            evictExclude(path, false), child.properties());
+                        IgfsFileInfo fsInfo = new IgfsFileInfo(
+                            child.blockSize(), child.length(), evictExclude(path, false),
child.properties());
 
                         files.add(new IgfsFileImpl(child.path(), fsInfo, data.groupBlockSize()));
                     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acf140c4/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 3a7464c..11003a5 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -40,7 +40,6 @@ import static org.apache.ignite.internal.processors.igfs.IgfsEx.*;
  * Adapter to use any Hadoop file system {@link FileSystem} as  {@link IgfsSecondaryFileSystem}.
  */
 public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, AutoCloseable
{
-
     /** Hadoop file system. */
     private final FileSystem fileSys;
 
@@ -345,7 +344,8 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
                 }
 
                 @Override public int blockSize() {
-                    return (int)status.getBlockSize();
+                    // By convention directory has blockSize == 0, while file has blockSize
> 0:
+                    return isDirectory() ? 0 : (int)status.getBlockSize();
                 }
 
                 @Override public long groupBlockSize() {
@@ -384,7 +384,6 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
                     return props;
                 }
             };
-
         }
         catch (FileNotFoundException ignore) {
             return null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acf140c4/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
index 93c0df4..41ef3e5 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
@@ -694,12 +694,20 @@ public class IgniteHadoopFileSystem extends FileSystem {
                 return secondaryFs.rename(toSecondary(src), toSecondary(dst));
             }
             else {
-                // Will throw exception if failed.
-                rmtClient.rename(srcPath, dstPath);
-
                 if (clientLog.isLogEnabled())
                     clientLog.logRename(srcPath, mode, dstPath);
 
+                try {
+                    rmtClient.rename(srcPath, dstPath);
+                }
+                catch (IOException ioe) {
+                    // Log the exception before rethrowing since it may be ignored:
+                    LOG.warn("Failed to rename [srcPath=" + srcPath + ", dstPath=" + dstPath
+ ", mode=" + mode + ']',
+                        ioe);
+
+                    throw ioe;
+                }
+
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acf140c4/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 70ad99f..5dac047 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
@@ -587,11 +587,13 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements
Closea
 
                 secondaryFs.renameInternal(toSecondary(src), toSecondary(dst));
             }
+            else {
+                if (clientLog.isLogEnabled())
+                    clientLog.logRename(srcPath, modeRslvr.resolveMode(srcPath), dstPath);
 
-            rmtClient.rename(srcPath, dstPath);
+                rmtClient.rename(srcPath, dstPath);
+            }
 
-            if (clientLog.isLogEnabled())
-                clientLog.logRename(srcPath, modeRslvr.resolveMode(srcPath), dstPath);
         }
         finally {
             leaveBusy();


Mime
View raw message