Search in sources :

Example 1 with WorkspaceConfig

use of org.apache.drill.exec.store.dfs.WorkspaceConfig in project drill by apache.

the class TestUtilities method updateDfsTestTmpSchemaLocation.

/**
   * Update the location of dfs_test.tmp location. Get the "dfs_test.tmp" workspace and update the location with an
   * exclusive temp directory just for use in the current test jvm.
   *
   * @param pluginRegistry
   * @return JVM exclusive temporary directory location.
   */
public static void updateDfsTestTmpSchemaLocation(final StoragePluginRegistry pluginRegistry, final String tmpDirPath) throws ExecutionSetupException {
    @SuppressWarnings("resource") final FileSystemPlugin plugin = (FileSystemPlugin) pluginRegistry.getPlugin(dfsTestPluginName);
    final FileSystemConfig pluginConfig = (FileSystemConfig) plugin.getConfig();
    final WorkspaceConfig tmpWSConfig = pluginConfig.workspaces.get(dfsTestTmpSchema);
    final WorkspaceConfig newTmpWSConfig = new WorkspaceConfig(tmpDirPath, true, tmpWSConfig.getDefaultInputFormat());
    pluginConfig.workspaces.remove(dfsTestTmpSchema);
    pluginConfig.workspaces.put(dfsTestTmpSchema, newTmpWSConfig);
    pluginRegistry.createOrUpdate(dfsTestPluginName, pluginConfig, true);
}
Also used : FileSystemPlugin(org.apache.drill.exec.store.dfs.FileSystemPlugin) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig)

Example 2 with WorkspaceConfig

use of org.apache.drill.exec.store.dfs.WorkspaceConfig in project drill by apache.

the class BaseTestImpersonation method createAndAddWorkspace.

protected static void createAndAddWorkspace(String name, String path, short permissions, String owner, String group, final Map<String, WorkspaceConfig> workspaces) throws Exception {
    final Path dirPath = new Path(path);
    FileSystem.mkdirs(fs, dirPath, new FsPermission(permissions));
    fs.setOwner(dirPath, owner, group);
    final WorkspaceConfig ws = new WorkspaceConfig(path, true, "parquet");
    workspaces.put(name, ws);
}
Also used : Path(org.apache.hadoop.fs.Path) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FsPermission(org.apache.hadoop.fs.permission.FsPermission)

Example 3 with WorkspaceConfig

use of org.apache.drill.exec.store.dfs.WorkspaceConfig in project drill by apache.

the class TestImpersonationQueries method createTestWorkspaces.

private static Map<String, WorkspaceConfig> createTestWorkspaces() throws Exception {
    // Create "/tmp" folder and set permissions to "777"
    final Path tmpPath = new Path("/tmp");
    fs.delete(tmpPath, true);
    FileSystem.mkdirs(fs, tmpPath, new FsPermission((short) 0777));
    Map<String, WorkspaceConfig> workspaces = Maps.newHashMap();
    // create user directory (ex. "/user/user0_1", with ownership "user0_1:group0_1" and perms 755) for every user.
    for (int i = 0; i < org1Users.length; i++) {
        final String user = org1Users[i];
        final String group = org1Groups[i];
        createAndAddWorkspace(user, getUserHome(user), (short) 0755, user, group, workspaces);
    }
    // create user directory (ex. "/user/user0_2", with ownership "user0_2:group0_2" and perms 755) for every user.
    for (int i = 0; i < org2Users.length; i++) {
        final String user = org2Users[i];
        final String group = org2Groups[i];
        createAndAddWorkspace(user, getUserHome(user), (short) 0755, user, group, workspaces);
    }
    return workspaces;
}
Also used : Path(org.apache.hadoop.fs.Path) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FsPermission(org.apache.hadoop.fs.permission.FsPermission) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Example 4 with WorkspaceConfig

use of org.apache.drill.exec.store.dfs.WorkspaceConfig in project drill by apache.

the class TestImpersonationMetadata method createTestWorkspaces.

private static Map<String, WorkspaceConfig> createTestWorkspaces() throws Exception {
    // Create "/tmp" folder and set permissions to "777"
    final Path tmpPath = new Path("/tmp");
    fs.delete(tmpPath, true);
    FileSystem.mkdirs(fs, tmpPath, new FsPermission((short) 0777));
    Map<String, WorkspaceConfig> workspaces = Maps.newHashMap();
    // Create /drillTestGrp0_700 directory with permissions 700 (owned by user running the tests)
    createAndAddWorkspace("drillTestGrp0_700", "/drillTestGrp0_700", (short) 0700, processUser, group0, workspaces);
    // Create /drillTestGrp0_750 directory with permissions 750 (owned by user running the tests)
    createAndAddWorkspace("drillTestGrp0_750", "/drillTestGrp0_750", (short) 0750, processUser, group0, workspaces);
    // Create /drillTestGrp0_755 directory with permissions 755 (owned by user running the tests)
    createAndAddWorkspace("drillTestGrp0_755", "/drillTestGrp0_755", (short) 0755, processUser, group0, workspaces);
    // Create /drillTestGrp0_770 directory with permissions 770 (owned by user running the tests)
    createAndAddWorkspace("drillTestGrp0_770", "/drillTestGrp0_770", (short) 0770, processUser, group0, workspaces);
    // Create /drillTestGrp0_777 directory with permissions 777 (owned by user running the tests)
    createAndAddWorkspace("drillTestGrp0_777", "/drillTestGrp0_777", (short) 0777, processUser, group0, workspaces);
    // Create /drillTestGrp1_700 directory with permissions 700 (owned by user1)
    createAndAddWorkspace("drillTestGrp1_700", "/drillTestGrp1_700", (short) 0700, user1, group1, workspaces);
    // create /user2_workspace1 with 775 permissions (owner by user1)
    createAndAddWorkspace("user2_workspace1", "/user2_workspace1", (short) 0775, user2, group1, workspaces);
    // create /user2_workspace with 755 permissions (owner by user1)
    createAndAddWorkspace("user2_workspace2", "/user2_workspace2", (short) 0755, user2, group1, workspaces);
    return workspaces;
}
Also used : Path(org.apache.hadoop.fs.Path) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FsPermission(org.apache.hadoop.fs.permission.FsPermission) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Example 5 with WorkspaceConfig

use of org.apache.drill.exec.store.dfs.WorkspaceConfig in project drill by apache.

the class ClusterFixture method defineWorkspace.

public static void defineWorkspace(Drillbit drillbit, String pluginName, String schemaName, String path, String defaultFormat, FormatPluginConfig format) throws ExecutionSetupException {
    @SuppressWarnings("resource") final StoragePluginRegistry pluginRegistry = drillbit.getContext().getStorage();
    @SuppressWarnings("resource") final FileSystemPlugin plugin = (FileSystemPlugin) pluginRegistry.getPlugin(pluginName);
    final FileSystemConfig pluginConfig = (FileSystemConfig) plugin.getConfig();
    final WorkspaceConfig newTmpWSConfig = new WorkspaceConfig(path, true, defaultFormat);
    pluginConfig.workspaces.remove(schemaName);
    pluginConfig.workspaces.put(schemaName, newTmpWSConfig);
    if (format != null) {
        pluginConfig.formats.put(defaultFormat, format);
    }
    pluginRegistry.createOrUpdate(pluginName, pluginConfig, true);
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) FileSystemPlugin(org.apache.drill.exec.store.dfs.FileSystemPlugin) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig)

Aggregations

WorkspaceConfig (org.apache.drill.exec.store.dfs.WorkspaceConfig)7 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)4 FsPermission (org.apache.hadoop.fs.permission.FsPermission)4 FileSystemPlugin (org.apache.drill.exec.store.dfs.FileSystemPlugin)3 Path (org.apache.hadoop.fs.Path)3 StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 Properties (java.util.Properties)1 UUID (java.util.UUID)1 Configuration (org.apache.hadoop.conf.Configuration)1 BeforeClass (org.junit.BeforeClass)1