use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class UfsFallbackFileOutStreamIntegrationTest method grpcWrite.
@Ignore("Files may be lost due to evicting and committing before file is complete.")
@Test
public void grpcWrite() throws Exception {
try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.USER_FILE_BUFFER_BYTES, mUserFileBufferSize);
put(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT, mBlockSize);
put(PropertyKey.USER_SHORT_CIRCUIT_ENABLED, false);
}
}, ServerConfiguration.global()).toResource()) {
AlluxioURI filePath = new AlluxioURI(PathUtils.uniqPath());
CreateFilePOptions op = CreateFilePOptions.newBuilder().setWriteType(WritePType.ASYNC_THROUGH).setRecursive(true).build();
writeIncreasingBytesToFile(filePath, mFileLength, op);
CommonUtils.sleepMs(1);
// check the file is completed but not persisted
URIStatus status = mFileSystem.getStatus(filePath);
Assert.assertEquals(PersistenceState.TO_BE_PERSISTED.toString(), status.getPersistenceState());
Assert.assertTrue(status.isCompleted());
IntegrationTestUtils.waitForPersist(mLocalAlluxioClusterResource, filePath);
status = mFileSystem.getStatus(filePath);
Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
checkFileInAlluxio(filePath, mFileLength);
checkFileInUnderStorage(filePath, mFileLength);
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileOutStreamIntegrationTest method writeByteArray.
/**
* Tests {@link FileOutStream#write(byte[])}.
*/
@Test
public void writeByteArray() throws Exception {
String uniqPath = PathUtils.uniqPath();
for (int len = MIN_LEN; len <= MAX_LEN; len += DELTA) {
CreateFilePOptions op = CreateFilePOptions.newBuilder().setWriteType(mWriteType.toProto()).setRecursive(true).build();
AlluxioURI filePath = new AlluxioURI(PathUtils.concatPath(uniqPath, "file_" + len + "_" + mWriteType));
writeIncreasingByteArrayToFile(filePath, len, op);
if (mWriteType.getAlluxioStorageType().isStore()) {
checkFileInAlluxio(filePath, len);
}
if (mWriteType.getUnderStorageType().isSyncPersist()) {
checkFileInUnderStorage(filePath, len);
}
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileOutStreamIntegrationTest method writeInNonExistDirectory.
/**
* Tests {@link FileOutStream#write(int)}.
*/
@Test
public void writeInNonExistDirectory() throws Exception {
String uniqPath = PathUtils.uniqPath();
CreateFilePOptions op = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).setRecursive(true).build();
AlluxioURI filePath = new AlluxioURI(PathUtils.concatPath(uniqPath, "file_" + MIN_LEN + "_" + mWriteType));
AlluxioURI parentPath = new AlluxioURI(uniqPath);
// create a directory without a backing directory in UFS
mFileSystem.createDirectory(parentPath, CreateDirectoryPOptions.newBuilder().setRecursive(true).setWriteType(WritePType.CACHE_THROUGH).build());
URIStatus status = mFileSystem.getStatus(parentPath);
String checkpointPath = status.getUfsPath();
UnderFileSystem ufs = UnderFileSystem.Factory.create(checkpointPath, ServerConfiguration.global());
ufs.deleteDirectory(checkpointPath);
// write a file to a directory exists in Alluxio but not in UFS
writeIncreasingBytesToFile(filePath, MIN_LEN, op);
checkFileInAlluxio(filePath, MIN_LEN);
checkFileInUnderStorage(filePath, MIN_LEN);
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileOutStreamIntegrationTest method writeBytes.
/**
* Tests {@link FileOutStream#write(int)}.
*/
@Test
public void writeBytes() throws Exception {
String uniqPath = PathUtils.uniqPath();
for (int len = MIN_LEN; len <= MAX_LEN; len += DELTA) {
CreateFilePOptions op = CreateFilePOptions.newBuilder().setWriteType(mWriteType.toProto()).setRecursive(true).build();
AlluxioURI filePath = new AlluxioURI(PathUtils.concatPath(uniqPath, "file_" + len + "_" + mWriteType));
writeIncreasingBytesToFile(filePath, len, op);
if (mWriteType.getAlluxioStorageType().isStore()) {
checkFileInAlluxio(filePath, len);
}
if (mWriteType.getUnderStorageType().isSyncPersist()) {
checkFileInUnderStorage(filePath, len);
}
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class BufferedBlockInStreamIntegrationTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
sFileSystem = sLocalAlluxioClusterResource.get().getClient();
// Create files of varying size and write type to later read from
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFilePOptions op : getOptionSet()) {
AlluxioURI path = new AlluxioURI(sTestPath + "/file_" + k + "_" + op.hashCode());
FileSystemTestUtils.createByteFile(sFileSystem, path, op, k);
}
}
}
Aggregations