/** {@inheritDoc} */ @Override public Collection<IgfsBlockLocation> affinity(IgfsPath path, long start, long len) { return affinity(path, start, len, 0L); }
/** {@inheritDoc} */ @Override public IgfsOutputStream append(IgfsPath path, boolean create) { return igfs.append(path, create); }
/** {@inheritDoc} */ @Override public IgfsContext context() { return igfs.context(); }
/** * Get summary for path. * * @param path Path. * @return Summary. * @throws IgniteCheckedException If failed. */ private IgfsPathSummary summary0(IgfsPath path) throws IgniteCheckedException { IgfsFile info = info(path); if (info == null) throw new IgfsPathNotFoundException("Failed to get path summary (path not found): " + path); IgfsPathSummary sum = new IgfsPathSummary(path); summaryRecursive(info, sum); return sum; }
/** * Create the given directories and files in the given IGFS. * * @param igfs IGFS. * @param dirs Directories. * @param files Files. * @throws Exception If failed. */ @SuppressWarnings("EmptyTryBlock") public static void create(IgfsImpl igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception { if (dirs != null) { for (IgfsPath dir : dirs) igfs.mkdirs(dir); } if (files != null) { for (IgfsPath file : files) { try (OutputStream ignored = igfs.create(file, true)) { // No-op. } igfs.await(file); } } }
/** * Check root property update. * * @throws Exception If failed. */ private void checkRootPropertyUpdate(String prop, String setVal, String expGetVal) throws Exception { igfs.update(IgfsPath.ROOT, Collections.singletonMap(prop, setVal)); igfs.clear(); IgfsFile file = igfs.info(IgfsPath.ROOT); assert file != null; Map<String,String> props = file.properties(); assertEquals(expGetVal, props.get(prop)); }
igfs.mkdirs(dir); IgfsOutputStream os = igfs.create(file, 1024, true, null, 0, 2048, null); os = igfs.append(file, 1024, false, null); IgfsInputStream is = igfs.open(file); assert igfsSecondary.exists(dir); assert igfsSecondary.exists(file); isSecondary = igfsSecondary.open(file); IgfsInputStream isSecondary = igfsSecondary.open(file); assert !igfsSecondary.exists(dir); assert !igfsSecondary.exists(file); igfs.delete(dir, true); assert !igfs.exists(dir); assert !igfs.exists(file); assert !igfsSecondary.exists(dir); assert !igfsSecondary.exists(file);
/** * @throws Exception If failed. */ @Test public void testAffinity() throws Exception { long fileSize = 32L * 1024 * 1024; IgfsPath filePath = new IgfsPath("/file"); try (OutputStream os = igfs.create(filePath, true)) { for(int i = 0; i < fileSize / chunk.length; ++i) os.write(chunk); } long len = igfs.info(filePath).length(); int start = 0; // Check default maxLen (maxLen = 0) for (int i = 0; i < igfs.context().data().groupBlockSize() / 1024; i++) { Collection<IgfsBlockLocation> blocks = igfs.affinity(filePath, start, len); assertEquals(F.first(blocks).start(), start); assertEquals(start + len, F.last(blocks).start() + F.last(blocks).length()); len -= 1024 * 2; start += 1024; } }
IgfsOutputStream out = igfsSecondary.append(FILE, false); IgfsMetaManager meta = igfs.context().meta(); IgniteCache<IgfsBlockKey, byte[]> dataCache = igfs.context().kernalContext().cache().jcache( igfs.configuration().getDataCacheConfiguration().getName()); igfsSecondary.delete(FILE, false);
@Override public Boolean call() throws Exception { U.awaitQuiet(barrier); try { return igfs.delete(SUBDIR, true); } catch (IgniteException ignored) { return false; } } });
/** * Test how evictions are handled for a file working in PRIMARY mode. * * @throws Exception If failed. */ @Test public void testFilePrimary() throws Exception { start(); // Create file in primary mode. It must not be propagated to eviction policy. igfsPrimary.create(FILE, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE).blockSize(); append(FILE, blockSize); checkEvictionPolicy(0, 0); read(FILE, 0, blockSize); checkEvictionPolicy(0, 0); }
/** {@inheritDoc} */ @Override public IgfsInputStream open(IgfsPath path, int bufSize, int seqReadsBeforePrefetch) { return igfs.open(path, bufSize, seqReadsBeforePrefetch); }
/** * Test update when parent is the root. * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testUpdateParentRoot() throws Exception { if(!propertiesSupported()) return; Map<String, String> props = properties("owner", "group", "0555"); create(igfs, paths(DIR), null); igfs.update(DIR, props); if (dual) assertEquals(props, igfsSecondary.properties(DIR.toString())); assertEquals(props, igfs.info(DIR).properties()); }
groupBlockSize(), props); return new IgfsOutputStreamProxyImpl(igfsCtx, path, info(path), bufferSize(bufSize), batch); fileProps, (short)replication, groupBlockSize(), bufSize); await(path); cfg.getBlockSize(), affKey, evictExclude(path, mode == PRIMARY), fileProps, secondaryCtx
/** * * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") @Test public void testListPathForSymlink() throws Exception { if (U.isWindows()) return; createSymlinks(); assertTrue(igfs.info(DIR).isDirectory()); Collection<IgfsPath> pathes = igfs.listPaths(DIR); Collection<IgfsFile> files = igfs.listFiles(DIR); assertEquals(1, pathes.size()); assertEquals(1, files.size()); assertEquals("filedest", F.first(pathes).name()); assertEquals("filedest", F.first(files).path().name()); }
/** * Test rename on the file when it was opened for write(create) and is not closed yet. * * @throws Exception If failed. */ @Test public void testCreateRenameNoClose() throws Exception { if (dual) return; create(igfs, paths(DIR, SUBDIR), null); IgfsOutputStream os = null; try { os = igfs.create(FILE, true); igfs.rename(FILE, FILE2); os.close(); } finally { U.closeQuiet(os); } }
/** * 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); } } }
long blockSize = igfs.configuration().getBlockSize(); IgfsDataManager data = igfs.context().data();
return new IgfsOutputStreamProxyImpl(igfsCtx, path, info(path), bufferSize(bufSize), batch); assert IgfsUtils.isDualMode(mode); await(path); cfg.getBlockSize(), evictExclude(path, true), fileProps );