Search in sources :

Example 31 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration 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));
    }
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) Mode(alluxio.security.authorization.Mode) AclEntry(alluxio.security.authorization.AclEntry) ArrayList(java.util.ArrayList) FileSystemShell(alluxio.cli.fs.FileSystemShell) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 32 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class TableShell method main.

/**
 * Manage Alluxio extensions.
 *
 * @param args array of arguments given by the user's input from the terminal
 */
public static void main(String[] args) {
    TableShell tableShell = new TableShell(new InstancedConfiguration(ConfigurationUtils.defaults()));
    System.exit(tableShell.run(args));
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration)

Example 33 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class TransformTableCommandTest method transformInternal.

private void transformInternal(String definition, String expected) throws Exception {
    TableMasterClient client = mock(TableMasterClient.class);
    when(client.transformTable(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(0L);
    TransformTableCommand command = new TransformTableCommand(new InstancedConfiguration(ConfigurationUtils.defaults()), client, null);
    ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
    if (definition != null) {
        command.run(command.parseAndValidateArgs("db", "table", definition));
    } else {
        command.run(command.parseAndValidateArgs("db", "table"));
    }
    verify(client).transformTable(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), argumentCaptor.capture());
    assertEquals(expected, argumentCaptor.getValue());
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) TableMasterClient(alluxio.client.table.TableMasterClient) TransformTableCommand(alluxio.cli.table.command.TransformTableCommand)

Example 34 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class LocalUnderFileSystemTest method testBrokenSymlinkSkip.

@Test
public void testBrokenSymlinkSkip() throws IOException {
    InstancedConfiguration c = new InstancedConfiguration(sConf.copyProperties());
    c.set(PropertyKey.UNDERFS_LOCAL_SKIP_BROKEN_SYMLINKS, true);
    mLocalUfs = UnderFileSystem.Factory.create(mLocalUfsRoot, UnderFileSystemConfiguration.defaults(c));
    Path linkPath = createNonExistentSymlink();
    assertTrue(Files.exists(linkPath, LinkOption.NOFOLLOW_LINKS));
    assertFalse(Files.exists(linkPath));
    UfsStatus[] statuses = mLocalUfs.listStatus(mLocalUfsRoot);
    assertNotNull(statuses);
    assertEquals(0, statuses.length);
}
Also used : Path(java.nio.file.Path) InstancedConfiguration(alluxio.conf.InstancedConfiguration) UfsStatus(alluxio.underfs.UfsStatus) Test(org.junit.Test)

Example 35 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class LocalUnderFileSystemTest method testSymlinkNonSkip.

@Test
public void testSymlinkNonSkip() throws IOException {
    InstancedConfiguration c = new InstancedConfiguration(sConf.copyProperties());
    c.set(PropertyKey.UNDERFS_LOCAL_SKIP_BROKEN_SYMLINKS, false);
    mLocalUfs = UnderFileSystem.Factory.create(mLocalUfsRoot, UnderFileSystemConfiguration.defaults(c));
    Path linkPath = createNonExistentSymlink();
    assertTrue(Files.exists(linkPath, LinkOption.NOFOLLOW_LINKS));
    assertFalse(Files.exists(linkPath));
    assertThrows(NoSuchFileException.class, () -> mLocalUfs.listStatus(mLocalUfsRoot));
}
Also used : Path(java.nio.file.Path) InstancedConfiguration(alluxio.conf.InstancedConfiguration) Test(org.junit.Test)

Aggregations

InstancedConfiguration (alluxio.conf.InstancedConfiguration)94 Test (org.junit.Test)35 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)16 AlluxioURI (alluxio.AlluxioURI)14 AlluxioProperties (alluxio.conf.AlluxioProperties)11 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)10 HashMap (java.util.HashMap)9 BaseHubTest (alluxio.hub.test.BaseHubTest)8 InetSocketAddress (java.net.InetSocketAddress)8 FileSystemShell (alluxio.cli.fs.FileSystemShell)6 FileSystemContext (alluxio.client.file.FileSystemContext)6 HealthCheckClient (alluxio.HealthCheckClient)5 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)5 FileSystemShellUtilsTest (alluxio.client.cli.fs.FileSystemShellUtilsTest)5 MasterInquireClient (alluxio.master.MasterInquireClient)5 Properties (java.util.Properties)5 ParseException (org.apache.commons.cli.ParseException)5 ClientContext (alluxio.ClientContext)4 FileSystem (alluxio.client.file.FileSystem)4