@Test public void testShortenPathName() throws Exception { Assert.assertEquals(RecoveryHelper.shortenPathName(new Path("/test"), 10), "_test"); Assert.assertEquals(RecoveryHelper.shortenPathName(new Path("/relatively/long/path"), 9), "_re...ath"); }
static String shortenPathName(Path path, int bytes) { String pathString = path.toUri().getPath(); String replaced = pathString.replace("/", "_"); if (replaced.length() <= bytes) { return replaced; } int bytesPerHalf = (bytes - 3) / 2; return replaced.substring(0, bytesPerHalf) + "..." + replaced.substring(replaced.length() - bytesPerHalf); }
RecoveryHelper { static String shortenPathName(Path path, int bytes) { String pathString = path.toUri().getPath(); String replaced = pathString.replace("/", "_"); if (replaced.length() <= bytes) { return replaced; } int bytesPerHalf = (bytes - 3) / 2; return replaced.substring(0, bytesPerHalf) + "..." + replaced.substring(replaced.length() - bytesPerHalf); } }
RecoveryHelper { static String shortenPathName(Path path, int bytes) { String pathString = path.toUri().getPath(); String replaced = pathString.replace("/", "_"); if (replaced.length() <= bytes) { return replaced; } int bytesPerHalf = (bytes - 3) / 2; return replaced.substring(0, bytesPerHalf) + "..." + replaced.substring(replaced.length() - bytesPerHalf); } RecoveryHelper(FileSystem fs, State state); }
RecoveryHelper { static String shortenPathName(Path path, int bytes) { String pathString = path.toUri().getPath(); String replaced = pathString.replace("/", "_"); if (replaced.length() <= bytes) { return replaced; } int bytesPerHalf = (bytes - 3) / 2; return replaced.substring(0, bytesPerHalf) + "..." + replaced.substring(replaced.length() - bytesPerHalf); } RecoveryHelper(FileSystem fs, State state); static Optional<Path> getPersistDir(State state); boolean persistFile(State state, CopyableFile file, Path path); Optional<FileStatus> findPersistedFile(State state, CopyEntity file, Predicate<FileStatus> filter); void purgeOldPersistedFile(); }
RecoveryHelper { static String shortenPathName(Path path, int bytes) { String pathString = path.toUri().getPath(); String replaced = pathString.replace("/", "_"); if (replaced.length() <= bytes) { return replaced; } int bytesPerHalf = (bytes - 3) / 2; return replaced.substring(0, bytesPerHalf) + "..." + replaced.substring(replaced.length() - bytesPerHalf); } RecoveryHelper(FileSystem fs, State state); static Optional<Path> getPersistDir(State state); boolean persistFile(State state, CopyableFile file, Path path); Optional<FileStatus> findPersistedFile(State state, CopyEntity file, Predicate<FileStatus> filter); void purgeOldPersistedFile(); static final String PERSIST_DIR_KEY; static final String PERSIST_RETENTION_KEY; static final int DEFAULT_PERSIST_RETENTION; }