@Test public void scheduleAsyncPersist() throws Exception { DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster)); AlluxioURI path = new AlluxioURI("/test"); long blockId = 0; long workerId = 1; long fileId = 2; List<FileBlockInfo> blockInfoList = new ArrayList<>(); BlockLocation location = new BlockLocation().setWorkerId(workerId); blockInfoList.add(new FileBlockInfo().setBlockInfo( new BlockInfo().setBlockId(blockId).setLocations(Lists.newArrayList(location)))); when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList); when(mFileSystemMaster.getFileId(path)).thenReturn(fileId); when(mFileSystemMaster.getPath(fileId)).thenReturn(path); when(mFileSystemMaster.getFileInfo(fileId)) .thenReturn(new FileInfo().setLength(1).setCompleted(true)); handler.scheduleAsyncPersistence(path); List<PersistFile> persistFiles = handler.pollFilesToPersist(workerId); assertEquals(1, persistFiles.size()); assertEquals(Lists.newArrayList(blockId), persistFiles.get(0).getBlockIds()); }
/** * Tests persistence after deletion of files. */ @Test public void persistenceFileAfterDeletion() throws Exception { DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster)); AlluxioURI path = new AlluxioURI("/test"); long blockId = 0; long workerId = 1; long fileId = 2; List<FileBlockInfo> blockInfoList = new ArrayList<>(); BlockLocation location = new BlockLocation().setWorkerId(workerId); blockInfoList.add(new FileBlockInfo().setBlockInfo( new BlockInfo().setBlockId(blockId).setLocations(Lists.newArrayList(location)))); when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList); when(mFileSystemMaster.getFileId(path)).thenReturn(fileId); when(mFileSystemMaster.getPath(fileId)).thenReturn(path); when(mFileSystemMaster.getFileInfo(fileId)) .thenReturn(new FileInfo().setLength(1).setCompleted(true)); handler.scheduleAsyncPersistence(path); when(mFileSystemMaster.getFileInfo(fileId)) .thenThrow(new FileDoesNotExistException("no file")); List<PersistFile> persistFiles = handler.pollFilesToPersist(workerId); assertEquals(0, persistFiles.size()); } }
result.setInMemoryPercentage(inMemoryPercentage); result.setLastModificationTimeMs(lastModificationTimeMs); result.setLength(length); result.setMode(permission); result.setMountPoint(mountPoint);
/** * Tests the persistence of file with block on multiple workers. */ @Test public void persistenceFileWithBlocksOnMultipleWorkers() throws Exception { DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster)); AlluxioURI path = new AlluxioURI("/test"); List<FileBlockInfo> blockInfoList = new ArrayList<>(); BlockLocation location1 = new BlockLocation().setWorkerId(1); blockInfoList.add(new FileBlockInfo() .setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location1)))); BlockLocation location2 = new BlockLocation().setWorkerId(2); blockInfoList.add(new FileBlockInfo() .setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location2)))); long fileId = 2; when(mFileSystemMaster.getFileId(path)).thenReturn(fileId); when(mFileSystemMaster.getFileInfo(fileId)) .thenReturn(new FileInfo().setLength(1).setCompleted(true)); when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList); // no persist scheduled on any worker assertEquals(0, handler.pollFilesToPersist(1).size()); assertEquals(0, handler.pollFilesToPersist(2).size()); }
public void before() throws Exception { sConf = ConfigurationTestUtils.defaults(); mInfo = new FileInfo().setBlockSizeBytes(BLOCK_LENGTH).setLength(FILE_LENGTH);
FileInfo fileInfo = inode.generateClientFileInfo(uri.toString()); if (fileInfo.isFolder()) { fileInfo.setLength(inode.asDirectory().getChildCount());
ret.setName(getName()); ret.setPath(path); ret.setLength(getLength()); ret.setBlockSizeBytes(getBlockSizeBytes()); ret.setCreationTimeMs(getCreationTimeMs());
/** * Converts a proto type to a wire type. * * @param pInfo the proto representation of a file information * @return wire representation of the file information */ public static FileInfo fromProto(alluxio.grpc.FileInfo pInfo) { return new FileInfo().setFileId(pInfo.getFileId()).setName(pInfo.getName()) .setPath(pInfo.getPath()).setUfsPath(pInfo.getUfsPath()).setLength(pInfo.getLength()) .setBlockSizeBytes(pInfo.getBlockSizeBytes()).setCreationTimeMs(pInfo.getCreationTimeMs()) .setCompleted(pInfo.getCompleted()).setFolder(pInfo.getFolder()) .setPinned(pInfo.getPinned()).setCacheable(pInfo.getCacheable()) .setPersisted(pInfo.getPersisted()).setBlockIds(pInfo.getBlockIdsList()) .setLastModificationTimeMs(pInfo.getLastModificationTimeMs()).setTtl(pInfo.getTtl()) .setTtlAction(pInfo.getTtlAction()).setOwner(pInfo.getOwner()) .setGroup(pInfo.getGroup()).setMode(pInfo.getMode()) .setPersistenceState(pInfo.getPersistenceState()).setMountPoint(pInfo.getMountPoint()) .setFileBlockInfos(map(GrpcUtils::fromProto, pInfo.getFileBlockInfosList())) .setMountId(pInfo.getMountId()).setInAlluxioPercentage(pInfo.getInAlluxioPercentage()) .setInMemoryPercentage(pInfo.getInMemoryPercentage()) .setUfsFingerprint(pInfo.hasUfsFingerprint() ? pInfo.getUfsFingerprint() : Constants.INVALID_UFS_FINGERPRINT) .setAcl(pInfo.hasAcl() ? (fromProto(pInfo.getAcl())) : AccessControlList.EMPTY_ACL) .setDefaultAcl( pInfo.hasDefaultAcl() ? ((DefaultAccessControlList) fromProto(pInfo.getDefaultAcl())) : DefaultAccessControlList.EMPTY_DEFAULT_ACL) .setReplicationMax(pInfo.getReplicationMax()).setReplicationMin(pInfo.getReplicationMin()); }
ret.setName(getName()); ret.setPath(path); ret.setLength(mChildren.size()); ret.setBlockSizeBytes(0); ret.setCreationTimeMs(getCreationTimeMs());
@Override public FileInfo generateClientFileInfo(String path) { FileInfo ret = new FileInfo(); // note: in-Alluxio percentage is NOT calculated here, because it needs blocks info stored in // block master ret.setFileId(getId()); ret.setName(getName()); ret.setPath(path); ret.setLength(getLength()); ret.setBlockSizeBytes(getBlockSizeBytes()); ret.setCreationTimeMs(getCreationTimeMs()); ret.setCacheable(isCacheable()); ret.setFolder(isDirectory()); ret.setPinned(isPinned()); ret.setCompleted(isCompleted()); ret.setPersisted(isPersisted()); ret.setBlockIds(getBlockIds()); ret.setLastModificationTimeMs(getLastModificationTimeMs()); ret.setTtl(mTtl); ret.setTtlAction(mTtlAction); ret.setOwner(getOwner()); ret.setGroup(getGroup()); ret.setMode(getMode()); ret.setPersistenceState(getPersistenceState().toString()); ret.setMountPoint(false); ret.setUfsFingerprint(getUfsFingerprint()); return ret; }
.setPath(info.getPath()) .setUfsPath(info.getUfsPath()) .setLength(info.getLength()) .setBlockSizeBytes(info.getBlockSizeBytes()) .setCreationTimeMs(info.getCreationTimeMs())