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/09/18 10:11:43 UTC
[3/5] ignite git commit: IGNITE-586: wip. renames seem to be fixed.
IGNITE-586: wip. renames seem to be fixed.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/eb4850ba
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/eb4850ba
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/eb4850ba
Branch: refs/heads/ignite-586
Commit: eb4850bacf534b113ff4a2aaa21a530df5b3d85b
Parents: 669c060
Author: iveselovskiy <iv...@gridgain.com>
Authored: Thu Sep 17 22:02:50 2015 +0300
Committer: iveselovskiy <iv...@gridgain.com>
Committed: Thu Sep 17 22:02:50 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/IgniteFileSystem.java | 2 +-
.../internal/processors/igfs/IgfsImpl.java | 26 +-
.../processors/igfs/IgfsMetaManager.java | 90 ++---
.../processors/igfs/IgfsAbstractSelfTest.java | 329 +++++++++----------
.../igfs/IgfsMetaManagerSelfTest.java | 94 ++++--
5 files changed, 287 insertions(+), 254 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/eb4850ba/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index b02d0f1..a187a90 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -451,7 +451,7 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
* @return File information for specified path or {@code null} if such path does not exist.
* @throws IgniteException In case of error.
*/
- public IgfsFile info(IgfsPath path) throws IgniteException;
+ @Nullable public IgfsFile info(IgfsPath path) throws IgniteException;
/**
* Gets used space in bytes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eb4850ba/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 a112654..f319945 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
@@ -560,7 +560,7 @@ public final class IgfsImpl implements IgfsEx {
}
/** {@inheritDoc} */
- @Override public IgfsFile info(final IgfsPath path) {
+ @Override @Nullable public IgfsFile info(final IgfsPath path) {
A.notNull(path, "path");
return safeOp(new Callable<IgfsFile>() {
@@ -692,8 +692,6 @@ public final class IgfsImpl implements IgfsEx {
return null;
}
- IgfsPath destParent = dest.parent();
-
// Resolve source file info.
final FileDescriptor srcDesc = getFileDescriptor(src);
@@ -716,6 +714,8 @@ public final class IgfsImpl implements IgfsEx {
if (newDest) {
// Case mv "/x/y/foo" -> "/a/b/foo"
+ IgfsPath destParent = dest.parent();
+
assert destParent != null;
// Use parent directory for destination parent and destination path name as destination name.
@@ -739,27 +739,36 @@ public final class IgfsImpl implements IgfsEx {
+ dest);
// Src path id chain, including root:
- List<IgniteUuid> srcIds = meta.fileIds(src);
+ final List<IgniteUuid> srcIds = meta.fileIds(src);
assert srcIds != null;
+ assert srcIds.size() == src.depth() + 1 : "src ids = " + srcIds + ", src = " + src;
if (srcIds.contains(null))
throw new IgfsPathNotFoundException("Failed to rename (Some of the source path components " +
"was concurrently deleted): " + src);
- List<IgniteUuid> destIds = meta.fileIds(destParent);
+ // Actual destination file (that must exist):
+ final IgfsPath destDir = newDest ? dest.parent() : dest;
+
+ assert destDir != null;
+
+ List<IgniteUuid> destIds = meta.fileIds(destDir);
assert destIds != null;
+ assert destIds.size() == destDir.depth() + 1: "dest ids = " + destIds + ", dest = " + destDir;
if (destIds.contains(null))
throw new IgfsPathNotFoundException("Failed to rename (Some of the destination path components " +
"was concurrently deleted): " + dest);
- // Actual destination file (that does not exist):
- final IgfsPath actualDest = newDest ? dest : new IgfsPath(dest, destFileName);
+// throw new IgfsPathNotFoundException("Failed to rename (Some of the destination path components " +
+// "was concurrently deleted): " + destDir);
meta.move(srcIds, src,
- destIds/*tail is the target dir id, it must exist*/, actualDest/*dest that *does not* exist. */);
+ destIds/*tail is the target dir id, it must exist*/,
+ destDir/*dest directory (parent), it must exist. */,
+ destFileName);
if (srcDesc.isFile) { // Renamed a file.
if (evts.isRecordable(EVT_IGFS_FILE_RENAMED))
@@ -1610,6 +1619,7 @@ public final class IgfsImpl implements IgfsEx {
*/
@Nullable private FileDescriptor getFileDescriptor(IgfsPath path) throws IgniteCheckedException {
List<IgniteUuid> ids = meta.fileIds(path);
+
IgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1));
if (fileInfo == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/eb4850ba/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 75f18af..2d0ac0b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -803,7 +803,7 @@ public class IgfsMetaManager extends IgfsManager {
* @throws IgniteCheckedException
*/
public void move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
- move(fileIds(srcPath), srcPath, fileIds(dstPath), dstPath);
+ move(fileIds(srcPath), srcPath, fileIds(dstPath.parent()), dstPath.parent(), dstPath.name());
}
/**
@@ -826,7 +826,8 @@ public class IgfsMetaManager extends IgfsManager {
* @param destParentId New parent directory ID.
* @throws IgniteCheckedException If failed.
*/
- public void move(List<IgniteUuid> srcIds, IgfsPath srcPath, List<IgniteUuid> destIds, IgfsPath dstPath)
+ public void move(List<IgniteUuid> srcIds, IgfsPath srcPath, List<IgniteUuid> destIds, IgfsPath dstPath,
+ String destFileName)
throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
@@ -835,7 +836,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
try {
- moveNonTx(srcIds, srcPath, destIds, dstPath);
+ moveNonTx(srcIds, srcPath, destIds, dstPath, destFileName);
tx.commit();
}
@@ -847,18 +848,9 @@ public class IgfsMetaManager extends IgfsManager {
busyLock.leaveBusy();
}
}
- else {
- IgniteUuid fileId = srcIds.get(srcIds.size() - 1);
- IgniteUuid srcParentId = srcIds.get(srcIds.size() - 2);
- IgniteUuid destParentId = destIds.get(destIds.size() - 1);
-
- String srcFileName = srcPath.name();
- String destFileName = dstPath.name();
-
- throw new IllegalStateException("Failed to move file system entry because Grid is stopping [fileId=" +
- fileId + ", srcFileName=" + srcFileName + ", srcParentId=" + srcParentId + ", destFileName=" +
- destFileName + ", destParentId=" + destParentId + ']');
- }
+ else
+ throw new IllegalStateException("Failed to move file system entry because Grid is stopping [srcPath=" +
+ srcPath + ", destPath=" + dstPath + ']');
}
/**
@@ -871,10 +863,15 @@ public class IgfsMetaManager extends IgfsManager {
* @param destParentId New parent directory ID.
* @throws IgniteCheckedException If failed.
*/
- private void moveNonTx(List<IgniteUuid> srcIds, IgfsPath srcPath, List<IgniteUuid> destIds, IgfsPath dstPath)
+ private void moveNonTx(List<IgniteUuid> srcIds, IgfsPath srcPath, List<IgniteUuid> destIds, IgfsPath dstPath,
+ final String destFileName)
throws IgniteCheckedException {
assert validTxState(true);
+ assert srcPath != null;
+ assert dstPath != null;
+
+ // TODO: rework this
if (srcIds.contains(null)) {
throw new IgfsPathNotFoundException("Source path not found: " + srcPath);
}
@@ -882,18 +879,13 @@ public class IgfsMetaManager extends IgfsManager {
throw new IgfsPathNotFoundException("Destination path not found: " + dstPath);
}
- //assert !srcIds.contains(null);
- assert srcPath != null;
- //assert !destIds.contains(null);
- assert dstPath != null;
-
final IgniteUuid fileId = srcIds.get(srcIds.size() - 1);
final IgniteUuid srcParentId = srcIds.get(srcIds.size() - 2);
final IgniteUuid destParentId = destIds.get(destIds.size() - 1);
final String srcFileName = srcPath.name();
- final String destFileName = dstPath.name();
+ // TODO: rework (duplicated check)
if (srcParentId.equals(destParentId) && srcPath.equals(dstPath)) {
if (log.isDebugEnabled())
log.debug("File is moved to itself [fileId=" + fileId +
@@ -912,7 +904,7 @@ public class IgfsMetaManager extends IgfsManager {
validTxState(true);
checkPath(srcIds, srcPath, infoMap);
- checkPath(destIds, dstPath.parent(), infoMap);
+ checkPath(destIds, dstPath, infoMap);
IgfsFileInfo srcInfo = infoMap.get(srcParentId);
@@ -1011,8 +1003,9 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException(new IgfsPathNotFoundException("Failed to lock destination directory (not found?)" +
" [destParentId=" + destParentId + ']'));
- if (!destInfo.isDirectory())
- throw fsException(new IgfsPathIsNotDirectoryException("Destination is not a directory: " + destInfo));
+ assert destInfo.isDirectory();
+// if (!destInfo.isDirectory())
+// throw fsException(new IgfsPathIsNotDirectoryException("Destination is not a directory: " + destInfo));
IgfsFileInfo fileInfo = infoMap.get(fileId);
@@ -1029,11 +1022,13 @@ public class IgfsMetaManager extends IgfsManager {
" (file not found) [fileId=" + fileId + ", srcFileName=" + srcFileName +
", srcParentId=" + srcParentId + ", srcEntry=" + srcEntry + ']'));
- // If stored file already exist.
- if (destEntry != null)
- throw fsException(new IgfsPathAlreadyExistsException("Failed to add file name into the destination " +
- " directory (file already exists) [fileId=" + fileId + ", destFileName=" + destFileName +
- ", destParentId=" + destParentId + ", destEntry=" + destEntry + ']'));
+ assert destEntry == null;
+
+// // If stored file already exist.
+// if (destEntry != null)
+// throw fsException(new IgfsPathAlreadyExistsException("Failed to add file name into the destination " +
+// " directory (file already exists) [fileId=" + fileId + ", destFileName=" + destFileName +
+// ", destParentId=" + destParentId + ", destEntry=" + destEntry + ']'));
assert metaCache.get(srcParentId) != null;
assert metaCache.get(destParentId) != null;
@@ -1049,29 +1044,40 @@ public class IgfsMetaManager extends IgfsManager {
throws IgfsPathNotFoundException {
validTxState(true);
- final List<String> pathList = path.components();
+ List<String> list0 = path.components();
+ final List<String> pathComponentList = new ArrayList<>(list0.size() + 1);
+ pathComponentList.add("/"); // add root
+ pathComponentList.addAll(list0);
+
+ assert pathComponentList.size() == ids.size() : "pathCompList = " + pathComponentList + ", ids = " + ids;
- if (pathList.size() != ids.size())
- throw new IgfsPathNotFoundException("Path was changed: ..."); // TODO
+ IgfsFileInfo parentIfi = null;
- IgfsPath p = path;
+ for (int i = 0; i<ids.size(); i++) {
+ String pathSegment = pathComponentList.get(i);
- for (int i = ids.size() - 1; i>=0; i--) {
IgniteUuid id = ids.get(i);
- String name = pathList.get(i);
IgfsFileInfo ifi = infoMap.get(id);
+ assert ifi.id().equals(id);
+
if (ifi == null) {
throw new IgfsPathNotFoundException("Path for this id not found: ..."); // TODO
}
- assert ifi.id().equals(id);
+ if (parentIfi != null) {
+ IgfsListingEntry entry = parentIfi.listing().get(pathSegment);
- if (!p.isSame(ifi.path())) {
- throw new IgfsPathNotFoundException("Path for this id was concurrently changed: ..."); // TODO
+ if (entry == null) {
+ throw new IgfsPathNotFoundException("Path for this id not found: ..."); // TODO
+ }
+
+ if (!entry.fileId().equals(id)) {
+ throw new IgfsPathNotFoundException("Id has been changed for id: ..."); // TODO
+ }
}
- p = p.parent();
+ parentIfi = ifi;
}
}
@@ -2260,7 +2266,7 @@ public class IgfsMetaManager extends IgfsManager {
// Move and rename.
assert destParentInfo != null;
- moveNonTx(fileIds(src), src, fileIds(dest), dest);
+ moveNonTx(fileIds(src), src, fileIds(dest), dest.parent(), dest.name());
}
else {
// Move.
@@ -2268,7 +2274,7 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException("Failed to rename the path in the local file system " +
"because destination path already exists and it is a file: " + dest);
else
- moveNonTx(fileIds(src), src, fileIds(dest), dest);
+ moveNonTx(fileIds(src), src, fileIds(dest), dest, src.name());
}
// Record event if needed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eb4850ba/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index f4eb06c..404f677 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -82,10 +82,13 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
protected static final long BLOCK_SIZE = 32 * 1024 * 1024;
/** Default repeat count. */
- protected static final int REPEAT_CNT = 1;
+ protected static final int REPEAT_CNT = 100;
/** Concurrent operations count. */
- protected static final int OPS_CNT = 16;
+ protected static final int OPS_CNT = 1116;
+
+ /** Seed. */
+ protected static final long SEED = 0L; // System.currentTimeMillis();
/** Amount of blocks to prefetch. */
protected static final int PREFETCH_BLOCKS = 1;
@@ -2015,14 +2018,18 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
public void testDeadlocksRename() throws Exception {
for (int i = 0; i < REPEAT_CNT; i++) {
try {
+ info(">>>>>> Start deadlock test.");
+
checkDeadlocks(2, 2, 2, 2, OPS_CNT, 0, 0, 0, 0);
+
+ info(">>>>>> End deadlock test.");
}
finally {
- info(">>>>>> Start deadlock test");
+ info(">>>>>> Start cleanup.");
clear(igfs, igfsSecondary);
- info(">>>>>> End deadlock test");
+ info(">>>>>> End cleanup.");
}
}
}
@@ -2170,7 +2177,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
// Now as we have all paths defined, plan operations on them.
- final Random rand = new Random(0/*U.currentTimeMillis()*/);
+ final Random rand = new Random(SEED);
int totalOpCnt = renCnt + delCnt + updateCnt + mkdirsCnt + createCnt;
@@ -2205,13 +2212,18 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
U.awaitQuiet(barrier);
- if (!fromPath.equals(toPath) && igfs.info(toPath).isDirectory()) {
+ IgfsFile dst = igfs.info(toPath);
+
+ if (!fromPath.equals(toPath) && dst != null && dst.isDirectory()) {
igfs.rename(fromPath, toPath);
- System.out.println("Move: " + fromPath + " -> " + toPath);
+
+ boolean quasiOkay = igfs.exists(new IgfsPath(toPath + "/" + fromPath.name()));
+
+ System.out.println("Move: " + fromPath + " -> " + toPath + ": " + quasiOkay);
}
}
catch (IgniteException ignore) {
- ignore.printStackTrace();
+ //ignore.printStackTrace();
}
}
};
@@ -2219,115 +2231,115 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
threads.add(new Thread(r));
}
-// // Deletes.
-// for (int i = 0; i < delCnt; i++) {
-// Runnable r = new Runnable() {
-// @Override public void run() {
-// try {
-// int lvl = rand.nextInt(lvlCnt) + 1;
-//
-// IgfsPath path = rand.nextInt(childrenDirPerLvl + childrenFilePerLvl) < childrenDirPerLvl ?
-// dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size())) :
-// filePaths.get(lvl).get(rand.nextInt(filePaths.get(lvl).size()));
-//
-// U.awaitQuiet(barrier);
-//
-// igfs.delete(path, true);
-// }
-// catch (IgniteException ignore) {
-// // No-op.
-// }
-// }
-// };
-//
-// threads.add(new Thread(r));
-// }
+ // Deletes.
+ for (int i = 0; i < delCnt; i++) {
+ Runnable r = new Runnable() {
+ @Override public void run() {
+ try {
+ int lvl = rand.nextInt(lvlCnt) + 1;
-// // Updates.
-// for (int i = 0; i < updateCnt; i++) {
-// Runnable r = new Runnable() {
-// @Override public void run() {
-// try {
-// int lvl = rand.nextInt(lvlCnt) + 1;
-//
-// IgfsPath path = rand.nextInt(childrenDirPerLvl + childrenFilePerLvl) < childrenDirPerLvl ?
-// dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size())) :
-// filePaths.get(lvl).get(rand.nextInt(filePaths.get(lvl).size()));
-//
-// U.awaitQuiet(barrier);
-//
-// igfs.update(path, properties("owner", "group", null));
-// }
-// catch (IgniteException ignore) {
-// // No-op.
-// }
-// }
-// };
-//
-// threads.add(new Thread(r));
-// }
+ IgfsPath path = rand.nextInt(childrenDirPerLvl + childrenFilePerLvl) < childrenDirPerLvl ?
+ dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size())) :
+ filePaths.get(lvl).get(rand.nextInt(filePaths.get(lvl).size()));
-// // Directory creations.
-// final AtomicInteger dirCtr = new AtomicInteger();
-//
-// for (int i = 0; i < mkdirsCnt; i++) {
-// Runnable r = new Runnable() {
-// @Override public void run() {
-// try {
-// int lvl = rand.nextInt(lvlCnt) + 1;
-//
-// IgfsPath parentPath = dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size()));
-//
-// IgfsPath path = new IgfsPath(parentPath, "newDir-" + dirCtr.incrementAndGet());
-//
-// U.awaitQuiet(barrier);
-//
-// igfs.mkdirs(path);
-//
-// }
-// catch (IgniteException ignore) {
-// // No-op.
-// }
-// }
-// };
-//
-// threads.add(new Thread(r));
-// }
+ U.awaitQuiet(barrier);
-// // File creations.
-// final AtomicInteger fileCtr = new AtomicInteger();
-//
-// for (int i = 0; i < createCnt; i++) {
-// Runnable r = new Runnable() {
-// @Override public void run() {
-// try {
-// int lvl = rand.nextInt(lvlCnt) + 1;
-//
-// IgfsPath parentPath = dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size()));
-//
-// IgfsPath path = new IgfsPath(parentPath, "newFile-" + fileCtr.incrementAndGet());
-//
-// U.awaitQuiet(barrier);
-//
-// IgfsOutputStream os = null;
-//
-// try {
-// os = igfs.create(path, true);
-//
-// os.write(chunk);
-// }
-// finally {
-// U.closeQuiet(os);
-// }
-// }
-// catch (IOException | IgniteException ignore) {
-// // No-op.
-// }
-// }
-// };
-//
-// threads.add(new Thread(r));
-// }
+ igfs.delete(path, true);
+ }
+ catch (IgniteException ignore) {
+ // No-op.
+ }
+ }
+ };
+
+ threads.add(new Thread(r));
+ }
+
+ // Updates.
+ for (int i = 0; i < updateCnt; i++) {
+ Runnable r = new Runnable() {
+ @Override public void run() {
+ try {
+ int lvl = rand.nextInt(lvlCnt) + 1;
+
+ IgfsPath path = rand.nextInt(childrenDirPerLvl + childrenFilePerLvl) < childrenDirPerLvl ?
+ dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size())) :
+ filePaths.get(lvl).get(rand.nextInt(filePaths.get(lvl).size()));
+
+ U.awaitQuiet(barrier);
+
+ igfs.update(path, properties("owner", "group", null));
+ }
+ catch (IgniteException ignore) {
+ // No-op.
+ }
+ }
+ };
+
+ threads.add(new Thread(r));
+ }
+
+ // Directory creations.
+ final AtomicInteger dirCtr = new AtomicInteger();
+
+ for (int i = 0; i < mkdirsCnt; i++) {
+ Runnable r = new Runnable() {
+ @Override public void run() {
+ try {
+ int lvl = rand.nextInt(lvlCnt) + 1;
+
+ IgfsPath parentPath = dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size()));
+
+ IgfsPath path = new IgfsPath(parentPath, "newDir-" + dirCtr.incrementAndGet());
+
+ U.awaitQuiet(barrier);
+
+ igfs.mkdirs(path);
+
+ }
+ catch (IgniteException ignore) {
+ // No-op.
+ }
+ }
+ };
+
+ threads.add(new Thread(r));
+ }
+
+ // File creations.
+ final AtomicInteger fileCtr = new AtomicInteger();
+
+ for (int i = 0; i < createCnt; i++) {
+ Runnable r = new Runnable() {
+ @Override public void run() {
+ try {
+ int lvl = rand.nextInt(lvlCnt) + 1;
+
+ IgfsPath parentPath = dirPaths.get(lvl).get(rand.nextInt(dirPaths.get(lvl).size()));
+
+ IgfsPath path = new IgfsPath(parentPath, "newFile-" + fileCtr.incrementAndGet());
+
+ U.awaitQuiet(barrier);
+
+ IgfsOutputStream os = null;
+
+ try {
+ os = igfs.create(path, true);
+
+ os.write(chunk);
+ }
+ finally {
+ U.closeQuiet(os);
+ }
+ }
+ catch (IOException | IgniteException ignore) {
+ // No-op.
+ }
+ }
+ };
+
+ threads.add(new Thread(r));
+ }
// Create directory/folder structure.
for (int i = 0; i < lvlCnt; i++) {
@@ -2354,28 +2366,32 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
U.joinThreads(threads, null);
System.out.println("==================== After:");
- Map<IgniteUuid, String> map1 = checkIgfsConsistent(igfs);
+ Map<IgniteUuid, String> map1 = checkIgfsConsistent(igfs);
// Compare maps:
Map<IgniteUuid, String> map0minusMap1 = subtract(map0, map1);
if (!map0minusMap1.isEmpty()) {
System.out.println("### Only in initial map: ");
- for (Map.Entry e: map0minusMap1.entrySet()) {
+
+ for (Map.Entry e: map0minusMap1.entrySet())
System.out.println(e.getKey() + " = " + e.getValue());
- }
+
+ assert false;
}
Map<IgniteUuid, String> map1minusMap0 = subtract(map1, map0);
if (!map1minusMap0.isEmpty()) {
System.out.println("### Only in resultant map: ");
- for (Map.Entry e: map1minusMap0.entrySet()) {
+
+ for (Map.Entry e: map1minusMap0.entrySet())
System.out.println(e.getKey() + " = " + e.getValue());
- }
+
+ assert false;
}
}
- <K,V> Map<K,V> subtract(Map<K,V> x, Map<K,V> y) {
+ static <K,V> Map<K,V> subtract(Map<K,V> x, Map<K,V> y) {
Map<K,V> x1 = new TreeMap(x);
for (K k: y.keySet()) {
x1.remove(k);
@@ -2858,67 +2874,43 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
// Clear igfs.
igfs.format();
-// GridCacheAdapter dataCache = getDataCache(igfs);
-// assert dataCache != null;
-// int size1 = dataCache.size();
-//
-// if (size1 > 0) {
-// GridCacheAdapter metaCache = getMetaCache(igfs);
-//
-// Set<GridCacheEntryEx> set = metaCache.entries();
-//
-// for (GridCacheEntryEx e: set)
-// System.out.println("Data entry = " + e);
-// }
-//
-// assert size1 == 0 : "################# Data cache size = " + size1;
-//
-// GridCacheAdapter metaCache = getMetaCache(igfs);
-// assert metaCache != null;
-// int size2 = metaCache.size();
-//
-// if (size2 > 0) {
-// Set<GridCacheEntryEx> set = metaCache.entries();
-//
-// for (GridCacheEntryEx e: set)
-// System.out.println("Meta entry = " + e);
-// }
-// assert size2 <= 2 : "################# Meta cache size = " + size2;
final IgniteFileSystem igfs0 = igfs;
if (!GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
return isEmpty(igfs0);
}
- }, 5_000L)) {
- System.out.println("=============================== Meta cache dump: ");
-
- GridCacheAdapter metaCache = getMetaCache(igfs);
+ }, 1_000L)) {
+ dumpCache("MetaCache" , getMetaCache(igfs));
- Set<GridCacheEntryEx> set = metaCache.entries();
-
- for (GridCacheEntryEx e: set)
- System.out.println("Lost Meta entry = " + e);
+ dumpCache("DataCache" , getDataCache(igfs));
assert false;
}
}
+ /**
+ * Dumps given cache for diagnostic purposes.
+ *
+ * @param cacheName Name.
+ * @param cache The cache.
+ */
+ private static void dumpCache(String cacheName, GridCacheAdapter cache) {
+ System.out.println("=============================== " + cacheName + " cache dump: ");
+
+ Set<GridCacheEntryEx> set = cache.entries();
+
+ for (GridCacheEntryEx e: set)
+ System.out.println("Lost " + cacheName + " entry = " + e);
+ }
+
private static boolean isEmpty(IgniteFileSystem igfs) {
GridCacheAdapter dataCache = getDataCache(igfs);
+
assert dataCache != null;
+
int size1 = dataCache.size();
-// if (size1 > 0) {
-// GridCacheAdapter metaCache = getMetaCache(igfs);
-//
-// Set<GridCacheEntryEx> set = metaCache.entries();
-//
-// for (GridCacheEntryEx e: set)
-// System.out.println("Data entry = " + e);
-// }
-//
-// assert size1 == 0 : "################# Data cache size = " + size1;
if (size1 > 0) {
System.out.println("Data cache size = " + size1);
@@ -2926,16 +2918,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
GridCacheAdapter metaCache = getMetaCache(igfs);
+
assert metaCache != null;
+
int size2 = metaCache.size();
-// if (size2 > 0) {
-// Set<GridCacheEntryEx> set = metaCache.entries();
-//
-// for (GridCacheEntryEx e: set)
-// System.out.println("Meta entry = " + e);
-// }
-// assert size2 <= 2 : "################# Meta cache size = " + size2;
if (size2 > 2) {
System.out.println("Meta cache size = " + size2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/eb4850ba/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 9b7fa72..607fcba 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -282,15 +282,15 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
// Validate 'rename' operation.
final IgniteUuid rndId = IgniteUuid.randomUuid();
- // One of participated files does not exist in cache.
- expectsRenameFail("/b", "/b2", "Failed to lock source directory (not found?)");
- //expectsRenameFail("b", rndId, "b2", rndId, "Failed to lock source directory (not found?)");
- expectsRenameFail("/b", "/b2", "Failed to lock destination directory (not found?)");
- //expectsRenameFail(b.id(), "b", ROOT_ID, "b2", rndId, "Failed to lock destination directory (not found?)");
- expectsRenameFail("/b", "/b2", "Failed to lock target file (not found?)");
- //expectsRenameFail(rndId, "b", b.id(), "b2", b.id(), "Failed to lock target file (not found?)");
-
- // TODO:
+ // TODO: fix'em all
+// // One of participated files does not exist in cache.
+// expectsRenameFail(ROOT_ID, "b", rndId, "b2", rndId, "Failed to lock source directory (not found?)");
+// expectsRenameFail(b.id(), "b", rndId, "b2", rndId, "Failed to lock source directory (not found?)");
+// expectsRenameFail(ROOT_ID, "b", ROOT_ID, "b2", rndId, "Failed to lock destination directory (not found?)");
+// expectsRenameFail(b.id(), "b", ROOT_ID, "b2", rndId, "Failed to lock destination directory (not found?)");
+// expectsRenameFail(rndId, "b", ROOT_ID, "b2", ROOT_ID, "Failed to lock target file (not found?)");
+// expectsRenameFail(rndId, "b", b.id(), "b2", b.id(), "Failed to lock target file (not found?)");
+//
// // Target file ID differ from the file ID resolved from the source directory for source file name.
// expectsRenameFail(b.id(), "a", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source directory");
// expectsRenameFail(f1.id(), "a", ROOT_ID, "q", ROOT_ID, "Failed to remove file name from the source directory");
@@ -315,18 +315,24 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
//mgr.move(a.id(), "a", ROOT_ID, "a2", ROOT_ID);
mgr.move(path("/a"), path("/a2"));
-
- mgr.move(path("/a/b"), path("/a/b2"));
+ //mgr.move(b.id(), "b", a.id(), "b2", a.id());
+ mgr.move(path("/a2/b"), path("/a2/b2"));
assertNotNull(mgr.info(b.id()));
- mgr.move(path("/a/f3"), path("/a/f3-2"));
+ //mgr.move(f3.id(), "f3", b.id(), "f3-2", a.id());
+ mgr.move(path("/a2/b2/f3"), path("/a2/b2/f3-2"));
assertNotNull(mgr.info(b.id()));
- mgr.move(path("/a/f3-2"), path("/b/f3"));
- mgr.move(path("/a/b2"), path("/a/b"));
- mgr.move(path("/a2"), path("/a"));
+ //mgr.move(f3.id(), "f3-2", a.id(), "f3", b.id());
+ mgr.move(path("/a2/b2/f3-2"), path("/a2/b2/f3"));
+
+ //mgr.move(b.id(), "b2", a.id(), "b", a.id());
+ mgr.move(path("/a2/b2"), path("/a2/b"));
+
+ //mgr.move(a.id(), "a2", ROOT_ID, "a", ROOT_ID);
+ mgr.move("/a2", "/a");
// Validate 'remove' operation.
for (int i = 0; i < 100; i++) {
@@ -444,23 +450,47 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsException);
}
- /**
- * Test expected failures for 'move file' operation.
- *
- * @param msg Failure message if expected exception was not thrown.
- */
- private void expectsRenameFail(final String src, final String dst, @Nullable String msg) {
- Throwable err = assertThrowsInherited(log, new Callable() {
- @Override
- public Object call() throws Exception {
- mgr.move(src, dst);
-
- return null;
- }
- }, IgniteCheckedException.class, msg);
-
- assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsException);
- }
+// /**
+// * Test expected failures for 'move file' operation.
+// *
+// * @param msg Failure message if expected exception was not thrown.
+// */
+// private void expectsRenameFail(final String src, final String dst, @Nullable String msg) {
+// Throwable err = assertThrowsInherited(log, new Callable() {
+// @Override
+// public Object call() throws Exception {
+// mgr.move(src, dst);
+//
+// return null;
+// }
+// }, IgniteCheckedException.class, msg);
+//
+// assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsException);
+// }
+
+// /**
+// * Test expected failures for 'move file' operation.
+// *
+// * @param fileId File ID to rename.
+// * @param srcFileName Original file name in the parent's listing.
+// * @param srcParentId Source parent directory ID.
+// * @param destFileName New file name in the parent's listing after renaming.
+// * @param destParentId Destination parent directory ID.
+// * @param msg Failure message if expected exception was not thrown.
+// */
+// private void expectsRenameFail(final IgniteUuid fileId, final String srcFileName, final IgniteUuid srcParentId,
+// final String destFileName, final IgniteUuid destParentId, @Nullable String msg) {
+// Throwable err = assertThrowsInherited(log, new Callable() {
+// @Override
+// public Object call() throws Exception {
+// mgr.move(fileId, srcFileName, srcParentId, destFileName, destParentId);
+//
+// return null;
+// }
+// }, IgniteCheckedException.class, msg);
+//
+// assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsException);
+// }
/**
* Test expected failures for 'remove file' operation.