Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 909E9200B84 for ; Mon, 5 Sep 2016 15:18:31 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8F756160ACC; Mon, 5 Sep 2016 13:18:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4B929160ADB for ; Mon, 5 Sep 2016 15:18:30 +0200 (CEST) Received: (qmail 67549 invoked by uid 500); 5 Sep 2016 13:18:29 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 67040 invoked by uid 99); 5 Sep 2016 13:18:29 -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; Mon, 05 Sep 2016 13:18:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EE1DDEF7C3; Mon, 5 Sep 2016 13:18:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Mon, 05 Sep 2016 13:18:47 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [20/20] ignite git commit: WIP. archived-at: Mon, 05 Sep 2016 13:18:31 -0000 WIP. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1cdca9ec Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1cdca9ec Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1cdca9ec Branch: refs/heads/ignite-3611-1 Commit: 1cdca9ec941de26bbcd1671fd7fbc7302a052d7d Parents: 008cf64 Author: vozerov-gridgain Authored: Mon Sep 5 16:18:10 2016 +0300 Committer: vozerov-gridgain Committed: Mon Sep 5 16:18:10 2016 +0300 ---------------------------------------------------------------------- .../internal/processors/igfs/IgfsImpl.java | 73 +++++++++++--------- 1 file changed, 39 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/1cdca9ec/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 c704e00..3b25c82 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 @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.igfs; -import java.util.Set; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; @@ -68,7 +67,6 @@ import org.apache.ignite.internal.processors.igfs.client.IgfsClientUpdateCallabl import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.util.GridSpinBusyLock; import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.typedef.C1; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.A; @@ -791,7 +789,7 @@ public final class IgfsImpl implements IgfsEx { IgfsMode mode = resolveMode(path); - Collection files = new HashSet<>(); + Collection files = new HashSet<>(); if (IgfsUtils.isDualMode(mode)) { assert secondaryFs != null; @@ -799,8 +797,10 @@ public final class IgfsImpl implements IgfsEx { try { Collection children = secondaryFs.listPaths(path); - for (IgfsPath child : children) - files.add(child.name()); + files.addAll(children); + + if (!modeRslvr.hasPrimaryChild(path)) + return files; } catch (Exception e) { U.error(log, "List paths in DUAL mode failed [path=" + path + ']', e); @@ -809,20 +809,17 @@ public final class IgfsImpl implements IgfsEx { } } - if (!IgfsUtils.isDualMode(mode) || modeRslvr.hasPrimaryChild(path)) { - IgniteUuid fileId = meta.fileId(path); + IgfsEntryInfo info = primaryInfoForListing(path); - if (fileId != null) - files.addAll(meta.directoryListing(fileId).keySet()); - else if (mode == PRIMARY) - throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path); + if (info != null) { + // Perform the listing. + for (String child : info.listing().keySet()) + files.add(new IgfsPath(path, child)); } + else if (mode == PRIMARY) + throw new IgfsPathNotFoundException("Failed to list paths (path not found): " + path); - return F.viewReadOnly(files, new C1() { - @Override public IgfsPath apply(String e) { - return new IgfsPath(path, e); - } - }); + return files; } }); } @@ -841,7 +838,7 @@ public final class IgfsImpl implements IgfsEx { IgfsMode mode = resolveMode(path); - Set files = new HashSet<>(); + Collection files = new HashSet<>(); if (IgfsUtils.isDualMode(mode)) { assert secondaryFs != null; @@ -865,27 +862,22 @@ public final class IgfsImpl implements IgfsEx { } } - IgniteUuid fileId = meta.fileId(path); - - if (fileId != null) { - IgfsEntryInfo info = meta.info(fileId); + IgfsEntryInfo info = primaryInfoForListing(path); - // Handle concurrent deletion. - if (info != null) { - if (info.isFile()) - // If this is a file, return its description. - return Collections.singleton(new IgfsFileImpl(path, info, - data.groupBlockSize())); + if (info != null) { + if (info.isFile()) + // If this is a file, return its description. + return Collections.singleton(new IgfsFileImpl(path, info, + data.groupBlockSize())); - // Perform the listing. - for (Map.Entry e : info.listing().entrySet()) { - IgfsEntryInfo childInfo = meta.info(e.getValue().fileId()); + // Perform the listing. + for (Map.Entry e : info.listing().entrySet()) { + IgfsEntryInfo childInfo = meta.info(e.getValue().fileId()); - if (childInfo != null) { - IgfsPath childPath = new IgfsPath(path, e.getKey()); + if (childInfo != null) { + IgfsPath childPath = new IgfsPath(path, e.getKey()); - files.add(new IgfsFileImpl(childPath, childInfo, data.groupBlockSize())); - } + files.add(new IgfsFileImpl(childPath, childInfo, data.groupBlockSize())); } } } @@ -897,6 +889,19 @@ public final class IgfsImpl implements IgfsEx { }); } + /** + * Get primary file system info for listing operation. + * + * @param path Path. + * @return Info or {@code null} if not found. + * @throws IgniteCheckedException If failed. + */ + private IgfsEntryInfo primaryInfoForListing(IgfsPath path) throws IgniteCheckedException { + IgniteUuid fileId = meta.fileId(path); + + return fileId != null ? meta.info(fileId) : null; + } + /** {@inheritDoc} */ @Override public long usedSpaceSize() { return metrics().localSpaceSize();