@Override public Object call() throws Exception { igfs.open(path(path)); return false; } }, IgniteException.class, msg);
/** * Open file for read and return input stream. * * @return Input stream. * @throws Exception In case of exception. */ protected IgfsInputStream read() throws Exception { return igfs.open(FILE); }
/** * Read content of the file. * * @param path File path to read. * @return Content of this file. * @throws IgniteCheckedException In case of error. */ private String read(String path) throws Exception { try (IgfsInputStream in = igfs.open(path(path))) { return IOUtils.toString(in, UTF_8); } }
/** * Dump IGFS content. * * @param igfs IGFS. * @param path Path. * @throws Exception If failed. */ private static void dumpIgfs(IgniteFileSystem igfs, IgfsPath path) throws Exception { IgfsFile file = igfs.info(path); assert file != null; System.out.println(file.path()); if (file.isDirectory()) { for (IgfsPath child : igfs.listPaths(path)) dumpIgfs(igfs, child); } else { try (BufferedReader br = new BufferedReader(new InputStreamReader(igfs.open(path)))) { String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } } } }
/** {@inheritDoc} */ @Override public void handleFile(String strPath) throws Exception { IgfsPath path = new IgfsPath(strPath); IgfsInputStream in; try { in = fs.open(path); } catch (IgfsPathNotFoundException ex) { System.out.println("file " + path.toString() + " not exist: " + ex); throw ex; } catch (IgniteException ex) { System.out.println("open file " + path.toString() + " failed: " + ex); throw ex; } try { for (int i = 0; i < size / dataBufer.capacity(); i++) in.read(dataBufer.array()); } catch (IOException ex) { System.out.println("read file " + path.toString() + " failed: " + ex); throw ex; } finally { in.close(); } }
/** {@inheritDoc} */ @Override public Object execute() { IgniteFileSystem fs = ignite.fileSystem(igfsName); try (IgfsInputStream in = fs.open(path)) { IgfsFileRange split = new IgfsFileRange(path, start, len); if (rslvr != null) { split = rslvr.resolveRecords(fs, in, split); if (split == null) { log.warning("No data found for split on local node after resolver is applied " + "[igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']'); return null; } } in.seek(split.start()); return job.execute(fs, new IgfsFileRange(path, split.start(), split.length()), in); } catch (IOException e) { throw new IgniteException("Failed to execute IGFS job for file split [igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']', e); } }
/** * @throws Exception If failed. */ @Test public void testReadFragmentizing() throws Exception { IgniteFileSystem igfs = grid(0).fileSystem("igfs"); IgfsPath path = new IgfsPath("/someFile"); try (IgfsOutputStream out = igfs.create(path, true)) { // Write 10 groups. for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) { byte[] data = new byte[IGFS_BLOCK_SIZE]; Arrays.fill(data, (byte)i); out.write(data); } } long start = System.currentTimeMillis(); do { try (IgfsInputStream in = igfs.open(path)) { for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) { for (int j = 0; j < IGFS_BLOCK_SIZE; j++) assertEquals(i & 0xFF, in.read()); } assertEquals(-1, in.read()); } } while (System.currentTimeMillis() - start < 7000); }
try (IgfsInputStream in = igfs.open(path)) { i = 0;
try (IgfsInputStream in = igfs.open(path)) { cnt = 0;
/** @throws Exception If failed. */ @Test public void testMultipleClose() throws Exception { IgniteFileSystem fs = igfsPrimary[0]; IgfsOutputStream out = fs.create(new IgfsPath("/primary/file"), false); out.close(); out.close(); IgfsInputStream in = fs.open(new IgfsPath("/primary/file")); in.close(); in.close(); IgfsMetrics m = fs.metrics(); assertEquals(0, m.filesOpenedForWrite()); assertEquals(0, m.filesOpenedForRead()); }
final IgfsInputStream actIn = fs.open(path, CFG_BLOCK_SIZE * READING_THREADS_CNT * 11 / 10);
try (IgfsInputStream in = igfs.open(path)) { long pos = 0;
try (IgfsInputStream in = fs2.open(path)) {
try (IgfsInputStream in0 = igfs.open(path("/A/a"))) {
/** {@inheritDoc} */ @Override public Object execute() { IgniteFileSystem fs = ignite.fileSystem(igfsName); try (IgfsInputStream in = fs.open(path)) { IgfsFileRange split = new IgfsFileRange(path, start, len); if (rslvr != null) { split = rslvr.resolveRecords(fs, in, split); if (split == null) { log.warning("No data found for split on local node after resolver is applied " + "[igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']'); return null; } } in.seek(split.start()); return job.execute(fs, new IgfsFileRange(path, split.start(), split.length()), in); } catch (IOException e) { throw new IgniteException("Failed to execute IGFS job for file split [igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']', e); } }