/** * Resolve mode for the given path. * * @param path Path. * @return Mode. */ private IgfsMode resolveMode(IgfsPath path) { return modeRslvr.resolveMode(path); }
IgfsModeResolver msg = new IgfsModeResolver(); msg.readExternal(in);
@Override public Collection<IgfsPath> call() throws Exception { if (log.isDebugEnabled()) log.debug("List directory: " + path); IgfsMode mode = resolveMode(path); Collection<IgfsPath> files = new HashSet<>(); if (mode != PRIMARY) { assert secondaryFs != null; try { Collection<IgfsPath> children = secondaryFs.listPaths(path); files.addAll(children); if (mode == PROXY || !modeRslvr.hasPrimaryChild(path)) return files; } catch (Exception e) { U.error(log, "List paths in DUAL mode failed [path=" + path + ']', e); throw e; } } IgfsEntryInfo info = primaryInfoForListing(path); if (info != null) { // Perform the listing. for (String child : info.listing().keySet()) files.add(new IgfsPath(path, child)); } else if (mode == PRIMARY) throw new IgfsPathNotFoundException("Failed to list paths (path not found): " + path); return files; } });
modeRslvr = new IgfsModeResolver(dfltMode, modes);
/** */ @Before public void setUp() throws Exception { reslvr = new IgfsModeResolver(DUAL_SYNC, new ArrayList<>(Arrays.asList(new T2<>( new IgfsPath("/a/b/c/d"), PROXY), new T2<>(new IgfsPath("/a/P/"), PRIMARY), new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)))); }
/** {@inheritDoc} */ @Override public IgfsMode mode(IgfsPath path) { A.notNull(path, "path"); return modeRslvr.resolveMode(path); }
IgfsModeResolver msg = new IgfsModeResolver(); msg.readExternal(in);
modeRslvr = new IgfsModeResolver(dfltMode, modes);
if (mode == PROXY || !modeRslvr.hasPrimaryChild(path)) return files;
/** {@inheritDoc} */ @Override public boolean isProxy(URI path) { IgfsMode mode = F.isEmpty(cfg.getPathModes()) ? cfg.getDefaultMode() : modeRslvr.resolveMode(new IgfsPath(path)); return mode == PROXY; }
@Override public Collection<IgfsPath> call() throws Exception { if (log.isDebugEnabled()) log.debug("List directory: " + path); IgfsMode mode = resolveMode(path); Collection<IgfsPath> files = new HashSet<>(); if (mode != PRIMARY) { assert secondaryFs != null; try { Collection<IgfsPath> children = secondaryFs.listPaths(path); files.addAll(children); if (mode == PROXY || !modeRslvr.hasPrimaryChild(path)) return files; } catch (Exception e) { U.error(log, "List paths in DUAL mode failed [path=" + path + ']', e); throw e; } } IgfsEntryInfo info = primaryInfoForListing(path); if (info != null) { // Perform the listing. for (String child : info.listing().keySet()) files.add(new IgfsPath(path, child)); } else if (mode == PRIMARY) throw new IgfsPathNotFoundException("Failed to list paths (path not found): " + path); return files; } });
/** * @throws Exception If failed. */ @Test public void testResolve() throws Exception { assertEquals(DUAL_SYNC, reslvr.resolveMode(IgfsPath.ROOT)); assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a"))); assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a/1"))); assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P"))); assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P/c"))); assertEquals(PRIMARY, reslvr.resolveMode(new IgfsPath("/a/P/c/2"))); assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/"))); assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/3"))); assertEquals(DUAL_ASYNC, reslvr.resolveMode(new IgfsPath("/a/b/3/4"))); assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d"))); assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d/5"))); assertEquals(PROXY, reslvr.resolveMode(new IgfsPath("/a/b/c/d/6"))); }
if (mode == PROXY || !modeRslvr.hasPrimaryChild(path)) return files;
/** * @throws Exception If failed. */ @Test public void testModeResolver() throws Exception { IgfsModeResolver mr = ((IgniteHadoopFileSystem)fs).getModeResolver(); assertEquals(mode, mr.resolveMode(IgfsPath.ROOT)); }
/** * Resolve IGFS mode for the given path and compare it with expected one. * * @param pathStr Path ot resolve. * @param expMode Expected mode. * @throws Exception If failed. */ private void checkMode(String pathStr, IgfsMode expMode) throws Exception { assert igfs != null; IgfsPath path = new IgfsPath(pathStr); IgfsModeResolver rslvr = igfs.modeResolver(); IgfsMode mode = rslvr.resolveMode(path); assertEquals(expMode, mode); }
log.debug("Rename file [src=" + src + ", dest=" + dest + ']'); IgfsMode mode = resolveMode(src); "upper level to self sub-dir) [src=" + src + ", dest=" + dest + ']'); if (evictExclude(src, mode == PRIMARY) != evictExclude(dest, modeRslvr.resolveMode(dest) == PRIMARY)) throw new IgfsInvalidPathException("Cannot move file to a path with different eviction " + "exclude setting (need to copy and remove)");
/** * Resolve mode for the given path. * * @param path Path. * @return Mode. */ private IgfsMode resolveMode(IgfsPath path) { return modeRslvr.resolveMode(path); }
/** {@inheritDoc} */ @Override public IgfsMode mode(IgfsPath path) { A.notNull(path, "path"); return modeRslvr.resolveMode(path); }
/** {@inheritDoc} */ @Override public boolean isProxy(URI path) { IgfsMode mode = F.isEmpty(cfg.getPathModes()) ? cfg.getDefaultMode() : modeRslvr.resolveMode(new IgfsPath(path)); return mode == PROXY; }
log.debug("Rename file [src=" + src + ", dest=" + dest + ']'); IgfsMode mode = resolveMode(src); "upper level to self sub-dir) [src=" + src + ", dest=" + dest + ']'); if (evictExclude(src, mode == PRIMARY) != evictExclude(dest, modeRslvr.resolveMode(dest) == PRIMARY)) throw new IgfsInvalidPathException("Cannot move file to a path with different eviction " + "exclude setting (need to copy and remove)");