Search in sources :

Example 21 with CreateFilePOptions

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

the class FileInStreamIntegrationTest method eofSeek.

/**
 * Tests {@link FileInStream#seek(long)} when at the end of a file at the block boundary.
 */
@Test
public void eofSeek() throws Exception {
    String uniqPath = PathUtils.uniqPath();
    int length = BLOCK_SIZE * 3;
    for (CreateFilePOptions op : getOptionSet()) {
        String filename = uniqPath + "/file_" + op.hashCode();
        AlluxioURI uri = new AlluxioURI(filename);
        FileSystemTestUtils.createByteFile(mFileSystem, filename, length, op);
        FileInStream is = mFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
        byte[] data = new byte[length];
        is.read(data, 0, length);
        Assert.assertTrue(BufferUtils.equalIncreasingByteArray(length, data));
        is.seek(0);
        is.read(data, 0, length);
        Assert.assertTrue(BufferUtils.equalIncreasingByteArray(length, data));
        is.close();
    }
}
Also used : FileInStream(alluxio.client.file.FileInStream) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 22 with CreateFilePOptions

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

the class UfsJournalIntegrationTest method manyFile.

/**
 * Tests files creation.
 */
@Test
public void manyFile() throws Exception {
    for (int i = 0; i < 10; i++) {
        CreateFilePOptions option = CreateFilePOptions.newBuilder().setBlockSizeBytes((i + 1) * 64).build();
        mFileSystem.createFile(new AlluxioURI("/a" + i), option).close();
    }
    mLocalAlluxioCluster.stopFS();
    manyFileTestUtil();
    deleteFsMasterJournalLogs();
    manyFileTestUtil();
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 23 with CreateFilePOptions

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

the class UfsJournalIntegrationTest method delete.

/**
 * Tests file and directory creation and deletion.
 */
@Test
public void delete() throws Exception {
    CreateDirectoryPOptions recMkdir = CreateDirectoryPOptions.newBuilder().setRecursive(true).build();
    DeletePOptions recDelete = DeletePOptions.newBuilder().setRecursive(true).build();
    for (int i = 0; i < 10; i++) {
        String dirPath = "/i" + i;
        mFileSystem.createDirectory(new AlluxioURI(dirPath), recMkdir);
        for (int j = 0; j < 10; j++) {
            CreateFilePOptions option = CreateFilePOptions.newBuilder().setBlockSizeBytes((i + j + 1) * 64).build();
            String filePath = dirPath + "/j" + j;
            mFileSystem.createFile(new AlluxioURI(filePath), option).close();
            if (j >= 5) {
                mFileSystem.delete(new AlluxioURI(filePath), recDelete);
            }
        }
        if (i >= 5) {
            mFileSystem.delete(new AlluxioURI(dirPath), recDelete);
        }
    }
    mLocalAlluxioCluster.stopFS();
    deleteTestUtil();
    deleteFsMasterJournalLogs();
    deleteTestUtil();
}
Also used : DeletePOptions(alluxio.grpc.DeletePOptions) CreateDirectoryPOptions(alluxio.grpc.CreateDirectoryPOptions) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 24 with CreateFilePOptions

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

the class UfsJournalIntegrationTest method multiEditLog.

/**
 * Tests reading multiple edit logs.
 */
@Test
public void multiEditLog() throws Exception {
    for (int i = 0; i < 124; i++) {
        CreateFilePOptions op = CreateFilePOptions.newBuilder().setBlockSizeBytes((i + 10) / 10 * 64).build();
        mFileSystem.createFile(new AlluxioURI("/a" + i), op).close();
    }
    mLocalAlluxioCluster.stopFS();
    multiEditLogTestUtil();
    deleteFsMasterJournalLogs();
    multiEditLogTestUtil();
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 25 with CreateFilePOptions

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

the class MasterFaultToleranceIntegrationTest method createFiles.

@Test
public void createFiles() throws Exception {
    int clients = 10;
    CreateFilePOptions option = CreateFilePOptions.newBuilder().setBlockSizeBytes(1024).setWriteType(WritePType.THROUGH).build();
    for (int k = 0; k < clients; k++) {
        mFileSystem.createFile(new AlluxioURI(AlluxioURI.SEPARATOR + k), option).close();
    }
    List<String> files = FileSystemTestUtils.listFiles(mFileSystem, AlluxioURI.SEPARATOR);
    assertEquals(clients, files.size());
    Collections.sort(files);
    for (int k = 0; k < clients; k++) {
        assertEquals(AlluxioURI.SEPARATOR + k, files.get(k));
    }
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

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