Repository: incubator-ignite Updated Branches: refs/heads/ignite-26 7a8cde7a9 -> 6e104b80a
# ignite-26 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6e104b80 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6e104b80 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6e104b80 Branch: refs/heads/ignite-26 Commit: 6e104b80afe8c6399056abac322d7e22bbb1b0b2 Parents: 7a8cde7 Author: sboikov <sboi...@gridgain.com> Authored: Mon Feb 2 16:58:54 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Mon Feb 2 16:58:54 2015 +0300 ---------------------------------------------------------------------- .../processors/fs/GridGgfsMetaManager.java | 69 +++++++++++--------- .../fs/GridGgfsMetaManagerSelfTest.java | 22 ++++--- .../processors/fs/GridGgfsModesSelfTest.java | 4 +- 3 files changed, 55 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6e104b80/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManager.java index 002f1ca..3f070b9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManager.java @@ -498,7 +498,7 @@ public class GridGgfsMetaManager extends GridGgfsManager { GridGgfsFileInfo oldInfo = info(fileId); if (oldInfo == null) - throw new IgniteFsFileNotFoundException("Failed to unlock file (file not found): " + fileId); + throw fsException(new IgniteFsFileNotFoundException("Failed to unlock file (file not found): " + fileId)); if (!info.lockId().equals(oldInfo.lockId())) throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) [fileId=" + fileId + @@ -737,10 +737,10 @@ public class GridGgfsMetaManager extends GridGgfsManager { assert validTxState(true); if (parentInfo == null) - throw new IgniteFsFileNotFoundException("Failed to lock parent directory (not found): " + parentId); + throw fsException(new IgniteFsFileNotFoundException("Failed to lock parent directory (not found): " + parentId)); if (!parentInfo.isDirectory()) - throw new IgniteFsInvalidPathException("Parent file is not a directory: " + parentInfo); + throw fsException(new IgniteFsInvalidPathException("Parent file is not a directory: " + parentInfo)); Map<String, GridGgfsListingEntry> parentListing = parentInfo.listing(); @@ -837,41 +837,41 @@ public class GridGgfsMetaManager extends GridGgfsManager { GridGgfsFileInfo srcInfo = infoMap.get(srcParentId); if (srcInfo == null) - throw new IgniteFsFileNotFoundException("Failed to lock source directory (not found?)" + - " [srcParentId=" + srcParentId + ']'); + throw fsException(new IgniteFsFileNotFoundException("Failed to lock source directory (not found?)" + + " [srcParentId=" + srcParentId + ']')); if (!srcInfo.isDirectory()) - throw new IgniteFsInvalidPathException("Source is not a directory: " + srcInfo); + throw fsException(new IgniteFsInvalidPathException("Source is not a directory: " + srcInfo)); GridGgfsFileInfo destInfo = infoMap.get(destParentId); if (destInfo == null) - throw new IgniteFsFileNotFoundException("Failed to lock destination directory (not found?)" + - " [destParentId=" + destParentId + ']'); + throw fsException(new IgniteFsFileNotFoundException("Failed to lock destination directory (not found?)" + + " [destParentId=" + destParentId + ']')); if (!destInfo.isDirectory()) - throw new IgniteFsInvalidPathException("Destination is not a directory: " + destInfo); + throw fsException(new IgniteFsInvalidPathException("Destination is not a directory: " + destInfo)); GridGgfsFileInfo fileInfo = infoMap.get(fileId); if (fileInfo == null) - throw new IgniteFsFileNotFoundException("Failed to lock target file (not found?) [fileId=" + - fileId + ']'); + throw fsException(new IgniteFsFileNotFoundException("Failed to lock target file (not found?) [fileId=" + + fileId + ']')); GridGgfsListingEntry srcEntry = srcInfo.listing().get(srcFileName); GridGgfsListingEntry destEntry = destInfo.listing().get(destFileName); // If source file does not exist or was re-created. if (srcEntry == null || !srcEntry.fileId().equals(fileId)) - throw new IgniteFsFileNotFoundException("Failed to remove file name from the source directory" + + throw fsException(new IgniteFsFileNotFoundException("Failed to remove file name from the source directory" + " (file not found) [fileId=" + fileId + ", srcFileName=" + srcFileName + - ", srcParentId=" + srcParentId + ", srcEntry=" + srcEntry + ']'); + ", srcParentId=" + srcParentId + ", srcEntry=" + srcEntry + ']')); // If stored file already exist. if (destEntry != null) - throw new IgniteFsInvalidPathException("Failed to add file name into the destination directory " + + throw fsException(new IgniteFsInvalidPathException("Failed to add file name into the destination directory " + "(file already exists) [fileId=" + fileId + ", destFileName=" + destFileName + - ", destParentId=" + destParentId + ", destEntry=" + destEntry + ']'); + ", destParentId=" + destParentId + ", destEntry=" + destEntry + ']')); assert metaCache.get(srcParentId) != null; assert metaCache.get(destParentId) != null; @@ -981,8 +981,8 @@ public class GridGgfsMetaManager extends GridGgfsManager { Map<String, GridGgfsListingEntry> listing = fileInfo.listing(); if (!F.isEmpty(listing)) - throw new GridGgfsDirectoryNotEmptyException("Failed to remove file (directory is not empty)" + - " [fileId=" + fileId + ", listing=" + listing + ']'); + throw fsException(new GridGgfsDirectoryNotEmptyException("Failed to remove file (directory is not empty)" + + " [fileId=" + fileId + ", listing=" + listing + ']')); } // Validate file in the parent listing. @@ -1844,7 +1844,7 @@ public class GridGgfsMetaManager extends GridGgfsManager { if (info != null) { if (!info.isFile()) - throw new IgniteFsInvalidPathException("Failed to open file (not a file): " + path); + throw fsException(new IgniteFsInvalidPathException("Failed to open file (not a file): " + path)); return new GridGgfsSecondaryInputStreamDescriptor(info, fs.open(path, bufSize)); } @@ -1857,9 +1857,9 @@ public class GridGgfsMetaManager extends GridGgfsManager { GridGgfsFileInfo info = infos.get(path); if (info == null) - throw new IgniteFsFileNotFoundException("File not found: " + path); + throw fsException(new IgniteFsFileNotFoundException("File not found: " + path)); if (!info.isFile()) - throw new IgniteFsInvalidPathException("Failed to open file (not a file): " + path); + throw fsException(new IgniteFsInvalidPathException("Failed to open file (not a file): " + path)); return new GridGgfsSecondaryInputStreamDescriptor(infos.get(path), fs.open(path, bufSize)); } @@ -2047,11 +2047,12 @@ public class GridGgfsMetaManager extends GridGgfsManager { // Source path and destination (or destination parent) must exist. if (srcInfo == null) - throw new IgniteFsFileNotFoundException("Failed to rename (source path not found): " + src); + throw fsException(new IgniteFsFileNotFoundException("Failed to rename " + + "(source path not found): " + src)); if (destInfo == null && destParentInfo == null) - throw new IgniteFsFileNotFoundException("Failed to rename (destination path not found): " + - dest); + throw fsException(new IgniteFsFileNotFoundException("Failed to rename " + + "(destination path not found): " + dest)); // Delegate to the secondary file system. fs.rename(src, dest); @@ -2449,7 +2450,7 @@ public class GridGgfsMetaManager extends GridGgfsManager { if (changed != null) { finished = true; - throw new IgniteFsConcurrentModificationException(changed); + throw fsException(new IgniteFsConcurrentModificationException(changed)); } else { boolean newParents = false; @@ -2607,21 +2608,21 @@ public class GridGgfsMetaManager extends GridGgfsManager { GridGgfsFileInfo fileInfo = infoMap.get(fileId); if (fileInfo == null) - throw new IgniteFsFileNotFoundException("Failed to update times (path was not found): " + - fileName); + throw fsException(new IgniteFsFileNotFoundException("Failed to update times " + + "(path was not found): " + fileName)); GridGgfsFileInfo parentInfo = infoMap.get(parentId); if (parentInfo == null) - throw new IgniteFsInvalidPathException("Failed to update times (parent was not found): " + - fileName); + throw fsException(new IgniteFsInvalidPathException("Failed to update times " + + "(parent was not found): " + fileName)); GridGgfsListingEntry entry = parentInfo.listing().get(fileName); // Validate listing. if (entry == null || !entry.fileId().equals(fileId)) - throw new IgniteFsInvalidPathException("Failed to update times (file concurrently modified): " + - fileName); + throw fsException(new IgniteFsInvalidPathException("Failed to update times " + + "(file concurrently modified): " + fileName)); assert parentInfo.isDirectory(); @@ -2658,6 +2659,14 @@ public class GridGgfsMetaManager extends GridGgfsManager { } /** + * @param msg Error message. + * @return Checked exception. + */ + private static IgniteCheckedException fsException(IgniteFsException err) { + return new IgniteCheckedException(err); + } + + /** * Synchronization task interface. */ private static interface SynchronizationTask<T> { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6e104b80/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManagerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManagerSelfTest.java index b6f1f0f..5b6a350 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsMetaManagerSelfTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.fs; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.fs.*; @@ -418,12 +419,13 @@ public class GridGgfsMetaManagerSelfTest extends GridGgfsCommonAbstractTest { */ private void expectsPutIfAbsentFail(final IgniteUuid parentId, final String fileName, final GridGgfsFileInfo fileInfo, @Nullable String msg) { - assertThrows(log, new Callable() { - @Override - public Object call() throws Exception { + Throwable err = assertThrows(log, new Callable() { + @Override public Object call() throws Exception { return mgr.putIfAbsent(parentId, fileName, fileInfo); } - }, IgniteFsException.class, msg); + }, IgniteCheckedException.class, msg); + + assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgniteFsException); } /** @@ -438,14 +440,16 @@ public class GridGgfsMetaManagerSelfTest extends GridGgfsCommonAbstractTest { */ private void expectsRenameFail(final IgniteUuid fileId, final String srcFileName, final IgniteUuid srcParentId, final String destFileName, final IgniteUuid destParentId, @Nullable String msg) { - assertThrowsInherited(log, new Callable() { + Throwable err = assertThrowsInherited(log, new Callable() { @Override public Object call() throws Exception { mgr.move(fileId, srcFileName, srcParentId, destFileName, destParentId); return null; } - }, IgniteFsException.class, msg); + }, IgniteCheckedException.class, msg); + + assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgniteFsException); } /** @@ -459,12 +463,14 @@ public class GridGgfsMetaManagerSelfTest extends GridGgfsCommonAbstractTest { */ private void expectsRemoveFail(final IgniteUuid parentId, final String fileName, final IgniteUuid fileId, final IgniteFsPath path, @Nullable String msg) { - assertThrows(log, new Callable() { + Throwable err = assertThrows(log, new Callable() { @Nullable @Override public Object call() throws Exception { mgr.removeIfEmpty(parentId, fileName, fileId, path, true); return null; } - }, GridGgfsDirectoryNotEmptyException.class, msg); + }, IgniteCheckedException.class, msg); + + assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof GridGgfsDirectoryNotEmptyException); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6e104b80/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsModesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsModesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsModesSelfTest.java index 8ab1101..88491d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsModesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/GridGgfsModesSelfTest.java @@ -374,7 +374,7 @@ public class GridGgfsModesSelfTest extends GridGgfsCommonAbstractTest { startUp(); } catch (IgniteException e) { - errMsg = e.getCause().getMessage(); + errMsg = e.getCause().getCause().getMessage(); } assertTrue(errMsg.startsWith( @@ -440,7 +440,7 @@ public class GridGgfsModesSelfTest extends GridGgfsCommonAbstractTest { startUp(); } catch (IgniteException e) { - errMsg = e.getCause().getMessage(); + errMsg = e.getCause().getCause().getMessage(); } assertTrue(errMsg.startsWith(