Search in sources :

Example 11 with CreateFilePOptions

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);
    }
}
Also used : HashMap(java.util.HashMap) Closeable(java.io.Closeable) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) URIStatus(alluxio.client.file.URIStatus) ConfigurationRule(alluxio.ConfigurationRule) AlluxioURI(alluxio.AlluxioURI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with CreateFilePOptions

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);
        }
    }
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 13 with CreateFilePOptions

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);
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) URIStatus(alluxio.client.file.URIStatus) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 14 with CreateFilePOptions

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);
        }
    }
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 15 with CreateFilePOptions

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);
        }
    }
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) BeforeClass(org.junit.BeforeClass)

Aggregations

CreateFilePOptions (alluxio.grpc.CreateFilePOptions)68 AlluxioURI (alluxio.AlluxioURI)61 Test (org.junit.Test)49 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)36 FileInStream (alluxio.client.file.FileInStream)27 FileOutStream (alluxio.client.file.FileOutStream)16 URIStatus (alluxio.client.file.URIStatus)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 FileSystem (alluxio.client.file.FileSystem)4 AlluxioException (alluxio.exception.AlluxioException)4 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)4 CreateDirectoryPOptions (alluxio.grpc.CreateDirectoryPOptions)4 IOException (java.io.IOException)4 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)3 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)3 ArrayList (java.util.ArrayList)3 ConfigurationRule (alluxio.ConfigurationRule)2 BlockMaster (alluxio.master.block.BlockMaster)2 Mode (alluxio.security.authorization.Mode)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2