/** * Test create when parent is the root. * * @throws Exception If failed. */ @Test public void testCreateParentRoot() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); createFile(igfs, file, true, chunk); checkFile(igfs, igfsSecondary, file, chunk); }
createFile(igfs, new IgfsPath("/file" + i), false);
/** * 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 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 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); } }
/** * Test setTimes operation. * * @throws Exception If failed. */ @Test public void testSetTimes() throws Exception { createFile(igfs, FILE, true, chunk); checkExist(igfs, igfsSecondary, DIR); checkExist(igfs, igfsSecondary, SUBDIR); checkExist(igfs, igfsSecondary, FILE); checkSetTimes(SUBDIR); checkSetTimes(FILE); try { igfs.setTimes(FILE2, Long.MAX_VALUE, Long.MAX_VALUE); fail("Exception is not thrown for missing file."); } catch (Exception ignore) { // No-op. } }
/** * Test rename on the file parent when it was opened for write(append) and is not closed yet. * * @throws Exception If failed. */ @Test public void testAppendRenameParentNoClose() throws Exception { if (dual) return; if (appendSupported()) { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, false); IgfsOutputStream os = null; try { os = igfs.append(FILE, false); igfs.rename(SUBDIR, SUBDIR2); os.close(); } finally { U.closeQuiet(os); } } }
/** * Test rename on the file when it was opened for write(append) and is not closed yet. * * @throws Exception If failed. */ @Test public void testAppendRenameNoClose() throws Exception { if (dual) return; if (appendSupported()) { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, false); IgfsOutputStream os = null; try { os = igfs.append(FILE, false); igfs.rename(FILE, FILE2); os.close(); } finally { U.closeQuiet(os); } } }
/** * 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); } } }
final byte[] data = createChunk(fileSize, f); createFile(igfs0, filePath(f), true, -1/*block size unused*/, data);
create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, true, chunk);
createFile(igfs, FILE, true, BLOCK_SIZE, chunk);