Search in sources :

Example 26 with UfsStatus

use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.

the class UfsJournalSnapshot method getNextLogSequenceNumberToCheckpoint.

/**
 * Gets the first journal log sequence number that is not yet checkpointed.
 *
 * @return the first journal log sequence number that is not yet checkpointed
 */
static long getNextLogSequenceNumberToCheckpoint(UfsJournal journal) throws IOException {
    List<UfsJournalFile> checkpoints = new ArrayList<>();
    UfsStatus[] statuses = journal.getUfs().listStatus(journal.getCheckpointDir().toString());
    if (statuses != null) {
        for (UfsStatus status : statuses) {
            UfsJournalFile file = UfsJournalFile.decodeCheckpointFile(journal, status.getName());
            if (file != null) {
                checkpoints.add(file);
            }
        }
        Collections.sort(checkpoints);
    }
    if (checkpoints.isEmpty()) {
        return 0;
    }
    return checkpoints.get(checkpoints.size() - 1).getEnd();
}
Also used : UfsStatus(alluxio.underfs.UfsStatus) ArrayList(java.util.ArrayList)

Example 27 with UfsStatus

use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.

the class UfsJournal method isFormatted.

/**
 * @return whether the journal has been formatted
 */
public boolean isFormatted() throws IOException {
    UfsStatus[] files = mUfs.listStatus(mLocation.toString());
    if (files == null) {
        return false;
    }
    // Search for the format file.
    String formatFilePrefix = ServerConfiguration.getString(PropertyKey.MASTER_FORMAT_FILE_PREFIX);
    for (UfsStatus file : files) {
        if (file.getName().startsWith(formatFilePrefix)) {
            return true;
        }
    }
    return false;
}
Also used : UfsStatus(alluxio.underfs.UfsStatus)

Example 28 with UfsStatus

use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.

the class UnderFileSystemCommonOperations method getDirectoryStatusTest.

/**
 * Test for getting directory status.
 */
@RelatedS3Operations(operations = { "putObject", "getObjectMetadata" })
public void getDirectoryStatusTest() throws IOException {
    String testDir = PathUtils.concatPath(mTopLevelTestDirectory, "testDir");
    mUfs.mkdirs(testDir);
    UfsStatus status = mUfs.getStatus(testDir);
    if (!(status instanceof UfsDirectoryStatus)) {
        throw new IOException("Failed to get ufs directory status");
    }
}
Also used : UfsStatus(alluxio.underfs.UfsStatus) IOException(java.io.IOException) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus)

Example 29 with UfsStatus

use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.

the class UnderFileSystemCommonOperations method createThenGetExistingDirectoryStatusTest.

/**
 * Test for getting existing directory status.
 */
@RelatedS3Operations(operations = { "putObject", "getObjectMetadata" })
public void createThenGetExistingDirectoryStatusTest() throws IOException {
    String testDir = PathUtils.concatPath(mTopLevelTestDirectory, "testDir");
    mUfs.mkdirs(testDir);
    UfsStatus status = mUfs.getExistingStatus(testDir);
    if (!(status instanceof UfsDirectoryStatus)) {
        throw new IOException("Failed to get ufs directory status");
    }
}
Also used : UfsStatus(alluxio.underfs.UfsStatus) IOException(java.io.IOException) UfsDirectoryStatus(alluxio.underfs.UfsDirectoryStatus)

Example 30 with UfsStatus

use of alluxio.underfs.UfsStatus in project alluxio by Alluxio.

the class UnderFileSystemCommonOperations method createThenGetExistingStatusTest.

/**
 * Test for getting existing status.
 */
@RelatedS3Operations(operations = {})
public void createThenGetExistingStatusTest() throws IOException {
    String testFile = PathUtils.concatPath(mTopLevelTestDirectory, "testFile");
    createTestBytesFile(testFile);
    UfsStatus status = mUfs.getExistingStatus(testFile);
    if (!(status instanceof UfsFileStatus)) {
        throw new IOException("Failed to get ufs file status");
    }
}
Also used : UfsFileStatus(alluxio.underfs.UfsFileStatus) UfsStatus(alluxio.underfs.UfsStatus) IOException(java.io.IOException)

Aggregations

UfsStatus (alluxio.underfs.UfsStatus)40 UnderFileSystem (alluxio.underfs.UnderFileSystem)12 IOException (java.io.IOException)12 Test (org.junit.Test)11 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)10 Path (org.apache.hadoop.fs.Path)9 AlluxioURI (alluxio.AlluxioURI)8 Inode (alluxio.master.file.meta.Inode)7 MountTable (alluxio.master.file.meta.MountTable)7 UfsFileStatus (alluxio.underfs.UfsFileStatus)6 UfsDirectoryStatus (alluxio.underfs.UfsDirectoryStatus)5 ArrayList (java.util.ArrayList)5 FileStatus (org.apache.hadoop.fs.FileStatus)5 BlockInfoException (alluxio.exception.BlockInfoException)4 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)4 FileNotFoundException (java.io.FileNotFoundException)4 Fingerprint (alluxio.underfs.Fingerprint)3 URI (java.net.URI)3 InvalidPathException (alluxio.exception.InvalidPathException)2 LoadMetadataContext (alluxio.master.file.contexts.LoadMetadataContext)2