Search in sources :

Example 41 with ScanResult

use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by apache.

the class CheckStorageConfig method ensureStorageEnginePickup.

@Test
public void ensureStorageEnginePickup() {
    DrillConfig config = DrillConfig.create();
    ScanResult scan = ClassPathScanner.fromPrescan(config);
    Collection<?> engines = scan.getImplementations(StoragePluginConfig.class);
    assertEquals(engines.size(), 1);
}
Also used : ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) DrillConfig(org.apache.drill.common.config.DrillConfig) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 42 with ScanResult

use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by apache.

the class PlanningBase method testSqlPlan.

protected void testSqlPlan(String sqlCommands) throws Exception {
    final DrillbitContext dbContext = mock(DrillbitContext.class);
    final QueryContext context = mock(QueryContext.class);
    final String[] sqlStrings = sqlCommands.split(";");
    final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
    provider.start();
    final ScanResult scanResult = ClassPathScanner.fromPrescan(config);
    final LogicalPlanPersistence logicalPlanPersistence = new LogicalPlanPersistence(config, scanResult);
    final SystemOptionManager systemOptions = new SystemOptionManager(logicalPlanPersistence, provider, config);
    systemOptions.init();
    final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
    final SessionOptionManager sessionOptions = userSession.getOptions();
    final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
    final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
    when(dbContext.getMetrics()).thenReturn(new MetricRegistry());
    when(dbContext.getAllocator()).thenReturn(allocator);
    when(dbContext.getConfig()).thenReturn(config);
    when(dbContext.getOptionManager()).thenReturn(systemOptions);
    when(dbContext.getStoreProvider()).thenReturn(provider);
    when(dbContext.getClasspathScan()).thenReturn(scanResult);
    when(dbContext.getLpPersistence()).thenReturn(logicalPlanPersistence);
    final StoragePluginRegistry registry = new StoragePluginRegistryImpl(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
    final DrillOperatorTable table = new DrillOperatorTable(functionRegistry, systemOptions);
    SchemaConfig schemaConfig = SchemaConfig.newBuilder("foo", context).build();
    SchemaPlus root = DynamicSchema.createRootSchema(registry, schemaConfig, new AliasRegistryProvider(dbContext));
    when(context.getNewDefaultSchema()).thenReturn(root);
    when(context.getLpPersistence()).thenReturn(new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config)));
    when(context.getStorage()).thenReturn(registry);
    when(context.getFunctionRegistry()).thenReturn(functionRegistry);
    when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().withOptionManager(sessionOptions).setSupportComplexTypes(true).build());
    when(context.getCurrentEndpoint()).thenReturn(DrillbitEndpoint.getDefaultInstance());
    when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(DrillbitEndpoint.getDefaultInstance()));
    when(context.getPlannerSettings()).thenReturn(new PlannerSettings(queryOptions, functionRegistry));
    when(context.getOptions()).thenReturn(queryOptions);
    when(context.getConfig()).thenReturn(config);
    when(context.getDrillOperatorTable()).thenReturn(table);
    when(context.getAllocator()).thenReturn(allocator);
    when(context.getExecutionControls()).thenReturn(executionControls);
    when(context.getLpPersistence()).thenReturn(logicalPlanPersistence);
    // mocks for org.apache.drill.TestTpchPlanning#tpch06 test.
    // With changes for decimal types, subtract udf for decimals is used.
    when(context.getManagedBuffer()).thenReturn(allocator.buffer(4));
    when(context.getConstantValueHolder(eq("0.03"), eq(TypeProtos.MinorType.VARDECIMAL), Matchers.<Function<DrillBuf, ValueHolder>>any())).thenReturn(ValueHolderHelper.getVarDecimalHolder(allocator.buffer(4), "0.03"));
    when(context.getConstantValueHolder(eq("0.01"), eq(TypeProtos.MinorType.VARDECIMAL), Matchers.<Function<DrillBuf, ValueHolder>>any())).thenReturn(ValueHolderHelper.getVarDecimalHolder(allocator.buffer(4), "0.01"));
    when(context.getOption(anyString())).thenCallRealMethod();
    for (final String sql : sqlStrings) {
        if (sql.trim().isEmpty()) {
            continue;
        }
        @SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) SessionOptionManager(org.apache.drill.exec.server.options.SessionOptionManager) SchemaConfig(org.apache.drill.exec.store.SchemaConfig) PlannerSettings(org.apache.drill.exec.planner.physical.PlannerSettings) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) QueryOptionManager(org.apache.drill.exec.server.options.QueryOptionManager) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) AliasRegistryProvider(org.apache.drill.exec.alias.AliasRegistryProvider) UserSession(org.apache.drill.exec.rpc.user.UserSession) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) DrillOperatorTable(org.apache.drill.exec.planner.sql.DrillOperatorTable) DrillBuf(io.netty.buffer.DrillBuf) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) MetricRegistry(com.codahale.metrics.MetricRegistry) SchemaPlus(org.apache.calcite.schema.SchemaPlus) QueryContext(org.apache.drill.exec.ops.QueryContext) ValueHolder(org.apache.drill.exec.expr.holders.ValueHolder) ExecutionControls(org.apache.drill.exec.testing.ExecutionControls) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl)

Example 43 with ScanResult

use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by apache.

the class TestParsePhysicalPlan method parseSimplePlan.

@Test
public void parseSimplePlan() throws Exception {
    DrillConfig c = DrillConfig.create();
    ScanResult scanResult = ClassPathScanner.fromPrescan(c);
    LogicalPlanPersistence lpp = new LogicalPlanPersistence(c, scanResult);
    PhysicalPlanReader reader = new PhysicalPlanReader(c, scanResult, lpp, CoordinationProtos.DrillbitEndpoint.getDefaultInstance(), null);
    ObjectReader r = lpp.getMapper().reader(PhysicalPlan.class);
    ObjectWriter writer = lpp.getMapper().writer();
    PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/physical_test1.json"), Charsets.UTF_8).read());
    plan.unparse(writer);
}
Also used : ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) DrillConfig(org.apache.drill.common.config.DrillConfig) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest) PlannerTest(org.apache.drill.categories.PlannerTest)

Example 44 with ScanResult

use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by apache.

the class TestBitBitKerberos method successEncryptionChunkMode.

@Test
public void successEncryptionChunkMode() throws Exception {
    final WorkerBee bee = mock(WorkerBee.class);
    final WorkEventBus workBus = mock(WorkEventBus.class);
    newConfig = new DrillConfig(DrillConfig.create(cloneDefaultTestConfigProperties()).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("kerberos"))).withValue(ExecConstants.BIT_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.BIT_AUTHENTICATION_MECHANISM, ConfigValueFactory.fromAnyRef("kerberos")).withValue(ExecConstants.BIT_ENCRYPTION_SASL_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.BIT_ENCRYPTION_SASL_MAX_WRAPPED_SIZE, ConfigValueFactory.fromAnyRef(100000)).withValue(ExecConstants.USE_LOGIN_PRINCIPAL, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(ExecConstants.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())));
    final ScanResult result = ClassPathScanner.fromPrescan(newConfig);
    final BootStrapContext c2 = new BootStrapContext(newConfig, SystemOptionManager.createDefaultOptionDefinitions(), result);
    final FragmentManager manager = setupFragmentContextAndManager(c2.getAllocator());
    when(workBus.getFragmentManager(Mockito.<FragmentHandle>any())).thenReturn(manager);
    final DataConnectionConfig config = new DataConnectionConfig(c2.getAllocator(), c2, new DataServerRequestHandler(workBus, bee));
    final DataServer server = new DataServer(config);
    port = server.bind(port, true);
    final DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build();
    final DataConnectionManager connectionManager = new DataConnectionManager(ep, config);
    final DataTunnel tunnel = new DataTunnel(connectionManager);
    AtomicLong max = new AtomicLong(0);
    try {
        for (int i = 0; i < 40; i++) {
            long t1 = System.currentTimeMillis();
            tunnel.sendRecordBatch(new TimingOutcome(max), new FragmentWritableBatch(false, QueryId.getDefaultInstance(), 1, 1, 1, 1, getRandomBatch(c2.getAllocator(), 5000)));
        }
        assertTrue(max.get() > 2700);
        Thread.sleep(5000);
    } catch (Exception | AssertionError ex) {
        fail();
    } finally {
        server.close();
        connectionManager.close();
        c2.close();
    }
}
Also used : WorkerBee(org.apache.drill.exec.work.WorkManager.WorkerBee) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) FragmentWritableBatch(org.apache.drill.exec.record.FragmentWritableBatch) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) RpcException(org.apache.drill.exec.rpc.RpcException) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) IOException(java.io.IOException) FragmentManager(org.apache.drill.exec.work.fragment.FragmentManager) WorkEventBus(org.apache.drill.exec.rpc.control.WorkEventBus) AtomicLong(java.util.concurrent.atomic.AtomicLong) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) DrillConfig(org.apache.drill.common.config.DrillConfig) BootStrapContext(org.apache.drill.exec.server.BootStrapContext) SecurityTest(org.apache.drill.categories.SecurityTest) Test(org.junit.Test)

Example 45 with ScanResult

use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by apache.

the class TestSpnegoAuthentication method testFORMEnabledWithPlainDisabled.

/**
 * Validate failure in creating FORM security handler when PAM authenticator is absent. PAM authenticator is provided
 * via {@link PlainFactory#getAuthenticator()}
 */
@Test
public void testFORMEnabledWithPlainDisabled() throws Exception {
    try {
        final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.HTTP_AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("form"))).withValue(ExecConstants.HTTP_SPNEGO_PRINCIPAL, ConfigValueFactory.fromAnyRef(spnegoHelper.SERVER_PRINCIPAL)).withValue(ExecConstants.HTTP_SPNEGO_KEYTAB, ConfigValueFactory.fromAnyRef(spnegoHelper.serverKeytab.toString())));
        final ScanResult scanResult = ClassPathScanner.fromPrescan(newConfig);
        final AuthenticatorProviderImpl authenticatorProvider = Mockito.mock(AuthenticatorProviderImpl.class);
        Mockito.when(authenticatorProvider.containsFactory(PlainFactory.SIMPLE_NAME)).thenReturn(false);
        final DrillbitContext context = Mockito.mock(DrillbitContext.class);
        Mockito.when(context.getClasspathScan()).thenReturn(scanResult);
        Mockito.when(context.getConfig()).thenReturn(newConfig);
        Mockito.when(context.getAuthProvider()).thenReturn(authenticatorProvider);
        final DrillHttpSecurityHandlerProvider securityProvider = new DrillHttpSecurityHandlerProvider(newConfig, context);
        fail();
    } catch (Exception ex) {
        assertTrue(ex instanceof DrillbitStartupException);
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) AuthenticatorProviderImpl(org.apache.drill.exec.rpc.security.AuthenticatorProviderImpl) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) DrillHttpSecurityHandlerProvider(org.apache.drill.exec.server.rest.auth.DrillHttpSecurityHandlerProvider) DrillConfig(org.apache.drill.common.config.DrillConfig) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) BaseTest(org.apache.drill.test.BaseTest) SecurityTest(org.apache.drill.categories.SecurityTest) Test(org.junit.Test)

Aggregations

ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)48 DrillConfig (org.apache.drill.common.config.DrillConfig)29 Test (org.junit.Test)26 SecurityTest (org.apache.drill.categories.SecurityTest)16 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)12 IOException (java.io.IOException)10 DrillbitStartupException (org.apache.drill.exec.exception.DrillbitStartupException)10 AuthenticatorProviderImpl (org.apache.drill.exec.rpc.security.AuthenticatorProviderImpl)10 DrillHttpSecurityHandlerProvider (org.apache.drill.exec.server.rest.auth.DrillHttpSecurityHandlerProvider)10 URL (java.net.URL)9 LogicalPlanPersistence (org.apache.drill.common.config.LogicalPlanPersistence)7 BootStrapContext (org.apache.drill.exec.server.BootStrapContext)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)6 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)6 FragmentWritableBatch (org.apache.drill.exec.record.FragmentWritableBatch)6 WorkEventBus (org.apache.drill.exec.rpc.control.WorkEventBus)6 WorkerBee (org.apache.drill.exec.work.WorkManager.WorkerBee)6 BaseTest (org.apache.drill.test.BaseTest)6 URLClassLoader (java.net.URLClassLoader)4 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)4