Search in sources :

Example 6 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class StoragePluginRegistryImpl method setEnabled.

@Override
public void setEnabled(String name, boolean enable) throws PluginException {
    // Works only with the stored config. (Some odd persistent stores do not
    // actually serialize the config; they just cache a copy.) If we change
    // anything, the next request will do a resync to pick up the change.
    name = validateName(name);
    StoragePluginConfig config = requireStoredConfig(name);
    if (config.isEnabled() == enable) {
        return;
    }
    StoragePluginConfig copy = copyConfig(config);
    copy.setEnabled(enable);
    validatedPut(name, copy);
}
Also used : StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig)

Example 7 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class StoragePluginRegistryImpl method getEntry.

private PluginHandle getEntry(String name) {
    PluginHandle plugin = pluginCache.get(name);
    if (plugin != null && plugin.isIntrinsic()) {
        return plugin;
    }
    StoragePluginConfig config = getStoredConfig(name);
    if (plugin == null) {
        return refresh(name, config);
    } else {
        return refresh(plugin, config);
    }
}
Also used : StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig)

Example 8 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class DropboxFileSystemTest method setup.

/*
   All test files can be found in java-exec/src/test/resources/dropboxTestFiles

  Instructions for running Dropbox Unit Tests
  1.  Get your Dropbox API key as explained in the Drill docs and paste it above into the ACCESS_TOKEN variable.
  2.  In your dropbox account, create a folder called 'csv' and upload the file hdf-test.csvh into that folder
  3.  In your dropbox account, upload the file http-pcap.json to the root directory of your dropbox account
  4.  In the testListFiles test, you will have to update the modified dates
  5.  Run tests.
   */
@BeforeClass
public static void setup() throws Exception {
    assertTrue(!ACCESS_TOKEN.equalsIgnoreCase("<Your Dropbox Access Token Here>"));
    ClusterTest.startCluster(ClusterFixture.builder(dirTestWatcher));
    Map<String, String> dropboxConfigVars = new HashMap<>();
    dropboxConfigVars.put("dropboxAccessToken", ACCESS_TOKEN);
    // Create workspaces
    WorkspaceConfig rootWorkspace = new WorkspaceConfig("/", false, null, false);
    WorkspaceConfig csvWorkspace = new WorkspaceConfig("/csv", false, null, false);
    Map<String, WorkspaceConfig> workspaces = new HashMap<>();
    workspaces.put("root", rootWorkspace);
    workspaces.put("csv", csvWorkspace);
    // Add formats
    Map<String, FormatPluginConfig> formats = new HashMap<>();
    List<String> jsonExtensions = new ArrayList<>();
    jsonExtensions.add("json");
    FormatPluginConfig jsonFormatConfig = new JSONFormatConfig(jsonExtensions);
    // CSV Format
    List<String> csvExtensions = new ArrayList<>();
    csvExtensions.add("csv");
    csvExtensions.add("csvh");
    FormatPluginConfig csvFormatConfig = new TextFormatConfig(csvExtensions, "\n", ",", "\"", null, null, false, true);
    StoragePluginConfig dropboxConfig = new FileSystemConfig("dropbox:///", dropboxConfigVars, workspaces, formats, null);
    dropboxConfig.setEnabled(true);
    cluster.defineStoragePlugin("dropbox_test", dropboxConfig);
    cluster.defineFormat("dropbox_test", "json", jsonFormatConfig);
    cluster.defineFormat("dropbox_test", "csv", csvFormatConfig);
}
Also used : HashMap(java.util.HashMap) TextFormatConfig(org.apache.drill.exec.store.easy.text.TextFormatPlugin.TextFormatConfig) ArrayList(java.util.ArrayList) JSONFormatConfig(org.apache.drill.exec.store.easy.json.JSONFormatPlugin.JSONFormatConfig) FormatPluginConfig(org.apache.drill.common.logical.FormatPluginConfig) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) BeforeClass(org.junit.BeforeClass)

Example 9 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class TestClassicLocator method testPrivateConnector.

@Test
public void testPrivateConnector() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // See note above.
    // builder.configBuilder().put(ClassPathScanner.IMPLEMENTATIONS_SCAN_CACHE, false);
    builder.configBuilder().put(ExecConstants.PRIVATE_CONNECTORS, Collections.singletonList(StoragePluginFixture.class.getName()));
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        ConnectorLocator locator = new ClassicConnectorLocator(context);
        locator.init();
        Set<Class<? extends StoragePluginConfig>> result = locator.configClasses();
        // Now the private connector does appear.
        assertTrue(result.contains(StoragePluginFixtureConfig.class));
        // Create a plugin instance given a config
        StoragePluginFixtureConfig config = new StoragePluginFixtureConfig("some-mode");
        StoragePlugin plugin = locator.create("myplugin", config);
        assertNotNull(plugin);
        assertTrue(plugin instanceof StoragePluginFixture);
        // No-op
        locator.close();
    }
}
Also used : AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 10 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class TestPluginRegistry method testFormatPlugin.

@Test
public void testFormatPlugin() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
    try (ClusterFixture cluster = builder.build()) {
        StoragePluginRegistry registry = cluster.storageRegistry();
        StoragePluginConfig config = registry.getStoredConfig(CP_PLUGIN_NAME);
        FileSystemConfig fsConfig = (FileSystemConfig) config;
        assertFalse(fsConfig.getFormats().containsKey("bsv"));
        // Add a new format
        TextFormatConfig bsv = new TextFormatConfig(null, // line delimiter
        null, // field delimiter
        "!", // quote
        null, // escape
        null, // comment
        null, // skip first line
        false, // extract header
        false);
        registry.putFormatPlugin(CP_PLUGIN_NAME, "bsv", bsv);
        config = registry.getStoredConfig(CP_PLUGIN_NAME);
        fsConfig = (FileSystemConfig) config;
        assertTrue(fsConfig.getFormats().containsKey("bsv"));
        assertSame(bsv, fsConfig.getFormats().get("bsv"));
        // Remove the format
        registry.putFormatPlugin(CP_PLUGIN_NAME, "bsv", null);
        config = registry.getStoredConfig(CP_PLUGIN_NAME);
        fsConfig = (FileSystemConfig) config;
        assertFalse(fsConfig.getFormats().containsKey("bsv"));
        // Undefined plugin
        try {
            registry.putFormatPlugin("bogus", "bsv", bsv);
            fail();
        } catch (PluginException e) {
        // Expected
        }
        // Try to set a non-FS plugin
        try {
            registry.putFormatPlugin(SYS_PLUGIN_NAME, "bsv", bsv);
            fail();
        } catch (PluginException e) {
        // Expected
        }
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) TextFormatConfig(org.apache.drill.exec.store.easy.text.TextFormatPlugin.TextFormatConfig) PluginException(org.apache.drill.exec.store.StoragePluginRegistry.PluginException) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Aggregations

StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)28 Test (org.junit.Test)15 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)12 StoragePlugins (org.apache.drill.exec.planner.logical.StoragePlugins)9 OperatorFixture (org.apache.drill.test.OperatorFixture)6 BaseTest (org.apache.drill.test.BaseTest)5 ClusterFixture (org.apache.drill.test.ClusterFixture)5 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)5 HashMap (java.util.HashMap)4 JdbcTest (org.apache.drill.categories.JdbcTest)4 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)4 PlanProperties (org.apache.drill.common.logical.PlanProperties)4 Project (org.apache.drill.common.logical.data.Project)4 Scan (org.apache.drill.common.logical.data.Scan)4 Store (org.apache.drill.common.logical.data.Store)4 InfoSchemaStoragePlugin (org.apache.drill.exec.store.ischema.InfoSchemaStoragePlugin)4 IOException (java.io.IOException)3 Map (java.util.Map)3 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)3 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)3