use of org.apache.drill.common.logical.StoragePluginConfig in project drill by axbaretto.
the class JdbcDataTest method testProjectPlan.
/**
* Checks the logical plan.
*/
@Test
public void testProjectPlan() throws Exception {
LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select _MAP['ppu'] as ppu from donuts").logicalPlan();
PlanProperties planProperties = plan.getProperties();
Assert.assertEquals("optiq", planProperties.generator.type);
Assert.assertEquals("na", planProperties.generator.info);
Assert.assertEquals(1, planProperties.version);
Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
StoragePluginConfig config = seConfigs.get("donuts-json");
// Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
config = seConfigs.get("queue");
// Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
Scan scan = findOnlyOperator(plan, Scan.class);
Assert.assertEquals("donuts-json", scan.getStorageEngine());
Project project = findOnlyOperator(plan, Project.class);
Assert.assertEquals(1, project.getSelections().size());
Assert.assertEquals(Scan.class, project.getInput().getClass());
Store store = findOnlyOperator(plan, Store.class);
Assert.assertEquals("queue", store.getStorageEngine());
Assert.assertEquals("output sink", store.getMemo());
Assert.assertEquals(Project.class, store.getInput().getClass());
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class TestPluginRegistry method testEnabledState.
/**
* Tests the dedicated setEnabled() method to cleanly update the
* enabled status of a plugin by name.
*/
@Test
public void testEnabledState() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
try (ClusterFixture cluster = builder.build()) {
StoragePluginRegistry registry = cluster.storageRegistry();
// Disable an enabled plugin
StoragePluginConfig config = registry.getStoredConfig(CP_PLUGIN_NAME);
assertTrue(config.isEnabled());
// Enable/disable has traditionally been done by changing
// the plugin outside of the registry, which leads to obvious
// race conditions.
// Tests synchronized version.
registry.setEnabled(CP_PLUGIN_NAME, true);
StoragePluginConfig savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertTrue(savedConfig.isEnabled());
registry.setEnabled(CP_PLUGIN_NAME, false);
savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertFalse(savedConfig.isEnabled());
// OK to disable twice
registry.setEnabled(CP_PLUGIN_NAME, false);
savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertFalse(savedConfig.isEnabled());
// Disabled plugins appear in the stored config map
Map<String, StoragePluginConfig> configMap = registry.storedConfigs();
assertTrue(configMap.containsKey(CP_PLUGIN_NAME));
assertEquals(config, configMap.get(CP_PLUGIN_NAME));
// Re-enable
registry.setEnabled(CP_PLUGIN_NAME, true);
savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertTrue(savedConfig.isEnabled());
// Error if plugin does not exist
try {
registry.setEnabled("foo", true);
fail();
} catch (PluginException e) {
// expected
}
try {
registry.setEnabled("foo", false);
fail();
} catch (PluginException e) {
// expected
}
// Error to mess with a system plugins
try {
registry.setEnabled(SYS_PLUGIN_NAME, true);
fail();
} catch (PluginException e) {
// expected
}
try {
registry.setEnabled(SYS_PLUGIN_NAME, false);
fail();
} catch (PluginException e) {
// expected
}
}
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class TestPluginRegistry method testEphemeralWithoutInstance.
@Test
public void testEphemeralWithoutInstance() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
try (ClusterFixture cluster = builder.build()) {
StoragePluginRegistry registry = cluster.storageRegistry();
// Create a plugin
// Since we've created no plugin instance, the configs come from
// the persistent store, there is no guarantee we get the same
// instance on each retrieval.
FileSystemConfig pConfig1 = myConfig1();
registry.put(MY_PLUGIN_NAME, pConfig1);
StoragePluginConfig savedConfig = registry.getStoredConfig(MY_PLUGIN_NAME);
assertEquals(pConfig1, savedConfig);
assertTrue(savedConfig.isEnabled());
assertEquals(pConfig1, registry.getDefinedConfig(MY_PLUGIN_NAME));
// Do not refer to the instance. As a result, no reason to
// cache the plugin in ephemeral cache.
// Change config
FileSystemConfig pConfig1b = myConfig2();
registry.put(MY_PLUGIN_NAME, pConfig1b);
assertEquals(pConfig1b, registry.getDefinedConfig(MY_PLUGIN_NAME));
// Put it back
FileSystemConfig pConfig1c = myConfig1();
registry.put(MY_PLUGIN_NAME, pConfig1c);
assertEquals(pConfig1c, registry.getDefinedConfig(MY_PLUGIN_NAME));
assertEquals(pConfig1c, registry.getPlugin(MY_PLUGIN_NAME).getConfig());
// Odd case. Some thread refers to the config while not in
// the store which forces an instance which later reappears.
FileSystemConfig pConfig2a = myConfig1();
registry.put("myplugin2", pConfig2a);
// Didn't instantiate. Change
FileSystemConfig pConfig2b = myConfig2();
registry.put("myplugin2", pConfig2b);
// Force a resync
assertEquals(pConfig2b, registry.getDefinedConfig("myplugin2"));
// Refer by original config. We didn't cache the original config
// because there was no plugin instance. Must make up a new plugin
// Which goes into the ephemeral cache.
FileSystemConfig pConfig2c = myConfig1();
StoragePlugin plugin2 = registry.getPluginByConfig(pConfig2c);
assertEquals(pConfig2c, plugin2.getConfig());
// Put the original config into the persistent store and local cache.
// Should not dredge up the ephemeral version to reuse since that
// version had an unknown name.
// It is unfortunate that we have to instances with the same config,
// but different names. But, since the name is immutable, and not
// known above, the two-instance situation is the least bad option.
FileSystemConfig pConfig2d = myConfig1();
registry.put("myplugin2", pConfig2d);
assertEquals(pConfig2d, registry.getPlugin("myplugin2").getConfig());
}
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class TestBootstrapLoader method testDuplicateBootstrapEntries.
@Test
public void testDuplicateBootstrapEntries() throws Exception {
OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
String bootstrapFile = RESOURCE_BASE + "dup-bootstrap.json";
builder.configBuilder().put(ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE, bootstrapFile);
try (OperatorFixture fixture = builder.build()) {
PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
PluginBootstrapLoaderImpl loader = new PluginBootstrapLoaderImpl(context);
StoragePlugins plugins = loader.loadBootstrapPlugins(new HashMap<>());
// Duplicates noted in log; last one wins.
StoragePluginConfig pluginConfig = plugins.getConfig("cp");
assertNotNull(pluginConfig);
assertTrue(pluginConfig instanceof FileSystemConfig);
FileSystemConfig cpConfig = (FileSystemConfig) pluginConfig;
assertNotNull(cpConfig.getFormats().get("tsv"));
}
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class TestBootstrapLoader method testBootstrapLoaderWithFormats.
/**
* Test a format bootstrap with a mock file. Can't use a real
* file because those appear in modules not yet available when
* this test runs.
*/
@Test
public void testBootstrapLoaderWithFormats() throws Exception {
OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
String bootstrapFile = RESOURCE_BASE + "mock-format-bootstrap.json";
builder.configBuilder().put(ExecConstants.BOOTSTRAP_FORMAT_PLUGINS_FILE, bootstrapFile);
try (OperatorFixture fixture = builder.build()) {
PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
PluginBootstrapLoader loader = new PluginBootstrapLoaderImpl(context);
StoragePlugins plugins = loader.bootstrapPlugins();
// bsv added to dfs
StoragePluginConfig pluginConfig = plugins.getConfig("dfs");
assertNotNull(pluginConfig);
FileSystemConfig dfs = (FileSystemConfig) pluginConfig;
assertNotNull(dfs.getFormats().get("bsv"));
}
}
Aggregations