/** {@inheritDoc} */ @Override public IgfsOutputStream append(IgfsPath path, boolean create) { return igfs.append(path, create); }
/** {@inheritDoc} */ @Override public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create, @Nullable Map<String, String> props) { return igfs.append(path, bufSize, create, props); }
/** {@inheritDoc} */ @Override public IgfsOutputStream append(IgfsPath path, boolean create) { return append(path, cfg.getBufferSize(), create, null); }
/** * Append some data to the given file. * * @param path File path. * @param len Data length. * @throws Exception If failed. */ private void append(IgfsPath path, int len) throws Exception { IgfsOutputStream os = igfsPrimary.append(path, false); os.write(new byte[len]); os.close(); }
@Override public Object call() throws Exception { IgfsOutputStream osErr = igfs(0).append(path, false); try { for (int i = 0; i < maxSize / writeChunkSize * GRID_CNT; ++i) osErr.write(chunk(writeChunkSize)); osErr.close(); return null; } catch (IOException e) { Throwable e0 = e; while (e0.getCause() != null) e0 = e0.getCause(); throw (Exception)e0; } finally { U.closeQuiet(osErr); } } }, IgniteOutOfMemoryException.class, "Not enough memory allocated");
@SuppressWarnings("ThrowFromFinallyBlock") @Override public void run() { while (!stop.get() && err.get() == null) { IgfsOutputStream os = null; try { os = igfs.append(FILE, false); os.write(chunk); os.close(); chunksCtr.incrementAndGet(); } catch (IgniteException ignore) { // No-op. } catch (IOException e) { err.compareAndSet(null, e); } finally { if (os != null) try { os.close(); } catch (IOException ioe) { throw new IgniteException(ioe); } } } } }, threadCnt);
@Override public Object call() throws Exception { IgfsPath FILE = new IgfsPath(new IgfsPath("/dir"), "file"); igfs.append(FILE, true); return null; } }, IgfsException.class, "Failed to execute operation because there are no IGFS metadata nodes.");
/** * Append to the file in the given IGFS provided data chunks. * * @param igfs IGFS. * @param file File. * @param chunks Data chunks. * @throws Exception If failed. */ protected static void appendFile(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks) throws Exception { IgfsOutputStream os = null; try { os = igfs.append(file, false); writeFileChunks(os, chunks); } finally { U.closeQuiet(os); awaitFileClose(igfs, file); } }
@Override public Void call() throws Exception { IgfsOutputStream ios = os; try { writeChunks0(igfs0, ios, f); } catch (IOException ioe) { log().warning("Attempt to append the data to existing stream failed: ", ioe); ios = igfs0.append(filePath(f), false); assert ios != null; writeChunks0(igfs0, ios, f); } return null; } });
@Override public void run() { int idx = ctr.getAndIncrement(); IgfsPath path = new IgfsPath("/file" + idx); try { byte[][] chunks = new byte[REPEAT_CNT][]; for (int i = 0; i < REPEAT_CNT; i++) { chunks[i] = chunk; IgfsOutputStream os = igfs.append(path, false); os.write(chunk); os.close(); assert igfs.exists(path); } awaitFileClose(igfs, path); checkFileContent(igfs, path, chunks); } catch (IOException | IgniteCheckedException e) { err.compareAndSet(null, e); // Log the very first error. } } }, threadCnt);
IgfsOutputStream os = igfs(0).append(path, false);
IgfsOutputStream out = igfsSecondary.append(FILE, false);
/** * 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); } } }
os = igfs.append(path2, true/*create*/); os = igfs.append(path2, false/*create*/); try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/should-not-be-created"), false)) { try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/k/l"), true)) { checkExist(igfs, igfsSecondary, new IgfsPath("/k/l")); assert igfs.info(new IgfsPath("/k/l")).isFile(); try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/k/l/m"), true)) { try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/k/l/m/n/o/p"), true)) { assert igfs.info(new IgfsPath("/x/y")).isDirectory(); try { try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y"), true)) { try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/f"), true)) { assert igfs.info(new IgfsPath("/x/y/f")).isFile(); try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/z/f"), true)) { assert igfs.info(new IgfsPath("/x/y/z/f")).isFile(); try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/z/t/f"), true)) { assert igfs.info(new IgfsPath("/x/y/z/t/f")).isFile(); try (IgfsOutputStream ignored = igfs.append(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f"), true)) { assert igfs.info(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f")).isFile();
os = igfs(0).append(path, false); os.write(chunk(1)); os.close();
os = igfs.append(file, 1024, false, null);
/** {@inheritDoc} */ @Override public IgfsOutputStream append(IgfsPath path, int bufSize, boolean create, @Nullable Map<String, String> props) { return igfs.append(path, bufSize, create, props); }