Search in sources :

Example 1 with LineageDoesNotExistException

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);
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) Lineage(alluxio.master.lineage.meta.Lineage) LineageDoesNotExistException(alluxio.exception.LineageDoesNotExistException) HashSet(java.util.HashSet)

Example 2 with LineageDoesNotExistException

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;
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) FileInfo(alluxio.wire.FileInfo) LineageDoesNotExistException(alluxio.exception.LineageDoesNotExistException) AlluxioURI(alluxio.AlluxioURI)

Example 3 with LineageDoesNotExistException

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);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) LineageDoesNotExistException(alluxio.exception.LineageDoesNotExistException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

LineageDoesNotExistException (alluxio.exception.LineageDoesNotExistException)3 AlluxioURI (alluxio.AlluxioURI)2 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)2 FileOutStream (alluxio.client.file.FileOutStream)1 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)1 Lineage (alluxio.master.lineage.meta.Lineage)1 FileInfo (alluxio.wire.FileInfo)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1