use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class ConcurrentFileSystemMasterTest method sameDstConcurrentRename.
/**
* Tests renaming files concurrently to the same destination will only succeed once.
*/
@Test
public void sameDstConcurrentRename() throws Exception {
int numThreads = CONCURRENCY_FACTOR;
final AlluxioURI[] srcs = new AlluxioURI[numThreads];
final AlluxioURI[] dsts = new AlluxioURI[numThreads];
for (int i = 0; i < numThreads; i++) {
srcs[i] = new AlluxioURI("/file" + i);
mFileSystem.createFile(srcs[i], sCreatePersistedFileOptions).close();
dsts[i] = new AlluxioURI("/renamed");
}
int errors = concurrentRename(srcs, dsts);
// We should get an error for all but 1 rename.
Assert.assertEquals(numThreads - 1, errors);
List<URIStatus> files = mFileSystem.listStatus(new AlluxioURI("/"));
// Store file names in a set to ensure the names are all unique.
Set<String> renamedFiles = new HashSet<>();
Set<String> originalFiles = new HashSet<>();
for (URIStatus file : files) {
if (file.getName().startsWith("renamed")) {
renamedFiles.add(file.getName());
}
if (file.getName().startsWith("file")) {
originalFiles.add(file.getName());
}
}
// One renamed file should exist, and numThreads - 1 original source files
Assert.assertEquals(numThreads, files.size());
Assert.assertEquals(1, renamedFiles.size());
Assert.assertEquals(numThreads - 1, originalFiles.size());
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class ConcurrentFileSystemMasterTest method folderConcurrentRename.
/**
* Tests concurrent renames within a folder do not block on each other.
*/
@Test
public void folderConcurrentRename() throws Exception {
final int numThreads = CONCURRENCY_FACTOR;
AlluxioURI[] srcs = new AlluxioURI[numThreads];
AlluxioURI[] dsts = new AlluxioURI[numThreads];
AlluxioURI dir = new AlluxioURI("/dir");
mFileSystem.createDirectory(dir);
for (int i = 0; i < numThreads; i++) {
srcs[i] = dir.join("/file" + i);
mFileSystem.createFile(srcs[i], sCreatePersistedFileOptions).close();
dsts[i] = dir.join("/renamed" + i);
}
int errors = concurrentRename(srcs, dsts);
Assert.assertEquals("More than 0 errors: " + errors, 0, errors);
List<URIStatus> files = mFileSystem.listStatus(new AlluxioURI("/dir"));
Collections.sort(files, new IntegerSuffixedPathComparator());
for (int i = 0; i < numThreads; i++) {
Assert.assertEquals(dsts[i].getName(), files.get(i).getName());
}
Assert.assertEquals(numThreads, files.size());
}
use of alluxio.client.file.URIStatus 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);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method aclTestUtil.
private void aclTestUtil(URIStatus status, String user) throws Exception {
FileSystemMaster fsMaster = createFsMasterFromJournal();
AuthenticatedClientUser.set(user);
FileInfo info = fsMaster.getFileInfo(new AlluxioURI("/file"));
Assert.assertEquals(status, new URIStatus(info));
fsMaster.stop();
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method directory.
/**
* Tests directory creation.
*/
@Test
public void directory() throws Exception {
AlluxioURI directoryPath = new AlluxioURI("/xyz");
mFileSystem.createDirectory(directoryPath);
URIStatus status = mFileSystem.getStatus(directoryPath);
mLocalAlluxioCluster.stopFS();
directoryTestUtil(status);
deleteFsMasterJournalLogs();
directoryTestUtil(status);
}
Aggregations