/** * Remove <code> userId </code> from user pool. * * @param userId The user to be removed. * @return The space quote the removed user occupied in bytes. */ public synchronized long removeUser(long userId) { StringBuilder sb = new StringBuilder("Trying to cleanup user " + userId + " : "); UserInfo tUser = null; synchronized (USERS) { tUser = USERS.get(userId); USERS.remove(userId); } long returnedBytes = 0; if (tUser == null) { returnedBytes = 0; sb.append(" The user does not exist in the worker's current user pool."); } else { returnedBytes = tUser.getOwnBytes(); String folder = getUserTempFolder(userId); sb.append( " The user returns " + returnedBytes + " bytes. Remove the user's folder " + folder + " ;"); try { FileUtils.deleteDirectory(new File(folder)); } catch (IOException e) { CommonUtils.runtimeException(e); } folder = getUserUnderfsTempFolder(userId); sb.append(" Also remove users underfs folder " + folder); try { UnderFileSystem.get(CommonConf.get().UNDERFS_ADDRESS).delete(folder, true); } catch (IOException e) { LOG.error(e); } } LOG.info(sb.toString()); return returnedBytes; }
public static boolean mkdirs(String path) throws IOException { UnderFileSystem ufs = UnderFileSystem.get(path); return ufs.mkdirs(path, true); }