use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by axbaretto.
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.toString(DrillFileUtils.getResourceAsFile("/physical_test1.json"), Charsets.UTF_8));
String unparse = plan.unparse(writer);
// System.out.println(unparse);
}
use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by axbaretto.
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();
@SuppressWarnings("resource") 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);
final SchemaPlus root = CalciteSchema.createRootSchema(false, false).plus();
registry.getSchemaFactory().registerSchemas(SchemaConfig.newBuilder("foo", context).build(), root);
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);
for (final String sql : sqlStrings) {
if (sql.trim().isEmpty()) {
continue;
}
@SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
}
}
use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by axbaretto.
the class TestBitBitKerberos method successEncryption.
@Test
public void successEncryption() 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.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);
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)));
System.out.println(System.currentTimeMillis() - t1);
}
System.out.println(String.format("Max time: %d", max.get()));
assertTrue(max.get() > 2700);
Thread.sleep(5000);
} finally {
server.close();
connectionManager.close();
c2.close();
}
}
use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by axbaretto.
the class TestSpnegoAuthentication method testOnlyFORMEnabled.
/**
* Validate if FORM security handler is created successfully when only form is configured as auth mechanism
* @throws Exception
*/
@Test
public void testOnlyFORMEnabled() throws Exception {
final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.HTTP_AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("form"))).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).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(true);
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);
assertTrue(securityProvider.isFormEnabled());
assertTrue(!securityProvider.isSpnegoEnabled());
}
use of org.apache.drill.common.scanner.persistence.ScanResult in project drill by axbaretto.
the class TestSpnegoAuthentication method testOnlySPNEGOEnabled.
/**
* Validate only SPNEGO security handler is configured properly when enabled via configuration
* @throws Exception
*/
@Test
public void testOnlySPNEGOEnabled() throws Exception {
final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.HTTP_AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("spnego"))).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).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);
assertTrue(!securityProvider.isFormEnabled());
assertTrue(securityProvider.isSpnegoEnabled());
}
Aggregations