@Test public void listFilesTest() throws InvalidPathException, FileDoesNotExistException, FileAlreadyExistException, BlockInfoException, TachyonException { HashSet<Integer> ids = new HashSet<Integer>(); for (int i = 0; i < 10; i ++) { String dir = "/i" + i; mMasterInfo.mkdir(dir); for (int j = 0; j < 10; j ++) { ids.add(mMasterInfo.createFile(dir + "/j" + j, 64)); } } HashSet<Integer> listedIds = new HashSet<Integer>(mMasterInfo.listFiles("/", true)); Assert.assertEquals(ids, listedIds); }
public List<Integer> listFiles(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException { List<Integer> ret = new ArrayList<Integer>(); synchronized (mRoot) { Inode inode = getInode(path); if (inode == null) { throw new FileDoesNotExistException(path); } if (inode.isFile()) { ret.add(inode.getId()); } else if (recursive) { Queue<Inode> queue = new LinkedList<Inode>(); queue.addAll(((InodeFolder) inode).getChildren()); while (!queue.isEmpty()) { Inode qinode = queue.poll(); if (qinode.isDirectory()) { queue.addAll(((InodeFolder) qinode).getChildren()); } else { ret.add(qinode.getId()); } } } } return ret; }
MasterInfo extends ImageWriter { public List<Integer> listFiles(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException { List<Integer> ret = new ArrayList<Integer>(); synchronized (mRoot) { Inode inode = getInode(path); if (inode == null) { throw new FileDoesNotExistException(path); } if (inode.isFile()) { ret.add(inode.getId()); } else if (recursive) { Queue<Inode> queue = new LinkedList<Inode>(); queue.addAll(((InodeFolder) inode).getChildren()); while (!queue.isEmpty()) { Inode qinode = queue.poll(); if (qinode.isDirectory()) { queue.addAll(((InodeFolder) qinode).getChildren()); } else { ret.add(qinode.getId()); } } } } return ret; } }
MasterInfo extends ImageWriter { public List<Integer> listFiles(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException { List<Integer> ret = new ArrayList<Integer>(); synchronized (mRoot) { Inode inode = getInode(path); if (inode == null) { throw new FileDoesNotExistException(path); } if (inode.isFile()) { ret.add(inode.getId()); } else if (recursive) { Queue<Inode> queue = new LinkedList<Inode>(); queue.addAll(((InodeFolder) inode).getChildren()); while (!queue.isEmpty()) { Inode qinode = queue.poll(); if (qinode.isDirectory()) { queue.addAll(((InodeFolder) qinode).getChildren()); } else { ret.add(qinode.getId()); } } } } return ret; } MasterInfo(InetSocketAddress address, Journal journal); }
MasterInfo extends ImageWriter { public List<Integer> listFiles(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException { List<Integer> ret = new ArrayList<Integer>(); synchronized (mRoot) { Inode inode = getInode(path); if (inode == null) { throw new FileDoesNotExistException(path); } if (inode.isFile()) { ret.add(inode.getId()); } else if (recursive) { Queue<Inode> queue = new LinkedList<Inode>(); queue.addAll(((InodeFolder) inode).getChildren()); while (!queue.isEmpty()) { Inode qinode = queue.poll(); if (qinode.isDirectory()) { queue.addAll(((InodeFolder) qinode).getChildren()); } else { ret.add(qinode.getId()); } } } } return ret; } MasterInfo(InetSocketAddress address, Journal journal); ClientRawTableInfo _getClientRawTableInfo(String path, Inode inode); boolean _rename(int fileId, String dstPath); boolean addCheckpoint(long workerId, int fileId, long length, String checkpointPath); int cacheBlock(long workerId, long workerUsedBytes, long blockId, long length); void completeFile(int fileId); int createDependency(List<String> parents, List<String> children, String commandPrefix,
      List<ByteBuffer> data, String comment, String framework, String frameworkVersion,
      DependencyType dependencyType); int createFile(boolean recursive, String path, boolean directory, long blockSizeByte); int createFile(String path, long blockSizeByte); long createNewBlock(int fileId); int createRawTable(String path, int columns, ByteBuffer metadata); boolean delete(int fileId, boolean recursive); boolean delete(String path, boolean recursive); long getBlockIdBasedOnOffset(int fileId, long offset); List<BlockInfo> getBlockList(String path); long getCapacityBytes(); ClientBlockInfo getClientBlockInfo(long blockId); ClientDependencyInfo getClientDependencyInfo(int dependencyId); ClientFileInfo getClientFileInfo(int fid); ClientFileInfo getClientFileInfo(String path); ClientRawTableInfo getClientRawTableInfo(int id); ClientRawTableInfo getClientRawTableInfo(String path); int getFileId(String path); List<ClientBlockInfo> getFileLocations(int fileId); List<ClientBlockInfo> getFileLocations(String path); List<ClientFileInfo> getFilesInfo(String path); List<String> getInMemoryFiles(); Journal getJournal(); InetSocketAddress getMasterAddress(); long getNewUserId(); int getNumberOfFiles(String path); String getPath(int fileId); List<Integer> getPinIdList(); List<Integer> getPriorityDependencyList(); int getRawTableId(String path); long getStarttimeMs(); long getUnderFsCapacityBytes(); long getUnderFsFreeBytes(); long getUnderFsUsedBytes(); long getUsedBytes(); List<String> getWhiteList(); NetAddress getWorker(boolean random, String host); int getWorkerCount(); List<ClientWorkerInfo> getWorkersInfo(); void init(); List<Integer> listFiles(String path, boolean recursive); void loadImage(JsonParser parser, String path); List<String> ls(String path, boolean recursive); boolean mkdir(String path); long registerWorker(NetAddress workerNetAddress, long totalBytes, long usedBytes,
      List<Long> currentBlockIds); boolean rename(int fileId, String dstPath); boolean rename(String srcPath, String dstPath); void reportLostFile(int fileId); void requestFilesInDependency(int depId); void stop(); void setPinned(int fileId, boolean pinned); void updateRawTableMetadata(int tableId, ByteBuffer metadata); Command workerHeartbeat(long workerId, long usedBytes, List<Long> removedBlockIds); @Override void writeImage(ObjectWriter objWriter, DataOutputStream dos); }
MasterInfo extends ImageWriter { public List<Integer> listFiles(String path, boolean recursive) throws InvalidPathException, FileDoesNotExistException { List<Integer> ret = new ArrayList<Integer>(); synchronized (mRoot) { Inode inode = getInode(path); if (inode == null) { throw new FileDoesNotExistException(path); } if (inode.isFile()) { ret.add(inode.getId()); } else if (recursive) { Queue<Inode> queue = new LinkedList<Inode>(); queue.addAll(((InodeFolder) inode).getChildren()); while (!queue.isEmpty()) { Inode qinode = queue.poll(); if (qinode.isDirectory()) { queue.addAll(((InodeFolder) qinode).getChildren()); } else { ret.add(qinode.getId()); } } } } return ret; } MasterInfo(InetSocketAddress address, Journal journal); ClientRawTableInfo _getClientRawTableInfo(String path, Inode inode); boolean _rename(int fileId, String dstPath); boolean addCheckpoint(long workerId, int fileId, long length, String checkpointPath); int cacheBlock(long workerId, long workerUsedBytes, long blockId, long length); void completeFile(int fileId); int createDependency(List<String> parents, List<String> children, String commandPrefix,
      List<ByteBuffer> data, String comment, String framework, String frameworkVersion,
      DependencyType dependencyType); int createFile(boolean recursive, String path, boolean directory, long blockSizeByte); int createFile(String path, long blockSizeByte); long createNewBlock(int fileId); int createRawTable(String path, int columns, ByteBuffer metadata); boolean delete(int fileId, boolean recursive); boolean delete(String path, boolean recursive); long getBlockIdBasedOnOffset(int fileId, long offset); List<BlockInfo> getBlockList(String path); long getCapacityBytes(); ClientBlockInfo getClientBlockInfo(long blockId); ClientDependencyInfo getClientDependencyInfo(int dependencyId); ClientFileInfo getClientFileInfo(int fid); ClientFileInfo getClientFileInfo(String path); ClientRawTableInfo getClientRawTableInfo(int id); ClientRawTableInfo getClientRawTableInfo(String path); int getFileId(String path); List<ClientBlockInfo> getFileLocations(int fileId); List<ClientBlockInfo> getFileLocations(String path); List<ClientFileInfo> getFilesInfo(String path); List<String> getInMemoryFiles(); Journal getJournal(); InetSocketAddress getMasterAddress(); long getNewUserId(); int getNumberOfFiles(String path); String getPath(int fileId); List<Integer> getPinIdList(); List<Integer> getPriorityDependencyList(); int getRawTableId(String path); long getStarttimeMs(); long getUnderFsCapacityBytes(); long getUnderFsFreeBytes(); long getUnderFsUsedBytes(); long getUsedBytes(); List<String> getWhiteList(); NetAddress getWorker(boolean random, String host); int getWorkerCount(); List<ClientWorkerInfo> getWorkersInfo(); void init(); List<Integer> listFiles(String path, boolean recursive); void loadImage(JsonParser parser, String path); List<String> ls(String path, boolean recursive); boolean mkdir(String path); long registerWorker(NetAddress workerNetAddress, long totalBytes, long usedBytes,
      List<Long> currentBlockIds); boolean rename(int fileId, String dstPath); boolean rename(String srcPath, String dstPath); void reportLostFile(int fileId); void requestFilesInDependency(int depId); void stop(); void setPinned(int fileId, boolean pinned); void updateRawTableMetadata(int tableId, ByteBuffer metadata); Command workerHeartbeat(long workerId, long usedBytes, List<Long> removedBlockIds); @Override void writeImage(ObjectWriter objWriter, DataOutputStream dos); static final String COL; }