use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method ufsDirUpdatePermissions.
@Test
public void ufsDirUpdatePermissions() throws Exception {
new File(ufsPath("/dir1")).mkdirs();
new File(ufsPath("/dir1/dir2")).mkdirs();
String fileA = "/dir1/dir2/fileA";
writeUfsFile(ufsPath(fileA), 1);
// Set the mode for the directory
FileUtils.changeLocalFilePermission(ufsPath("/dir1"), "rwxrwxrwx");
GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath("/dir1")), options);
Assert.assertNotNull(status);
assertEquals(FileUtils.translatePosixPermissionToMode(PosixFilePermissions.fromString("rwxrwxrwx")), status.getMode());
// Change the mode for the directory
FileUtils.changeLocalFilePermission(ufsPath("/dir1"), "rwxr-xr-x");
status = mFileSystem.getStatus(new AlluxioURI(alluxioPath("/dir1")), options);
Assert.assertNotNull(status);
assertEquals(FileUtils.translatePosixPermissionToMode(PosixFilePermissions.fromString("rwxr-xr-x")), status.getMode());
}
use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class LoadMetadataCommandIntegrationTest method loadMetadataFileWithWildcard.
@Test
public void loadMetadataFileWithWildcard() throws IOException, AlluxioException {
String dirPath = "/testRoot/layer1/layer2/layer3/";
String filePathA = PathUtils.concatPath(dirPath, "testFileA");
String filePathB = PathUtils.concatPath(dirPath, "testFileB");
FileSystemTestUtils.createByteFile(sFileSystem, filePathA, WritePType.CACHE_THROUGH, 10);
FileSystemTestUtils.createByteFile(sFileSystem, filePathB, WritePType.THROUGH, 30);
AlluxioURI uriA = new AlluxioURI(filePathA);
AlluxioURI uriB = new AlluxioURI(filePathB);
URIStatus statusBeforeA = sFileSystem.getStatus(uriA);
URIStatus statusBeforeB = sFileSystem.getStatus(uriB);
// Delete testFileA's metadata and testFileB's metadata.
DeletePOptions deletePOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
sFileSystem.delete(uriA, deletePOptions);
sFileSystem.delete(uriB, deletePOptions);
// Load metadata from ufs.
sFsShell.run("loadMetadata", "/*/*/*/*/testFile*");
// Use LoadMetadataPType.NEVER to avoid loading metadata during get file status.
GetStatusPOptions getStatusPOptions = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).build();
// Check testFileA's metadata.
URIStatus statusAfterA = sFileSystem.getStatus(uriA, getStatusPOptions);
assertEquals(statusBeforeA.getFileInfo().getName(), statusAfterA.getFileInfo().getName());
assertEquals(statusBeforeA.getFileInfo().getLength(), statusAfterA.getFileInfo().getLength());
// Check testFileB's metadata.
URIStatus statusAfterB = sFileSystem.getStatus(uriB, getStatusPOptions);
assertEquals(statusBeforeB.getFileInfo().getName(), statusAfterB.getFileInfo().getName());
assertEquals(statusBeforeB.getFileInfo().getLength(), statusAfterB.getFileInfo().getLength());
}
use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class LoadMetadataCommandIntegrationTest method loadMetadataFileRecursive.
@Test
public void loadMetadataFileRecursive() throws IOException, AlluxioException {
String filePath = "/testRoot/layer1/layer2/layer3/testFile";
FileSystemTestUtils.createByteFile(sFileSystem, filePath, WritePType.CACHE_THROUGH, 10);
AlluxioURI uri = new AlluxioURI(filePath);
URIStatus statusBefore = sFileSystem.getStatus(uri);
DeletePOptions deletePOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
sFileSystem.delete(uri, deletePOptions);
// Load metadata at /testRoot layer with -R option.
sFsShell.run("loadMetadata", "-R", "/testRoot");
// Use LoadMetadataPType.NEVER to avoid loading metadata during get file status
GetStatusPOptions getStatusPOptions = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).build();
URIStatus statusAfter = sFileSystem.getStatus(uri, getStatusPOptions);
assertEquals(statusBefore.getFileInfo().getName(), statusAfter.getFileInfo().getName());
assertEquals(statusBefore.getFileInfo().getLength(), statusAfter.getFileInfo().getLength());
}
use of alluxio.grpc.GetStatusPOptions 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());
}
use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method getStatusFileSyncInterval.
@Test
public void getStatusFileSyncInterval() throws Exception {
GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_INTERVAL).build();
long startMs = System.currentTimeMillis();
URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
long startLength = status.getLength();
int sizeFactor = 10;
while (true) {
writeUfsFile(ufsPath(EXISTING_FILE), sizeFactor);
status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
if (status.getLength() != startLength) {
break;
}
sizeFactor++;
}
long endMs = System.currentTimeMillis();
assertTrue((endMs - startMs) >= INTERVAL_MS);
}
Aggregations