Search in sources :

Example 6 with SetAttributePOptions

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

the class AlluxioJniFuseFileSystemTest method chown.

@Test
public void chown() throws Exception {
    long uid = AlluxioFuseUtils.getUid(System.getProperty("user.name"));
    long gid = AlluxioFuseUtils.getGid(System.getProperty("user.name"));
    mFuseFs.chown("/foo/bar", uid, gid);
    String userName = System.getProperty("user.name");
    String groupName = AlluxioFuseUtils.getGroupName(gid);
    AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar");
    SetAttributePOptions options = SetAttributePOptions.newBuilder().setGroup(groupName).setOwner(userName).build();
    verify(mFileSystem).setAttribute(expectedPath, options);
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with SetAttributePOptions

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

the class FileSystemCommandUtils method setPinned.

/**
 * Sets pin state for the input path.
 *
 * @param fs The {@link FileSystem} client
 * @param path The {@link AlluxioURI} path as the input of the command
 * @param pinned the state to be set
 * @param mediumTypes a list of medium types to pin to
 */
public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned, List<String> mediumTypes) throws AlluxioException, IOException {
    SetAttributePOptions options = SetAttributePOptions.newBuilder().setPinned(pinned).addAllPinnedMedia(mediumTypes).build();
    fs.setAttribute(path, options);
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions)

Example 8 with SetAttributePOptions

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

the class UfsJournalIntegrationTest method pin.

/**
 * Tests journalling of inodes being pinned.
 */
@Test
public void pin() throws Exception {
    SetAttributePOptions setPinned = SetAttributePOptions.newBuilder().setPinned(true).build();
    SetAttributePOptions setUnpinned = SetAttributePOptions.newBuilder().setPinned(false).build();
    AlluxioURI dirUri = new AlluxioURI("/myFolder");
    mFileSystem.createDirectory(dirUri);
    mFileSystem.setAttribute(dirUri, setPinned);
    AlluxioURI file0Path = new AlluxioURI("/myFolder/file0");
    CreateFilePOptions op = CreateFilePOptions.newBuilder().setBlockSizeBytes(64).build();
    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 : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 9 with SetAttributePOptions

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

the class PinIntegrationTest method pinDiscoverNewFiles.

/**
 * Make sure Pinning and Unpinning would recursively sync the directory if ufs sync is on.
 */
@Test
public void pinDiscoverNewFiles() throws Exception {
    String deeplyNestedDir = "/tmp/tmp2/tmp3";
    // Create a dir
    new File(ufsPath(deeplyNestedDir)).mkdirs();
    // Write a file in UFS
    FileWriter fileWriter = new FileWriter(ufsPath(PathUtils.concatPath(deeplyNestedDir, "/newfile")));
    fileWriter.write("test");
    fileWriter.close();
    SetAttributePOptions attributeOption = SetAttributePOptions.newBuilder().setPinned(true).setCommonOptions(SYNC_ALWAYS).build();
    GetStatusPOptions getStatusOption = GetStatusPOptions.newBuilder().setCommonOptions(SYNC_NEVER).build();
    // Pin the dir
    mFileSystem.setAttribute(new AlluxioURI("/mnt/tmp/"), attributeOption);
    ServerConfiguration.set(PropertyKey.USER_FILE_METADATA_LOAD_TYPE, LoadMetadataType.NEVER.toString());
    URIStatus dirStat = mFileSystem.getStatus(new AlluxioURI("/mnt/tmp/"), getStatusOption);
    URIStatus fileStat = mFileSystem.getStatus(new AlluxioURI(PathUtils.concatPath("/mnt", deeplyNestedDir, "newfile")), getStatusOption);
    Assert.assertTrue(dirStat.isPinned());
    Assert.assertTrue(fileStat.isPinned());
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) FileWriter(java.io.FileWriter) URIStatus(alluxio.client.file.URIStatus) File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 10 with SetAttributePOptions

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

the class S3ClientRestApiTest method listAllMyBuckets.

@Test
public void listAllMyBuckets() throws Exception {
    Mode mode = ModeParser.parse("777");
    SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(mode.toProto()).setRecursive(true).build();
    mFileSystem.setAttribute(new AlluxioURI("/"), options);
    Subject subject = new Subject();
    subject.getPrincipals().add(new User("user0"));
    AlluxioURI bucketPath = new AlluxioURI("/bucket0");
    FileSystem fs1 = sResource.get().getClient(FileSystemContext.create(subject, ServerConfiguration.global()));
    fs1.createDirectory(bucketPath);
    SetAttributePOptions setAttributeOptions = SetAttributePOptions.newBuilder().setOwner("user0").build();
    mFileSystem.setAttribute(new AlluxioURI("/bucket0"), setAttributeOptions);
    URIStatus bucket0Status = fs1.getStatus(bucketPath);
    subject = new Subject();
    subject.getPrincipals().add(new User("user1"));
    AlluxioURI bucket1Path = new AlluxioURI("/bucket1");
    FileSystem fs2 = sResource.get().getClient(FileSystemContext.create(subject, ServerConfiguration.global()));
    fs2.createDirectory(bucket1Path);
    setAttributeOptions = SetAttributePOptions.newBuilder().setOwner("user1").build();
    mFileSystem.setAttribute(new AlluxioURI("/bucket1"), setAttributeOptions);
    URIStatus bucket1Status = fs2.getStatus(bucket1Path);
    ListAllMyBucketsResult expected = new ListAllMyBucketsResult(Collections.emptyList());
    final TestCaseOptions requestOptions = TestCaseOptions.defaults().setContentType(TestCaseOptions.XML_CONTENT_TYPE);
    new TestCase(mHostname, mPort, S3_SERVICE_PREFIX + "/", NO_PARAMS, HttpMethod.GET, expected, requestOptions).run();
    expected = new ListAllMyBucketsResult(Lists.newArrayList(bucket0Status));
    requestOptions.setAuthorization("AWS4-HMAC-SHA256 Credential=user0/20210631");
    new TestCase(mHostname, mPort, S3_SERVICE_PREFIX + "/", NO_PARAMS, HttpMethod.GET, expected, requestOptions).run();
    expected = new ListAllMyBucketsResult(Lists.newArrayList(bucket1Status));
    requestOptions.setAuthorization("AWS4-HMAC-SHA256 Credential=user1/20210631");
    new TestCase(mHostname, mPort, S3_SERVICE_PREFIX + "/", NO_PARAMS, HttpMethod.GET, expected, requestOptions).run();
}
Also used : User(alluxio.security.User) SetAttributePOptions(alluxio.grpc.SetAttributePOptions) Mode(alluxio.security.authorization.Mode) FileSystem(alluxio.client.file.FileSystem) URIStatus(alluxio.client.file.URIStatus) ListAllMyBucketsResult(alluxio.proxy.s3.ListAllMyBucketsResult) Subject(javax.security.auth.Subject) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

SetAttributePOptions (alluxio.grpc.SetAttributePOptions)31 AlluxioURI (alluxio.AlluxioURI)20 Test (org.junit.Test)17 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 Mode (alluxio.security.authorization.Mode)6 URIStatus (alluxio.client.file.URIStatus)3 ConfigurationRule (alluxio.ConfigurationRule)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 Closeable (java.io.Closeable)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 InvalidPathException (java.nio.file.InvalidPathException)2 FuseContext (ru.serce.jnrfuse.struct.FuseContext)2 FileOutStream (alluxio.client.file.FileOutStream)1 FileSystem (alluxio.client.file.FileSystem)1 AlluxioException (alluxio.exception.AlluxioException)1 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)1 GetStatusPOptions (alluxio.grpc.GetStatusPOptions)1 FuseContext (alluxio.jnifuse.struct.FuseContext)1 JobIntegrationTest (alluxio.job.JobIntegrationTest)1 ListAllMyBucketsResult (alluxio.proxy.s3.ListAllMyBucketsResult)1