use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method writeMustCacheFile.
private void writeMustCacheFile(String path, int sizeFactor) throws Exception {
CreateFilePOptions options = CreateFilePOptions.newBuilder().setWriteType(WritePType.MUST_CACHE).setRecursive(true).build();
FileOutStream os = mFileSystem.createFile(new AlluxioURI(path), options);
for (int i = 0; i < sizeFactor; i++) {
os.write("test".getBytes());
}
os.close();
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method createFile.
@Test
public void createFile() throws IOException, AlluxioException {
CreateFilePOptions writeBoth = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).build();
AlluxioURI uri = new AlluxioURI(FILE_PATH + "_create");
try {
mFileSystem.createFile(uri, writeBoth).close();
Assert.fail("createFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
uri = new AlluxioURI(SUB_FILE_PATH + "_create");
try {
mFileSystem.createFile(uri, writeBoth).close();
Assert.fail("createFile should not succeed under a readonly mount.");
} catch (AccessControlException e) {
Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileSystemTestUtils method createByteFile.
/**
* Creates a simple file with {@code len} bytes.
*
* @param fs a {@link FileSystem} handler
* @param fileName the name of the file to be created
* @param writeType {@link WritePType} used to create the file
* @param len file size
* @param blockCapacityByte block size of the file
*/
public static void createByteFile(FileSystem fs, String fileName, WritePType writeType, int len, long blockCapacityByte) {
CreateFilePOptions options = CreateFilePOptions.newBuilder().setWriteType(writeType).setBlockSizeBytes(blockCapacityByte).setRecursive(true).build();
createByteFile(fs, new AlluxioURI(fileName), options, len);
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method createFile.
/**
* Tests the creation of a file via the
* {@link BaseFileSystem#createFile(AlluxioURI, CreateFilePOptions)} method.
*/
@Test
public void createFile() throws Exception {
URIStatus status = new URIStatus(new FileInfo());
AlluxioURI file = new AlluxioURI("/file");
when(mFileSystemMasterClient.createFile(any(AlluxioURI.class), any(CreateFilePOptions.class))).thenReturn(status);
mFileSystem.createFile(file, CreateFilePOptions.getDefaultInstance());
verify(mFileSystemMasterClient).createFile(file, FileSystemOptions.createFileDefaults(mConf).toBuilder().mergeFrom(CreateFilePOptions.getDefaultInstance()).build());
verifyFilesystemContextAcquiredAndReleased();
}
use of alluxio.grpc.CreateFilePOptions 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);
}
Aggregations