use of alluxio.exception.LineageDoesNotExistException in project alluxio by Alluxio.
the class RecomputePlanner method plan.
/**
* @return a {@link RecomputePlan} that identifies the lineages to recompute
*/
public RecomputePlan plan() {
List<Long> lostFiles = mFileSystemMaster.getLostFiles();
// lineage to recompute
Set<Lineage> toRecompute = new HashSet<>();
if (!lostFiles.isEmpty()) {
LOG.info("report lost files {}", lostFiles);
// report lost files
for (long lostFile : lostFiles) {
if (!mLineageStore.hasOutputFile(lostFile)) {
continue;
}
Lineage lineage;
try {
lineage = mLineageStore.getLineageOfOutputFile(lostFile);
} catch (LineageDoesNotExistException e) {
// should not happen
throw new IllegalStateException(e);
}
try {
if (!LineageStateUtils.isPersisted(lineage, mFileSystemMaster.getFileSystemMasterView())) {
toRecompute.add(lineage);
}
} catch (FileDoesNotExistException e) {
// should not happen
throw new IllegalStateException(e);
}
}
}
List<Lineage> toRecomputeAfterSort = mLineageStore.sortLineageTopologically(toRecompute);
return new RecomputePlan(toRecomputeAfterSort);
}
use of alluxio.exception.LineageDoesNotExistException in project alluxio by Alluxio.
the class LineageMaster method reinitializeFile.
/**
* Reinitializes the file when the file is lost or not completed.
*
* @param path the path to the file
* @param blockSizeBytes the block size
* @param ttl the TTL
* @param ttlAction action to perform on ttl expiry
* @return the id of the reinitialized file when the file is lost or not completed, -1 otherwise
* @throws InvalidPathException the file path is invalid
* @throws LineageDoesNotExistException when the file does not exist
* @throws AccessControlException if permission checking fails
* @throws FileDoesNotExistException if the path does not exist
*/
public synchronized long reinitializeFile(String path, long blockSizeBytes, long ttl, TtlAction ttlAction) throws InvalidPathException, LineageDoesNotExistException, AccessControlException, FileDoesNotExistException {
long fileId = mFileSystemMaster.getFileId(new AlluxioURI(path));
FileInfo fileInfo;
try {
fileInfo = mFileSystemMaster.getFileInfo(fileId);
if (!fileInfo.isCompleted() || mFileSystemMaster.getLostFiles().contains(fileId)) {
LOG.info("Recreate the file {} with block size of {} bytes", path, blockSizeBytes);
return mFileSystemMaster.reinitializeFile(new AlluxioURI(path), blockSizeBytes, ttl, ttlAction);
}
} catch (FileDoesNotExistException e) {
throw new LineageDoesNotExistException(ExceptionMessage.MISSING_REINITIALIZE_FILE.getMessage(path));
}
return -1;
}
use of alluxio.exception.LineageDoesNotExistException in project alluxio by Alluxio.
the class LineageFileSystemTest method getNonLineageStream.
/**
* Tests that a {@link FileOutStream} is returned.
*/
@Test
public void getNonLineageStream() throws Exception {
AlluxioURI path = new AlluxioURI("test");
Mockito.when(mLineageMasterClient.reinitializeFile("test", TEST_BLOCK_SIZE, 0, TtlAction.DELETE)).thenThrow(new LineageDoesNotExistException("lineage does not exist"));
CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(TEST_BLOCK_SIZE).setTtl(0);
FileOutStream outStream = mAlluxioLineageFileSystem.createFile(path, options);
Assert.assertTrue(outStream != null);
Assert.assertFalse(outStream instanceof LineageFileOutStream);
Assert.assertFalse(outStream instanceof DummyFileOutputStream);
// verify client is released
Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Aggregations