Search in sources :

Example 1 with MockBreakageStorage

use of org.apache.drill.exec.store.mock.MockBreakageStorage in project drill by axbaretto.

the class ClusterMockStorageFixture method insertMockStorage.

/**
 * This should be called after bits are started
 * @param name nthe 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();
        MockStorageEngineConfig config = MockStorageEngineConfig.INSTANCE;
        @SuppressWarnings("resource") MockBreakageStorage plugin = new MockBreakageStorage(MockStorageEngineConfig.INSTANCE, bit.getContext(), name);
        ((StoragePluginRegistryImpl) pluginRegistry).definePlugin(name, config, plugin);
        plugin.setBreakRegister(breakRegisterSchema);
    }
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) MockStorageEngineConfig(org.apache.drill.exec.store.mock.MockStorageEngineConfig) MockBreakageStorage(org.apache.drill.exec.store.mock.MockBreakageStorage) Drillbit(org.apache.drill.exec.server.Drillbit) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl)

Example 2 with MockBreakageStorage

use of org.apache.drill.exec.store.mock.MockBreakageStorage in project drill by apache.

the class TestInfoSchemaFilterPushDown method testLazySchemaRegistration.

/**
 * As reported in DRILL-8057, even queries against INFORMATION_SCHEMA that
 * included a filter that could be pushed down would be penalised by eager
 * schema registration executed on every enabled storage plugin instance.
 * This resulted in slow or even failed INFORMATION_SCHEMA schema queries
 * when some storage plugin was unresponsive, even if it was not needed for
 * the query being run.  This test checks that lazy schema registration is
 * working by installing a mock storage plugin to act as a canary.
 */
@Test
public void testLazySchemaRegistration() throws Exception {
    ClusterMockStorageFixture cluster = ClusterFixture.builder(dirTestWatcher).buildCustomMockStorage();
    // This mock storage plugin throws an exception from registerSchemas which
    // would have been enough to correctly make this test fail were it not that
    // the exception gets swallowed by StoragePluginRegistryImpl so we need to
    // inspect a counter instead.
    cluster.insertMockStorage("registerSchema canary", true);
    ClientFixture client = cluster.clientFixture();
    final String query = "SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_SCHEMA='INFORMATION_SCHEMA'";
    client.queryBuilder().sql(query).run();
    StoragePluginRegistry spr = cluster.drillbit().getContext().getStorage();
    MockBreakageStorage mbs = (MockBreakageStorage) spr.getPlugin("registerSchema canary");
    // no attempt to register schemas on the canary should have been made
    assertEquals(0, mbs.registerAttemptCount);
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) MockBreakageStorage(org.apache.drill.exec.store.mock.MockBreakageStorage) ClusterMockStorageFixture(org.apache.drill.test.ClusterMockStorageFixture) ClientFixture(org.apache.drill.test.ClientFixture) Test(org.junit.Test)

Example 3 with MockBreakageStorage

use of org.apache.drill.exec.store.mock.MockBreakageStorage 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)

Aggregations

StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)3 MockBreakageStorage (org.apache.drill.exec.store.mock.MockBreakageStorage)3 Drillbit (org.apache.drill.exec.server.Drillbit)2 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)1 StoragePluginRegistryImpl (org.apache.drill.exec.store.StoragePluginRegistryImpl)1 MockBreakageStorageEngineConfig (org.apache.drill.exec.store.mock.MockBreakageStorage.MockBreakageStorageEngineConfig)1 MockStorageEngineConfig (org.apache.drill.exec.store.mock.MockStorageEngineConfig)1 ClientFixture (org.apache.drill.test.ClientFixture)1 ClusterMockStorageFixture (org.apache.drill.test.ClusterMockStorageFixture)1 Test (org.junit.Test)1