/** * Resolves GGFS mode for the given path. * * @param path GGFS path. * @return GGFS mode. */ public GridGgfsMode resolveMode(GridGgfsPath path) { assert path != null; if (modes == null) return dfltMode; else { GridGgfsMode mode = modesCache.get(path); if (mode == null) { for (T2<GridGgfsPath, GridGgfsMode> entry : modes) { if (startsWith(path, entry.getKey())) { // As modes ordered from most specific to least specific first mode found is ours. mode = entry.getValue(); break; } } if (mode == null) mode = dfltMode; modesCache.put(path, mode); } return mode; } }
/** * @param path Path. * @return Set of all modes that children paths could have. */ public Set<GridGgfsMode> resolveChildrenModes(GridGgfsPath path) { assert path != null; if (modes == null) return Collections.singleton(dfltMode); else { Set<GridGgfsMode> children = childrenModesCache.get(path); if (children == null) { children = new HashSet<>(GridGgfsMode.values().length, 1.0f); GridGgfsMode pathDefault = dfltMode; for (T2<GridGgfsPath, GridGgfsMode> child : modes) { if (startsWith(path, child.getKey())) { pathDefault = child.getValue(); break; } else if (startsWith(child.getKey(), path)) children.add(child.getValue()); } children.add(pathDefault); childrenModesCache.put(path, children); } return children; } }
/** * Resolves GGFS mode for the given path. * * @param path GGFS path. * @return GGFS mode. */ public GridGgfsMode resolveMode(GridGgfsPath path) { assert path != null; if (modes == null) return dfltMode; else { GridGgfsMode mode = modesCache.get(path); if (mode == null) { for (T2<GridGgfsPath, GridGgfsMode> entry : modes) { if (startsWith(path, entry.getKey())) { // As modes ordered from most specific to least specific first mode found is ours. mode = entry.getValue(); break; } } if (mode == null) mode = dfltMode; modesCache.put(path, mode); } return mode; } }
/** * @param path Path. * @return Set of all modes that children paths could have. */ public Set<GridGgfsMode> resolveChildrenModes(GridGgfsPath path) { assert path != null; if (modes == null) return Collections.singleton(dfltMode); else { Set<GridGgfsMode> children = childrenModesCache.get(path); if (children == null) { children = new HashSet<>(GridGgfsMode.values().length, 1.0f); GridGgfsMode pathDefault = dfltMode; for (T2<GridGgfsPath, GridGgfsMode> child : modes) { if (startsWith(path, child.getKey())) { pathDefault = child.getValue(); break; } else if (startsWith(child.getKey(), path)) children.add(child.getValue()); } children.add(pathDefault); childrenModesCache.put(path, children); } return children; } }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeStringMap(out, props); U.writeEnum0(out, dfltMode); if (pathModes != null) { out.writeBoolean(true); out.writeInt(pathModes.size()); for (T2<GridGgfsPath, GridGgfsMode> pathMode : pathModes) { pathMode.getKey().writeExternal(out); U.writeEnum0(out, pathMode.getValue()); } } else out.writeBoolean(false); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeStringMap(out, props); U.writeEnum0(out, dfltMode); if (pathModes != null) { out.writeBoolean(true); out.writeInt(pathModes.size()); for (T2<GridGgfsPath, GridGgfsMode> pathMode : pathModes) { pathMode.getKey().writeExternal(out); U.writeEnum0(out, pathMode.getValue()); } } else out.writeBoolean(false); }