@Override public String toString() { return mUri.toString(); } }
@Override public String toString() { return String.format("startSync %s", uri.toString()); } });
@Override public String toString() { return String.format("stopSync %s", uri.toString()); } });
/** * Escapes a URI, replacing "/" and "." with "_" so that when the URI is used in a metric name, * the "/" and "." won't be interpreted as path separators. * * @param uri the URI to escape * @return the string representing the escaped URI */ public static String escape(AlluxioURI uri) { return uri.toString().replace("/", "_").replace(".", "_"); }
/** * Append additional path elements to the end of an {@link AlluxioURI}. * * @param suffix the suffix to add * @return the new {@link AlluxioURI} */ public AlluxioURI join(AlluxioURI suffix) { return join(suffix.toString()); }
/** * Clean the path by creating a URI and turning it back to a string. * * @param path the path to validate * @return validated path */ protected static String validatePath(String path) { return new AlluxioURI(path).toString(); } }
/** * @return the normalized path stripped of the folder path component */ public String getRootPath() { String rootPath = this.toString(); if (this.getPath() != null) { rootPath = rootPath.substring(0, rootPath.lastIndexOf(this.getPath())); } return PathUtils.normalizePath(rootPath, AlluxioURI.SEPARATOR); }
private alluxio.wire.StartupConsistencyCheck getStartupConsistencyCheckInternal() { StartupConsistencyCheck check = mFileSystemMaster.getStartupConsistencyCheck(); alluxio.wire.StartupConsistencyCheck ret = new alluxio.wire.StartupConsistencyCheck(); List<AlluxioURI> inconsistentUris = check.getInconsistentUris(); List<String> uris = new ArrayList<>(inconsistentUris.size()); for (AlluxioURI uri : inconsistentUris) { uris.add(uri.toString()); } ret.setInconsistentUris(uris); ret.setStatus(check.getStatus().toString().toLowerCase()); return ret; }
@Override public void mount(final AlluxioURI alluxioPath, final AlluxioURI ufsPath, final MountPOptions options) throws AlluxioStatusException { retryRPC( () -> mClient.mount(MountPRequest.newBuilder().setAlluxioPath(alluxioPath.toString()) .setUfsPath(ufsPath.toString()).setOptions(options).build()), "Mount"); }
@Override public MountPointInfo getMountPointInfo(AlluxioURI path) throws InvalidPathException { if (!mMountTable.isMountPoint(path)) { throw new InvalidPathException( ExceptionMessage.PATH_MUST_BE_MOUNT_POINT.getMessage(path)); } return getMountPointInfo(mMountTable.getMountTable().get(path.toString())); }
/** * @return the proto options corresponding to these options */ public BackupPResponse toProto() { return BackupPResponse.newBuilder().setBackupUri(mBackupUri.toString()).setHostname(mHostname) .build(); }
/** * @param ufsInfo wire type * @return proto representation of given wire type */ public static alluxio.grpc.UfsInfo toProto(UfsInfo ufsInfo) { return alluxio.grpc.UfsInfo.newBuilder().setUri(ufsInfo.getUri().toString()) .setProperties(ufsInfo.getMountOptions()).build(); }
private void initFromBackup(AlluxioURI backup) throws IOException { UnderFileSystem ufs; if (URIUtils.isLocalFilesystem(backup.toString())) { ufs = UnderFileSystem.Factory.create("/", UnderFileSystemConfiguration.defaults(ServerConfiguration.global())); } else { ufs = UnderFileSystem.Factory.createForRoot(ServerConfiguration.global()); } try (UnderFileSystem closeUfs = ufs; InputStream ufsIn = ufs.open(backup.getPath())) { LOG.info("Initializing metadata from backup {}", backup); mBackupManager.initFromBackup(ufsIn); } }
/** * Tests the {@link AlluxioURI#toString()} method to work with Windows paths appropriately. */ @Test public void toStringWindowsTests() { assumeTrue(WINDOWS); String[] uris = new String[] { "c:/", "c:/foo/bar", "C:/foo/bar#boo", "C:/foo/ bar" }; for (String uri : uris) { AlluxioURI turi = new AlluxioURI(uri); assertEquals(uri, turi.toString()); } assertEquals("C:/", new AlluxioURI("C:\\\\").toString()); assertEquals("C:/a/b.txt", new AlluxioURI("C:\\\\a\\b.txt").toString()); }
@Override public void unmount(final AlluxioURI alluxioPath) throws AlluxioStatusException { retryRPC(() -> mClient .unmount(UnmountPRequest.newBuilder().setAlluxioPath(alluxioPath.toString()) .setOptions(UnmountPOptions.newBuilder().build()).build()), "Unmount"); }
/** * @return the {@link MountPointInfo} for the mount point */ public MountPointInfo toMountPointInfo() { MountPointInfo info = new MountPointInfo(); info.setUfsUri(mUfsUri.toString()); info.setReadOnly(mOptions.getReadOnly()); info.setProperties(mOptions.getProperties()); info.setShared(mOptions.getShared()); return info; }
/** * Tests the {@link AlluxioURI#AlluxioURI(String)} constructor to work with file URIs * appropriately. */ @Test public void fileUriTests() { AlluxioURI uri = new AlluxioURI("file:///foo/bar"); assertFalse(uri.hasAuthority()); assertEquals("/foo/bar", uri.getPath()); assertEquals("file:///foo/bar", uri.toString()); }
/** * Tests the {@link AlluxioURI#AlluxioURI(String)} constructor to work with Windows paths * appropriately. */ @Test public void windowsPathTests() { assumeTrue(WINDOWS); AlluxioURI uri = new AlluxioURI("C:\\foo\\bar"); assertFalse(uri.hasAuthority()); assertEquals("/C:/foo/bar", uri.getPath()); assertEquals("C:/foo/bar", uri.toString()); }
/** * Tests to resolve a child {@link AlluxioURI} against a parent {@link AlluxioURI}. * * @param target the target path * @param parent the parent path * @param child the child path */ private void testParentChild(String target, String parent, String child) { if (target.length() > 0) { assertEquals(new AlluxioURI(target), new AlluxioURI(new AlluxioURI(parent), new AlluxioURI(child))); } else { assertEquals(target, new AlluxioURI(new AlluxioURI(parent), new AlluxioURI(child)).toString()); } }