Search in sources :

Example 41 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class JournalIntegrationTest method pin.

/**
   * Tests journalling of inodes being pinned.
   */
@Test
public void pin() throws Exception {
    SetAttributeOptions setPinned = SetAttributeOptions.defaults().setPinned(true);
    SetAttributeOptions setUnpinned = SetAttributeOptions.defaults().setPinned(false);
    AlluxioURI dirUri = new AlluxioURI("/myFolder");
    mFileSystem.createDirectory(dirUri);
    mFileSystem.setAttribute(dirUri, setPinned);
    AlluxioURI file0Path = new AlluxioURI("/myFolder/file0");
    CreateFileOptions op = CreateFileOptions.defaults().setBlockSizeBytes(64);
    mFileSystem.createFile(file0Path, op).close();
    mFileSystem.setAttribute(file0Path, setUnpinned);
    AlluxioURI file1Path = new AlluxioURI("/myFolder/file1");
    mFileSystem.createFile(file1Path, op).close();
    URIStatus directoryStatus = mFileSystem.getStatus(dirUri);
    URIStatus file0Status = mFileSystem.getStatus(file0Path);
    URIStatus file1Status = mFileSystem.getStatus(file1Path);
    mLocalAlluxioCluster.stopFS();
    pinTestUtil(directoryStatus, file0Status, file1Status);
    deleteFsMasterJournalLogs();
    pinTestUtil(directoryStatus, file0Status, file1Status);
}
Also used : SetAttributeOptions(alluxio.client.file.options.SetAttributeOptions) CreateFileOptions(alluxio.client.file.options.CreateFileOptions) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 42 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class MasterFaultToleranceIntegrationTest method createFiles.

@Test
public void createFiles() throws Exception {
    int clients = 10;
    CreateFileOptions option = CreateFileOptions.defaults().setBlockSizeBytes(1024).setWriteType(WriteType.THROUGH);
    for (int k = 0; k < clients; k++) {
        mFileSystem.createFile(new AlluxioURI(AlluxioURI.SEPARATOR + k), option).close();
    }
    List<String> files = FileSystemTestUtils.listFiles(mFileSystem, AlluxioURI.SEPARATOR);
    Assert.assertEquals(clients, files.size());
    Collections.sort(files);
    for (int k = 0; k < clients; k++) {
        Assert.assertEquals(AlluxioURI.SEPARATOR + k, files.get(k));
    }
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 43 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class CheckConsistencyIntegrationTest method largeTree.

/**
   * Tests the {@link FileSystemMaster#checkConsistency(AlluxioURI, CheckConsistencyOptions)} method
   * when some files are consistent in a larger inode tree.
   */
@Test
public void largeTree() throws Exception {
    CreateDirectoryOptions dirOptions = CreateDirectoryOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
    CreateFileOptions fileOptions = CreateFileOptions.defaults().setWriteType(WriteType.CACHE_THROUGH);
    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.get(ufsDirectory);
    ufs.deleteDirectory(ufsDirectory, DeleteOptions.defaults().setRecursive(true));
    List<AlluxioURI> expected = Lists.newArrayList(nestedDir, thirdLevelFile);
    List<AlluxioURI> result = mFileSystemMaster.checkConsistency(new AlluxioURI("/"), CheckConsistencyOptions.defaults());
    Collections.sort(expected);
    Collections.sort(result);
    Assert.assertEquals(expected, result);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 44 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class JournalIntegrationTest method setAcl.

@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_AUTHENTICATION_TYPE, "SIMPLE", PropertyKey.Name.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "true", PropertyKey.Name.SECURITY_GROUP_MAPPING_CLASS, FakeUserGroupsMapping.FULL_CLASS_NAME })
public void setAcl() throws Exception {
    AlluxioURI filePath = new AlluxioURI("/file");
    String user = "alluxio";
    Configuration.set(PropertyKey.SECURITY_LOGIN_USERNAME, user);
    CreateFileOptions op = CreateFileOptions.defaults().setBlockSizeBytes(64);
    mFileSystem.createFile(filePath, op).close();
    // TODO(chaomin): also setOwner and setGroup once there's a way to fake the owner/group in UFS.
    mFileSystem.setAttribute(filePath, SetAttributeOptions.defaults().setMode(new Mode((short) 0400)).setRecursive(false));
    URIStatus status = mFileSystem.getStatus(filePath);
    mLocalAlluxioCluster.stopFS();
    aclTestUtil(status, user);
    deleteFsMasterJournalLogs();
    aclTestUtil(status, user);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) Mode(alluxio.security.authorization.Mode) Matchers.anyString(org.mockito.Matchers.anyString) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 45 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.

the class JournalIntegrationTest method delete.

/**
   * Tests file and directory creation and deletion.
   */
@Test
public void delete() throws Exception {
    CreateDirectoryOptions recMkdir = CreateDirectoryOptions.defaults().setRecursive(true);
    DeleteOptions recDelete = DeleteOptions.defaults().setRecursive(true);
    for (int i = 0; i < 10; i++) {
        String dirPath = "/i" + i;
        mFileSystem.createDirectory(new AlluxioURI(dirPath), recMkdir);
        for (int j = 0; j < 10; j++) {
            CreateFileOptions option = CreateFileOptions.defaults().setBlockSizeBytes((i + j + 1) * 64);
            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 : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) DeleteOptions(alluxio.client.file.options.DeleteOptions) CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) Matchers.anyString(org.mockito.Matchers.anyString) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

CreateFileOptions (alluxio.client.file.options.CreateFileOptions)54 AlluxioURI (alluxio.AlluxioURI)48 Test (org.junit.Test)42 FileInStream (alluxio.client.file.FileInStream)22 FileOutStream (alluxio.client.file.FileOutStream)11 URIStatus (alluxio.client.file.URIStatus)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 CreateDirectoryOptions (alluxio.client.file.options.CreateDirectoryOptions)4 BeforeClass (org.junit.BeforeClass)3 Mode (alluxio.security.authorization.Mode)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 FileSystem (alluxio.client.file.FileSystem)1 DeleteOptions (alluxio.client.file.options.DeleteOptions)1 OpenFileOptions (alluxio.client.file.options.OpenFileOptions)1 SetAttributeOptions (alluxio.client.file.options.SetAttributeOptions)1 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)1 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)1 AccessControlException (alluxio.exception.AccessControlException)1