Search in sources :

Example 11 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class CheckConsistencyIntegrationTest method largeTree.

/**
 * Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyContext)} method
 * when some files are consistent in a larger inode tree.
 */
@Test
public void largeTree() throws Exception {
    CreateDirectoryPOptions dirOptions = CreateDirectoryPOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
    CreateFilePOptions fileOptions = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
    AlluxioURI nestedDir = DIRECTORY.join("/dir2");
    AlluxioURI topLevelFile = new AlluxioURI("/file");
    AlluxioURI thirdLevelFile = nestedDir.join("/file");
    mFileSystem.createDirectory(nestedDir, dirOptions);
    mFileSystem.createFile(topLevelFile, fileOptions).close();
    mFileSystem.createFile(thirdLevelFile, fileOptions).close();
    String ufsDirectory = mFileSystem.getStatus(nestedDir).getUfsPath();
    UnderFileSystem ufs = UnderFileSystem.Factory.create(ufsDirectory, ServerConfiguration.global());
    ufs.deleteDirectory(ufsDirectory, DeleteOptions.defaults().setRecursive(true));
    List<AlluxioURI> expected = Lists.newArrayList(nestedDir, thirdLevelFile);
    List<AlluxioURI> result = mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyContext.defaults());
    Collections.sort(expected);
    Collections.sort(result);
    Assert.assertEquals(expected, result);
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 12 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class CheckConsistencyIntegrationTest method before.

@Before
public final void before() throws Exception {
    mFileSystemMaster = mLocalAlluxioClusterResource.get().getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
    mFileSystem = FileSystem.Factory.create(ServerConfiguration.global());
    CreateDirectoryPOptions dirOptions = CreateDirectoryPOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
    CreateFilePOptions fileOptions = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
    mFileSystem.createDirectory(DIRECTORY, dirOptions);
    mFileSystem.createFile(FILE, fileOptions).close();
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) FileSystemMaster(alluxio.master.file.FileSystemMaster) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) Before(org.junit.Before)

Example 13 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method persistDirectoryLater.

/**
 * Tests journalling of creating directories with MUST_CACHE, then creating the same directories
 * again with CACHE_THROUGH and AllowExists=true.
 */
@Test
public void persistDirectoryLater() throws Exception {
    String[] directories = new String[] { "/d11", "/d11/d21", "/d11/d22", "/d12", "/d12/d21", "/d12/d22" };
    CreateDirectoryPOptions options = CreateDirectoryPOptions.newBuilder().setRecursive(true).setWriteType(WritePType.MUST_CACHE).build();
    for (String directory : directories) {
        mFileSystem.createDirectory(new AlluxioURI(directory), options);
    }
    options = options.toBuilder().setWriteType(WritePType.CACHE_THROUGH).setAllowExists(true).build();
    for (String directory : directories) {
        mFileSystem.createDirectory(new AlluxioURI(directory), options);
    }
    Map<String, URIStatus> directoryStatuses = new HashMap<>();
    for (String directory : directories) {
        directoryStatuses.put(directory, mFileSystem.getStatus(new AlluxioURI(directory)));
    }
    mLocalAlluxioCluster.stopFS();
    persistDirectoryLaterTestUtil(directoryStatuses);
    deleteFsMasterJournalLogs();
    persistDirectoryLaterTestUtil(directoryStatuses);
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) HashMap(java.util.HashMap) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 14 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class BaseFileSystem method createDirectory.

@Override
public void createDirectory(AlluxioURI path, CreateDirectoryPOptions options) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException {
    checkUri(path);
    rpc(client -> {
        CreateDirectoryPOptions mergedOptions = FileSystemOptions.createDirectoryDefaults(mFsContext.getPathConf(path)).toBuilder().mergeFrom(options).build();
        client.createDirectory(path, mergedOptions);
        LOG.debug("Created directory {}, options: {}", path.getPath(), mergedOptions);
        return null;
    });
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions)

Example 15 with CreateDirectoryPOptions

use of alluxio.grpc.CreateDirectoryPOptions in project alluxio by Alluxio.

the class CreateDirectoryContext method mergeFrom.

// TODO(zac): Consider renaming mergeFrom to disambiguate between POptions mergeFrom since
// this method and the gRPC version have different functionality.
/**
 * Merges and embeds the given {@link CreateDirectoryPOptions} with the corresponding master
 * options.
 *
 * @param optionsBuilder Builder for proto {@link CreateDirectoryPOptions} to merge with defaults
 * @return the instance of {@link CreateDirectoryContext} with default values for master
 */
public static CreateDirectoryContext mergeFrom(CreateDirectoryPOptions.Builder optionsBuilder) {
    CreateDirectoryPOptions masterOptions = FileSystemOptions.createDirectoryDefaults(ServerConfiguration.global());
    CreateDirectoryPOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
    return create(mergedOptionsBuilder);
}
Also used : CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions)

Aggregations

CreateDirectoryPOptions (alluxio.grpc.CreateDirectoryPOptions)15 AlluxioURI (alluxio.AlluxioURI)12 Test (org.junit.Test)5 AlluxioException (alluxio.exception.AlluxioException)4 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)4 IOException (java.io.IOException)4 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)3 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)3 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)3 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)3 FileSystem (alluxio.client.file.FileSystem)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 FileInStream (alluxio.client.file.FileInStream)1 FileOutStream (alluxio.client.file.FileOutStream)1 URIStatus (alluxio.client.file.URIStatus)1 DeletePOptions (alluxio.grpc.DeletePOptions)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 GrpcCallTracker (alluxio.master.file.contexts.GrpcCallTracker)1