final CyclicBarrier barrier = new CyclicBarrier(2); create(igfs, paths(DIR, SUBDIR, DIR_NEW), paths()); IgniteInternalFuture<Boolean> res1 = execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { U.awaitQuiet(barrier); IgniteInternalFuture<Boolean> res2 = execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { U.awaitQuiet(barrier); checkExist(igfs, igfsSecondary, DIR, DIR_NEW); checkNotExist(igfs, igfsSecondary, SUBDIR, SUBDIR_NEW); checkExist(igfs, igfsSecondary, DIR, DIR_NEW, SUBDIR_NEW); checkNotExist(igfs, igfsSecondary, SUBDIR); clear(igfs, igfsSecondary);
/** * Ensure that IGFS is able to stop in case not closed output stream exist. * * @throws Exception If failed. */ @Test public void testStop() throws Exception { create(igfs, paths(DIR, SUBDIR), null); IgfsOutputStream os = igfs.create(FILE, true); os.write(chunk); igfs.stop(true); // Reset test state. afterTestsStopped(); beforeTestsStarted(); }
/** * Test create when parent is the root. * * @throws Exception If failed. */ @Test public void testAppendParentRoot() throws Exception { if (appendSupported()) { IgfsPath file = new IgfsPath("/" + FILE.name()); createFile(igfs, file, true, BLOCK_SIZE, chunk); appendFile(igfs, file, chunk); checkFile(igfs, igfsSecondary, file, chunk, chunk); } }
/** * Test regular file open. * * @throws Exception If failed. */ @Test public void testOpen() throws Exception { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, true, chunk); checkFileContent(igfs, FILE, chunk); // Read again when the whole file is in memory. checkFileContent(igfs, FILE, chunk); }
/** * Test existence check when the path exists both locally and remotely. * * @throws Exception If failed. */ @Test public void testExists() throws Exception { create(igfs, paths(DIR), null); checkExist(igfs, igfsSecondary, DIR); }
/** * Test rename in case both local and remote file systems have the same folder structure and the path being renamed * is a file. * * @throws Exception If failed. */ @Test public void testRenameFile() throws Exception { create(igfs, paths(DIR, SUBDIR), paths(FILE)); igfs.rename(FILE, FILE2); checkExist(igfs, igfsSecondary, FILE2); checkNotExist(igfs, igfsSecondary, FILE); }
@Test public void testAppend() throws Exception { if (appendSupported()) { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, true, BLOCK_SIZE, chunk); checkFile(igfs, igfsSecondary, FILE, chunk); appendFile(igfs, FILE, chunk); checkFile(igfs, igfsSecondary, FILE, chunk, chunk); writeFileChunks(os, chunk); } finally { U.closeQuiet(os); awaitFileClose(igfs, path2); writeFileChunks(os, chunk); } finally { U.closeQuiet(os); awaitFileClose(igfs, path2); checkFile(igfs, igfsSecondary, path2, chunk, chunk); fail("Exception expected"); } catch (IgniteException ignored) {
@Test public void testMkdirs() throws Exception { if (!propertiesSupported()) return; Map<String, String> props = properties(null, null, "0555"); // mkdirs command doesn't propagate user info. checkExist(igfs, igfsSecondary, new IgfsPath("/x")); checkExist(igfs, igfsSecondary, new IgfsPath("/k/l")); checkExist(igfs, igfsSecondary, new IgfsPath("/x/y")); checkExist(igfs, igfsSecondary, new IgfsPath("/a/b/c/d")); checkExist(igfs, igfsSecondary, new IgfsPath("/a/b/c/d/e")); create(igfs, null, new IgfsPath[] { new IgfsPath("/d/f") }); // "f" is a file. checkExist(igfs, igfsSecondary, new IgfsPath("/d/f")); assertTrue(igfs.info(new IgfsPath("/d/f")).isFile()); fail("IgfsParentNotDirectoryException expected."); fail("IgfsParentNotDirectoryException expected."); create(igfs, paths(DIR, SUBDIR), null); checkExist(igfs, igfsSecondary, SUBSUBDIR);
/** * Test update in case both local and remote file systems have the same folder structure. * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testUpdate() throws Exception { if(!propertiesSupported()) return; Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR, SUBDIR), paths(FILE)); igfs.update(FILE, props); if (dual) assertEquals(props, igfsSecondary.properties(FILE.toString())); assertEquals(props, igfs.info(FILE).properties()); }
/** * Test subsequent "append" commands on the same file without closing the output streams. * * @throws Exception If failed. */ @Test public void testAppendNoClose() throws Exception { if (mode != PRIMARY) return; if (appendSupported()) { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, false); GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() { @Override public Object call() throws Exception { IgfsOutputStream os1 = null; IgfsOutputStream os2 = null; try { os1 = igfs.append(FILE, false); os2 = igfs.append(FILE, false); } finally { U.closeQuiet(os1); U.closeQuiet(os2); } return null; } }, IgniteException.class, null); } }
final IgfsImpl igfs0 = nodeDatas[0].igfsImpl; clear(igfs0); IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null); final byte[] data = createChunk(fileSize, f); createFile(igfs0, filePath(f), true, -1/*block size unused*/, data); checkExist(igfs0, path); checkFileContent(igfs0, path, data); checkExist(nodeDatas[n].igfsImpl, path); checkFileContent(nodeDatas[n].igfsImpl, path, data); checkExist(igfs0, path); checkFileContent(igfs0, path, data);
final IgfsImpl igfs0 = nodeDatas[0].igfsImpl; clear(igfs0); IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null); writeFileChunks(os, data); checkExist(igfs0, path); checkFileContent(igfs0, path, data, data);
@Test public void testCreate() throws Exception { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, true, chunk); checkFile(igfs, igfsSecondary, FILE, chunk); checkExist(igfs, igfsSecondary, new IgfsPath("/r")); assert igfs.info(new IgfsPath("/r")).isFile(); checkExist(igfs, igfsSecondary, new IgfsPath("/k/l")); assert igfs.info(new IgfsPath("/k/l")).isFile(); fail("Exception expected"); } catch (IgniteException ignored) { checkExist(igfs, igfsSecondary, new IgfsPath("/k/l")); assert igfs.info(new IgfsPath("/k/l")).isFile(); fail("Exception expected"); } catch (IgniteException ignored) { checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m")); checkExist(igfs, igfsSecondary, new IgfsPath("/k/l")); assert igfs.info(new IgfsPath("/k/l")).isFile(); fail("Exception expected"); } catch (IgniteException ignored) {
/** * Test update on the file when it was opened for write(create) and is not closed yet. * * @throws Exception If failed. */ @Test public void testAppendUpdateNoClose() throws Exception { if (dual) return; if (appendSupported()) { Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, false); IgfsOutputStream os = null; try { os = igfs.append(FILE, false); if (permissionsSupported()) igfs.update(FILE, props); os.close(); } finally { U.closeQuiet(os); } } }
/** * Test delete in case both local and remote file systems have the same folder structure. * * @throws Exception If failed. */ @Test public void testDelete() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); igfs.delete(SUBDIR, true); checkNotExist(igfs, igfsSecondary, SUBDIR, SUBSUBDIR, FILE); }
/** * Ensure that delete will not be successful in non-empty directory when recursive flag is set to {@code false}. * * @throws Exception If failed. */ @Test public void testDeleteDirectoryNotEmpty() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); checkExist(igfs, igfsSecondary, SUBDIR, SUBSUBDIR, FILE); try { boolean ok = igfs.delete(SUBDIR, false); assertFalse(ok); } catch (IgfsDirectoryNotEmptyException ignore) { // No-op, expected. } checkExist(igfs, igfsSecondary, SUBDIR, SUBSUBDIR, FILE); }
final CyclicBarrier barrier = new CyclicBarrier(2); IgniteInternalFuture<Boolean> res1 = execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { U.awaitQuiet(barrier); IgniteInternalFuture<Boolean> res2 = execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { U.awaitQuiet(barrier); checkNotExist(igfs, igfsSecondary, DIR, SUBDIR, SUBSUBDIR); else checkExist(igfs, igfsSecondary, DIR, SUBDIR, SUBSUBDIR); clear(igfs, igfsSecondary);
if (appendSupported()) { final AtomicBoolean stop = new AtomicBoolean(); IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() { @SuppressWarnings("ThrowFromFinallyBlock") @Override awaitFileClose(igfs, FILE); checkFileContent(igfs, FILE, data);
/** * Test list files routine. * * @throws Exception If failed. */ @Test public void testListFiles() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); Collection<IgfsFile> paths = igfs.listFiles(SUBDIR); assert paths != null; assert paths.size() == 2; Iterator<IgfsFile> iter = paths.iterator(); IgfsFile path1 = iter.next(); IgfsFile path2 = iter.next(); assert (SUBSUBDIR.equals(path1.path()) && FILE.equals(path2.path())) || (FILE.equals(path1.path()) && SUBSUBDIR.equals(path2.path())); }
int primaryLvlCnt, int renCnt, int delCnt, int updateCnt, int mkdirsCnt, int createCnt) throws Exception { if (relaxedConsistency()) return; checkDeadlocks(lvlCnt, childrenDirPerLvl, childrenFilePerLvl, primaryLvlCnt, renCnt, delCnt, updateCnt, mkdirsCnt, createCnt); clear(igfs, igfsSecondary);