You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/05/29 11:20:57 UTC

[4/4] incubator-ignite git commit: # Review.

# Review.


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

Branch: refs/heads/ignite-218-hdfs-only
Commit: 913871d924ad69336632458e88fd63d76c4425a9
Parents: ba51ff6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri May 29 12:21:09 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri May 29 12:21:09 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/igfs/IgfsUserContext.java |  6 +-
 .../igfs/secondary/IgfsSecondaryFileSystem.java |  2 +
 .../fs/IgniteHadoopIgfsSecondaryFileSystem.java |  3 +
 .../hadoop/fs/HadoopLazyConcurrentMap.java      | 80 ++++++++------------
 4 files changed, 41 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/913871d9/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
index 1242982..5a65bdb 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsUserContext.java
@@ -108,9 +108,9 @@ public abstract class IgfsUserContext {
 
     /**
      * Gets the current context user.
-     * If this method is invoked outside of any {@link #doAs(String, IgniteOutClosure)} on the call stack, it will return null.
-     * Otherwise it will return the user name set in the most lower {@link #doAs(String, IgniteOutClosure)} call
-     * on the call stack.
+     * If this method is invoked outside of any {@link #doAs(String, IgniteOutClosure)} on the call stack, it will
+     * return null. Otherwise it will return the user name set in the most lower
+     * {@link #doAs(String, IgniteOutClosure)} call on the call stack.
      * @return The current user, may be null.
      */
     @Nullable public static String currentUser() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/913871d9/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
index 9026eac..b6f8226 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
@@ -198,4 +198,6 @@ public interface IgfsSecondaryFileSystem {
      * @return Map of properties.
      */
     public Map<String,String> properties();
+
+    // TODO: Add close();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/913871d9/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 51878da..81fce96 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
@@ -42,6 +42,7 @@ import static org.apache.ignite.internal.processors.igfs.IgfsEx.*;
  * In fact, this class deals with different FileSystems depending on the user context,
  * see {@link IgfsUserContext#currentUser()}.
  */
+// TODO: Remove auto-closeable.
 public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, AutoCloseable {
     /** Properties of file system, see {@link #properties()}
      *
@@ -466,6 +467,8 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
 
     /** {@inheritDoc} */
     @Override public void close() throws IgniteCheckedException {
+        // TODO: Close default FS.
+
         fileSysLazyMap.close();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/913871d9/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
index 0fe9871..71b38c4 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/fs/HadoopLazyConcurrentMap.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.hadoop.fs;
 
 import org.apache.ignite.*;
 import org.apache.ignite.internal.util.future.*;
-import org.jetbrains.annotations.*;
 import org.jsr166.*;
 
 import java.io.*;
@@ -65,26 +64,25 @@ public class HadoopLazyConcurrentMap<K, V extends Closeable> {
         ValueWrapper w = map.get(k);
 
         if (w == null) {
-            final ValueWrapper wNew = new ValueWrapper(k);
+            closeLock.readLock().lock();
 
-            w = map.putIfAbsent(k, wNew);
+            try {
+                if (closed)
+                    throw new IllegalStateException("Failed to create value for key [" + k
+                        + "]: the map is already closed.");
 
-            if (w == null) {
-                // new wrapper 'w' has been put, so init the value:
-                closeLock.readLock().lock();
+                final ValueWrapper wNew = new ValueWrapper(k);
 
-                try {
-                    if (closed)
-                        throw new IllegalStateException("Failed to create value for key [" + k
-                            + "]: the map is already closed.");
+                w = map.putIfAbsent(k, wNew);
 
+                if (w == null) {
                     wNew.init();
-                }
-                finally {
-                    closeLock.readLock().unlock();
-                }
 
-                w = wNew;
+                    w = wNew;
+                }
+            }
+            finally {
+                closeLock.readLock().unlock();
             }
         }
 
@@ -101,57 +99,45 @@ public class HadoopLazyConcurrentMap<K, V extends Closeable> {
     }
 
     /**
-     * Gets the value without any attempt to create a new one.
-     * @param k the key
-     * @return the value, or null if there is no value for this key.
-     */
-    public @Nullable V get(K k) {
-        ValueWrapper w = map.get(k);
-
-        if (w == null)
-            return null;
-
-        try {
-            return w.getValue();
-        }
-        catch (IgniteCheckedException ie) {
-            throw new IgniteException(ie);
-        }
-    }
-
-    /**
      * Clears the map and closes all the values.
      */
     public void close() throws IgniteCheckedException {
         closeLock.writeLock().lock();
 
         try {
-            List<IOException> ioExs = new LinkedList<>();
+            closed = true;
+
+            Exception err = null;
 
             Set<K> keySet = map.keySet();
 
-            for (K key: keySet) {
-                ValueWrapper w = map.get(key);
+            for (K key : keySet) {
+                V v = null;
 
-                if (w != null) {
-                    try {
-                        V v = w.getValue();
+                try {
+                    v = map.get(key).getValue();
+                }
+                catch (IgniteCheckedException ignore) {
+                    // No-op.
+                }
 
+                if (v != null) {
+                    try {
                         v.close();
                     }
-                    catch (IOException ioe) {
-                        ioExs.add(ioe);
+                    catch (Exception err0) {
+                        if (err == null)
+                            err = err0;
                     }
                 }
             }
 
             map.clear();
 
-            if (!ioExs.isEmpty())
-                throw new IgniteCheckedException(ioExs.get(0));
-
-            closed = true;
-        } finally {
+            if (err != null)
+                throw new IgniteCheckedException(err);
+        }
+        finally {
             closeLock.writeLock().unlock();
         }
     }