Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C8948182E9 for ; Fri, 29 May 2015 09:21:02 +0000 (UTC) Received: (qmail 59116 invoked by uid 500); 29 May 2015 09:21:02 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 59086 invoked by uid 500); 29 May 2015 09:21:02 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 59077 invoked by uid 99); 29 May 2015 09:21:02 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2015 09:21:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 3FA82C0B58 for ; Fri, 29 May 2015 09:21:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id QMDDxQYytsTn for ; Fri, 29 May 2015 09:20:55 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 4A117207AC for ; Fri, 29 May 2015 09:20:55 +0000 (UTC) Received: (qmail 58880 invoked by uid 99); 29 May 2015 09:20:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2015 09:20:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EFCACE10DF; Fri, 29 May 2015 09:20:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 29 May 2015 09:20:57 -0000 Message-Id: In-Reply-To: <44a1390b6f9f4310a83e6b8e40c0772b@git.apache.org> References: <44a1390b6f9f4310a83e6b8e40c0772b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Fri May 29 12:21:09 2015 +0300 Committer: vozerov-gridgain 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 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 { 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 { } /** - * 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 ioExs = new LinkedList<>(); + closed = true; + + Exception err = null; Set 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(); } }