/** * Parses the TRASH file name to extract the original path. * * @param name The TRASH short (entry) name. * @return The original path, or null in case of failure. */ public static IgfsPath extractOriginalPathFromTrash(String name) { int idx = name.indexOf(TRASH_NAME_SEPARATOR); assert idx >= 0; String path = name.substring(idx + 1, name.length()); return new IgfsPath(path); }
/** * Read non-null path from the input. * * @param in Input. * @return IGFS path. * @throws IOException If failed. */ public static IgfsPath readPath(ObjectInput in) throws IOException { IgfsPath res = new IgfsPath(); res.readExternal(in); return res; }
/** * Composes the path of the file. */ private IgfsPath filePath(int j) { return new IgfsPath(SUBDIR, "file" + j); }
/** * Utility method to make IgfsPath. * * @param p The String path. * @return The IgfsPath object. */ private static IgfsPath path(String p) { return new IgfsPath(p); }
/** * @param path Path. * @return IGFS path. */ private IgfsPath path(String path) { assert path != null; return new IgfsPath(path); }
/** {@inheritDoc} */ @Override public void handleFile(String strPath) throws Exception { IgfsPath path = new IgfsPath(strPath); fs.delete(path, false); }
/** {@inheritDoc} */ @Override public void postHandleDir(String strPath) throws Exception { IgfsPath path = new IgfsPath(strPath); IgfsFile info = fs.info(path); assert info != null : "Info must be not null for exists dir. All dirs must be exists for benchmark"; } }
/** {@inheritDoc} */ @Override public void handleFile(String strPath) throws Exception { IgfsPath path = new IgfsPath(strPath); IgfsFile info = fs.info(path); assert info != null : "Info must be not null for exists file. All files must be exists for benchmark"; }
@Override public Object call() throws Exception { IgfsAbstractSelfTest.create(igfs, new IgfsPath[]{new IgfsPath("/dir")}, null); return null; } }, IgfsException.class, "Failed to execute operation because there are no IGFS metadata nodes.");
/** {@inheritDoc} */ @Override public InputStream openInputStream(String path) throws IOException { IgfsPath igfsPath = new IgfsPath(path); return igfsEx.open(igfsPath); }
/** {@inheritDoc} */ @Override public boolean isProxy(URI path) { IgfsMode mode = F.isEmpty(cfg.getPathModes()) ? cfg.getDefaultMode() : modeRslvr.resolveMode(new IgfsPath(path)); return mode == PROXY; }
/** {@inheritDoc} */ @Override public OutputStream openOutputStream(String path, boolean append) throws IOException { IgfsPath igfsPath = new IgfsPath(path); final IgfsOutputStream igfsOutputStream; if (append) igfsOutputStream = igfsEx.append(igfsPath, true/*create*/); else igfsOutputStream = igfsEx.create(igfsPath, true/*overwrite*/); return igfsOutputStream; }
/** {@inheritDoc} */ @SuppressWarnings("ConstantConditions") @Override public Map<String, String> properties(String path) { return igfsEx.info(new IgfsPath(path)).properties(); }
/** {@inheritDoc} */ @Override public void preHandleDir(String strPath) throws Exception { IgfsPath path = new IgfsPath(strPath); if (!fs.exists(path)) { System.out.println("path " + path.toString() + " not exist"); throw new IgniteException("path " + path.toString() + " not exist"); } } }
/** * Test create when parent is the root. * * @throws Exception If failed. */ @Test public void testCreateParentRoot() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); createFile(igfs, file, true, chunk); checkFile(igfs, igfsSecondary, file, chunk); }
/** * Test directory move when destination is the root. * * @throws Exception If failed. */ @Test public void testMoveDirectoryDestinationRoot() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), null); igfs.rename(SUBSUBDIR, IgfsPath.ROOT); checkExist(igfs, igfsSecondary, new IgfsPath("/" + SUBSUBDIR.name())); checkNotExist(igfs, igfsSecondary, SUBSUBDIR); }