use of alluxio.cli.fs.FileSystemShell in project alluxio by Alluxio.
the class JobServiceFaultToleranceShellTest method distributedCp.
@Test
public void distributedCp() throws Exception {
FileSystem fs = FileSystem.Factory.create(ServerConfiguration.global());
try (OutputStream out = fs.createFile(new AlluxioURI("/test"))) {
out.write("Hello".getBytes());
}
try (FileSystemShell shell = new FileSystemShell(ServerConfiguration.global())) {
int exitCode = shell.run("distributedCp", "/test", "/test2");
assertEquals("Command failed, output: " + mOutput.toString(), 0, exitCode);
}
assertTrue(fs.exists(new AlluxioURI("/test2")));
}
use of alluxio.cli.fs.FileSystemShell in project alluxio by Alluxio.
the class CpCommandIntegrationTest method copyFileWithPreservedAttributes.
/**
* Tests copying a file with attributes preserved.
*/
@Test
public void copyFileWithPreservedAttributes() throws Exception {
InstancedConfiguration conf = new InstancedConfiguration(ServerConfiguration.global());
// avoid chown on UFS since test might not be run with root
conf.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, "MUST_CACHE");
try (FileSystemShell fsShell = new FileSystemShell(conf)) {
String testDir = FileSystemShellUtilsTest.resetFileHierarchy(sFileSystem);
AlluxioURI srcFile = new AlluxioURI(testDir + "/foobar4");
String owner = TEST_USER_1.getUser();
String group = "staff";
short mode = 0422;
List<AclEntry> entries = new ArrayList<>();
entries.add(new AclEntry.Builder().setType(AclEntryType.NAMED_USER).setSubject(TEST_USER_2.getUser()).addAction(AclAction.READ).addAction(AclAction.WRITE).addAction(AclAction.EXECUTE).build());
entries.add(new AclEntry.Builder().setType(AclEntryType.NAMED_GROUP).setSubject(group).addAction(AclAction.WRITE).addAction(AclAction.EXECUTE).build());
sFileSystem.setAttribute(srcFile, SetAttributePOptions.newBuilder().setOwner(owner).setGroup(group).setMode(new Mode(mode).toProto()).setPinned(true).setReplicationMin(2).setReplicationMax(4).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(12345)).build());
sFileSystem.setAcl(srcFile, SetAclAction.MODIFY, entries);
int ret = fsShell.run("cp", "-p", testDir + "/foobar4", testDir + "/bar");
AlluxioURI dstFile = new AlluxioURI(testDir + "/bar/foobar4");
Assert.assertEquals(0, ret);
Assert.assertTrue(sFileSystem.exists(dstFile));
verifyPreservedAttributes(srcFile, dstFile);
}
}
use of alluxio.cli.fs.FileSystemShell in project alluxio by Alluxio.
the class CpCommandIntegrationTest method copyDirectoryWithPreservedAttributes.
/**
* Tests copying a folder with attributes preserved.
*/
@Test
public void copyDirectoryWithPreservedAttributes() throws Exception {
InstancedConfiguration conf = new InstancedConfiguration(ServerConfiguration.global());
conf.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, "MUST_CACHE");
try (FileSystemShell fsShell = new FileSystemShell(conf)) {
String testDir = FileSystemShellUtilsTest.resetFileHierarchy(sFileSystem);
String newDir = "/copy";
String subDir = "/foo";
String file = "/foobar4";
String owner = TEST_USER_1.getUser();
String group = "staff";
short mode = 0422;
List<AclEntry> entries = new ArrayList<>();
entries.add(new AclEntry.Builder().setType(AclEntryType.NAMED_USER).setSubject(TEST_USER_2.getUser()).addAction(AclAction.READ).addAction(AclAction.WRITE).addAction(AclAction.EXECUTE).build());
entries.add(new AclEntry.Builder().setType(AclEntryType.NAMED_GROUP).setSubject(group).addAction(AclAction.WRITE).addAction(AclAction.EXECUTE).build());
AlluxioURI srcDir = new AlluxioURI(testDir);
sFileSystem.setAttribute(srcDir, SetAttributePOptions.newBuilder().setRecursive(true).setOwner(owner).setGroup(group).setMode(new Mode(mode).toProto()).setPinned(true).setReplicationMin(2).setReplicationMax(4).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(12345)).build());
sFileSystem.setAcl(srcDir, SetAclAction.MODIFY, entries, SetAclPOptions.newBuilder().setRecursive(true).build());
int ret = fsShell.run("cp", "-R", "-p", testDir, newDir);
AlluxioURI dstDir = new AlluxioURI(newDir);
Assert.assertEquals(0, ret);
Assert.assertTrue(sFileSystem.exists(dstDir));
verifyPreservedAttributes(srcDir, dstDir);
verifyPreservedAttributes(srcDir.join(subDir), dstDir.join(subDir));
verifyPreservedAttributes(srcDir.join(file), dstDir.join(file));
}
}
use of alluxio.cli.fs.FileSystemShell in project alluxio by Alluxio.
the class PersistCommandTest method persistOnRenameDirectory.
@Test
public void persistOnRenameDirectory() throws Exception {
InstancedConfiguration conf = new InstancedConfiguration(ServerConfiguration.global());
conf.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, "MUST_CACHE");
conf.set(PropertyKey.USER_FILE_PERSIST_ON_RENAME, true);
try (FileSystemShell fsShell = new FileSystemShell(conf)) {
String testDir = FileSystemShellUtilsTest.resetFileHierarchy(sFileSystem);
String toPersist = testDir + "/foo";
String persisted = testDir + "/foo_persisted";
String doNotPersist = testDir + "/bar";
assertFalse(sFileSystem.getStatus(new AlluxioURI(testDir)).isPersisted());
assertFalse(sFileSystem.getStatus(new AlluxioURI(toPersist)).isPersisted());
assertFalse(sFileSystem.getStatus(new AlluxioURI(doNotPersist)).isPersisted());
int ret = fsShell.run("mv", toPersist, persisted);
Assert.assertEquals(mOutput.toString(), 0, ret);
CommonUtils.waitFor("Directory to be persisted", () -> {
try {
return sFileSystem.getStatus(new AlluxioURI(persisted)).isPersisted() && sFileSystem.getStatus(new AlluxioURI(persisted + "/foobar1")).isPersisted() && sFileSystem.getStatus(new AlluxioURI(persisted + "/foobar2")).isPersisted();
} catch (Exception e) {
return false;
}
}, WaitForOptions.defaults().setTimeoutMs(10000));
assertFalse(sFileSystem.getStatus(new AlluxioURI(testDir + "/bar")).isPersisted());
checkFilePersisted(new AlluxioURI(persisted + "/foobar1"), 10);
checkFilePersisted(new AlluxioURI(persisted + "/foobar2"), 20);
}
}
use of alluxio.cli.fs.FileSystemShell in project alluxio by Alluxio.
the class PinCommandMultipleMediaIntegrationTest method setPinToSpecificMedia.
@Test
public void setPinToSpecificMedia() throws Exception {
FileSystem fileSystem = sLocalAlluxioClusterResource.get().getClient();
FileSystemShell fsShell = new FileSystemShell(ServerConfiguration.global());
AlluxioURI filePathA = new AlluxioURI("/testFileA");
AlluxioURI filePathB = new AlluxioURI("/testFileB");
int fileSize = SIZE_BYTES / 2;
FileSystemTestUtils.createByteFile(fileSystem, filePathA, WritePType.CACHE_THROUGH, fileSize);
assertTrue(fileSystem.exists(filePathA));
assertEquals(0, fsShell.run("pin", filePathA.toString(), Constants.MEDIUM_SSD));
CommonUtils.waitFor("File being moved", () -> sJobCluster.getMaster().getJobMaster().listDetailed().stream().anyMatch(x -> x.getName().equals("Move") && x.getStatus().equals(Status.COMPLETED) && x.getAffectedPaths().contains(filePathA.getPath())), sWaitOptions);
assertTrue(fileSystem.getStatus(filePathA).getFileBlockInfos().get(0).getBlockInfo().getLocations().stream().anyMatch(x -> x.getMediumType().equals(Constants.MEDIUM_SSD)));
assertEquals(-1, fsShell.run("pin", filePathB.toString(), "NVRAM"));
}
Aggregations