Search in sources :

Example 21 with StoragePluginRegistry

use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.

the class ClusterMockStorageFixture method insertMockStorage.

/**
 * This should be called after bits are started
 * @param name the mock storage name we are going to create
 */
public void insertMockStorage(String name, boolean breakRegisterSchema) {
    for (Drillbit bit : drillbits()) {
        // Bit name and registration.
        final StoragePluginRegistry pluginRegistry = bit.getContext().getStorage();
        MockBreakageStorage plugin;
        try {
            MockBreakageStorageEngineConfig config = MockBreakageStorageEngineConfig.INSTANCE;
            config.setEnabled(true);
            pluginRegistry.put(name, config);
            plugin = (MockBreakageStorage) pluginRegistry.getPlugin(name);
        } catch (PluginException e) {
            throw new IllegalStateException(e);
        }
        plugin.setBreakRegister(breakRegisterSchema);
    }
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) MockBreakageStorage(org.apache.drill.exec.store.mock.MockBreakageStorage) Drillbit(org.apache.drill.exec.server.Drillbit) PluginException(org.apache.drill.exec.store.StoragePluginRegistry.PluginException) MockBreakageStorageEngineConfig(org.apache.drill.exec.store.mock.MockBreakageStorage.MockBreakageStorageEngineConfig)

Example 22 with StoragePluginRegistry

use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.

the class ClusterFixture method defineWorkspace.

private void defineWorkspace(Drillbit drillbit, String pluginName, String schemaName, String path, String defaultFormat, FormatPluginConfig format, boolean writable) throws PluginException {
    final StoragePluginRegistry pluginRegistry = drillbit.getContext().getStorage();
    final FileSystemConfig pluginConfig = (FileSystemConfig) pluginRegistry.getStoredConfig(pluginName);
    final WorkspaceConfig newTmpWSConfig = new WorkspaceConfig(path, writable, defaultFormat, false);
    Map<String, WorkspaceConfig> newWorkspaces = new HashMap<>();
    Optional.ofNullable(pluginConfig.getWorkspaces()).ifPresent(newWorkspaces::putAll);
    newWorkspaces.put(schemaName, newTmpWSConfig);
    Map<String, FormatPluginConfig> newFormats = new HashMap<>();
    Optional.ofNullable(pluginConfig.getFormats()).ifPresent(newFormats::putAll);
    Optional.ofNullable(format).ifPresent(f -> newFormats.put(defaultFormat, f));
    updatePlugin(pluginRegistry, pluginName, pluginConfig, newWorkspaces, newFormats);
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) HashMap(java.util.HashMap) FormatPluginConfig(org.apache.drill.common.logical.FormatPluginConfig) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig)

Example 23 with StoragePluginRegistry

use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.

the class BaseTestQuery method openClient.

private static void openClient(Properties properties) throws Exception {
    if (properties == null) {
        properties = new Properties();
    }
    allocator = RootAllocatorFactory.newRoot(config);
    serviceSet = RemoteServiceSet.getLocalServiceSet();
    dirTestWatcher.newDfsTestTmpDir();
    bits = new Drillbit[drillbitCount];
    for (int i = 0; i < drillbitCount; i++) {
        bits[i] = new Drillbit(config, serviceSet, classpathScan);
        bits[i].run();
        StoragePluginRegistry pluginRegistry = bits[i].getContext().getStorage();
        StoragePluginTestUtils.configureFormatPlugins(pluginRegistry);
        StoragePluginTestUtils.updateSchemaLocation(StoragePluginTestUtils.DFS_PLUGIN_NAME, pluginRegistry, dirTestWatcher.getDfsTestTmpDir(), TMP_SCHEMA);
        StoragePluginTestUtils.updateSchemaLocation(StoragePluginTestUtils.DFS_PLUGIN_NAME, pluginRegistry, dirTestWatcher.getRootDir(), ROOT_SCHEMA);
        StoragePluginTestUtils.updateSchemaLocation(StoragePluginTestUtils.DFS_PLUGIN_NAME, pluginRegistry, dirTestWatcher.getRootDir(), SchemaFactory.DEFAULT_WS_NAME);
    }
    if (!properties.containsKey(DrillProperties.DRILLBIT_CONNECTION)) {
        properties.setProperty(DrillProperties.DRILLBIT_CONNECTION, String.format("localhost:%s", bits[0].getUserPort()));
    }
    DrillConfig clientConfig = DrillConfig.forClient();
    client = QueryTestUtil.createClient(clientConfig, serviceSet, MAX_WIDTH_PER_NODE, properties);
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) DrillConfig(org.apache.drill.common.config.DrillConfig) Drillbit(org.apache.drill.exec.server.Drillbit) DrillProperties(org.apache.drill.common.config.DrillProperties) Properties(java.util.Properties)

Example 24 with StoragePluginRegistry

use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.

the class BaseTestQuery method openClient.

private static void openClient(Properties properties) throws Exception {
    allocator = RootAllocatorFactory.newRoot(config);
    serviceSet = RemoteServiceSet.getLocalServiceSet();
    dfsTestTmpSchemaLocation = TestUtilities.createTempDir();
    bits = new Drillbit[drillbitCount];
    for (int i = 0; i < drillbitCount; i++) {
        bits[i] = new Drillbit(config, serviceSet, classpathScan);
        bits[i].run();
        final StoragePluginRegistry pluginRegistry = bits[i].getContext().getStorage();
        TestUtilities.updateDfsTestTmpSchemaLocation(pluginRegistry, dfsTestTmpSchemaLocation);
        TestUtilities.makeDfsTmpSchemaImmutable(pluginRegistry);
    }
    client = QueryTestUtil.createClient(config, serviceSet, MAX_WIDTH_PER_NODE, properties);
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) Drillbit(org.apache.drill.exec.server.Drillbit)

Example 25 with StoragePluginRegistry

use of org.apache.drill.exec.store.StoragePluginRegistry in project drill by apache.

the class TestOptiqPlans method doPhysicalTest.

private SimpleRootExec doPhysicalTest(final DrillbitContext bitContext, UserClientConnection connection, String file) throws Exception {
    mockDrillbitContext(bitContext);
    final StoragePluginRegistry reg = new StoragePluginRegistryImpl(bitContext);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(config, reg);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile(file), Charsets.UTF_8));
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(config);
    final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    return exec;
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) FragmentContext(org.apache.drill.exec.ops.FragmentContext) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Aggregations

StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)42 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)10 Drillbit (org.apache.drill.exec.server.Drillbit)8 StoragePluginRegistryImpl (org.apache.drill.exec.store.StoragePluginRegistryImpl)8 BeforeClass (org.junit.BeforeClass)8 Test (org.junit.Test)8 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)6 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)6 File (java.io.File)5 Properties (java.util.Properties)5 DrillConfig (org.apache.drill.common.config.DrillConfig)5 WorkspaceConfig (org.apache.drill.exec.store.dfs.WorkspaceConfig)5 HashMap (java.util.HashMap)4 DrillProperties (org.apache.drill.common.config.DrillProperties)4 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)4 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 DrillBuf (io.netty.buffer.DrillBuf)3 MockBreakageStorage (org.apache.drill.exec.store.mock.MockBreakageStorage)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2