use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.
the class TestMergeJoin method orderedEqualityInnerJoin.
@Test
@Ignore
public void orderedEqualityInnerJoin() throws Throwable {
final DrillbitContext bitContext = mockDrillbitContext();
final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c, new StoragePluginRegistryImpl(bitContext));
final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_inner_single_batch.json"), Charsets.UTF_8).read().replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.right.json").toURI().toString()));
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
int totalRecordCount = 0;
final StringBuilder sb = new StringBuilder();
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
sb.append(String.format("got next with record count: %d (total: %d):\n", exec.getRecordCount(), totalRecordCount));
sb.append(" t1 t2\n");
for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
final List<Object> row = Lists.newArrayList();
for (final ValueVector v : exec) {
row.add(v.getField().getName() + ":" + v.getAccessor().getObject(valueIdx));
}
for (final Object cell : row) {
if (cell == null) {
sb.append("<null> ");
continue;
}
final int len = cell.toString().length();
sb.append(cell + " ");
for (int i = 0; i < (10 - len); ++i) {
sb.append(" ");
}
}
sb.append('\n');
}
}
assertEquals(23, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.
the class TestMergeJoin method orderedEqualityMultiBatchJoin.
@Test
@Ignore
public void orderedEqualityMultiBatchJoin() throws Throwable {
final DrillbitContext bitContext = mockDrillbitContext();
final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c, new StoragePluginRegistryImpl(bitContext));
final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.json"), Charsets.UTF_8).read().replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.right.json").toURI().toString()));
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
int totalRecordCount = 0;
final StringBuilder sb = new StringBuilder();
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
sb.append(String.format("got next with record count: %d (total: %d):\n", exec.getRecordCount(), totalRecordCount));
for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
final List<Object> row = Lists.newArrayList();
for (final ValueVector v : exec) {
row.add(v.getField().getName() + ":" + v.getAccessor().getObject(valueIdx));
}
for (final Object cell : row) {
if (cell == null) {
sb.append("<null> ");
continue;
}
int len = cell.toString().length();
sb.append(cell + " ");
for (int i = 0; i < (10 - len); ++i) {
sb.append(" ");
}
}
sb.append('\n');
}
}
assertEquals(25, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.
the class TestMergeJoin method orderedEqualityLeftJoin.
@Test
@Ignore
public void orderedEqualityLeftJoin() throws Throwable {
final DrillbitContext bitContext = mockDrillbitContext();
final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c, new StoragePluginRegistryImpl(bitContext));
final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_single_batch.json"), Charsets.UTF_8).read().replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.right.json").toURI().toString()));
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
int totalRecordCount = 0;
final StringBuilder sb = new StringBuilder();
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
sb.append(String.format("got next with record count: %d (total: %d):\n", exec.getRecordCount(), totalRecordCount));
sb.append(" t1 t2\n");
for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
final List<Object> row = Lists.newArrayList();
for (final ValueVector v : exec) {
row.add(v.getField().getName() + ":" + v.getAccessor().getObject(valueIdx));
}
for (final Object cell : row) {
if (cell == null) {
sb.append("<null> ");
continue;
}
final int len = cell.toString().length();
sb.append(cell + " ");
for (int i = 0; i < (10 - len); ++i) {
sb.append(" ");
}
}
sb.append('\n');
}
}
logger.info(sb.toString());
assertEquals(25, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.
the class TestDrillSpnegoAuthenticator method setupTest.
@BeforeClass
public static void setupTest() throws Exception {
spnegoHelper = new KerberosHelper(TestSpnegoAuthentication.class.getSimpleName(), primaryName);
spnegoHelper.setupKdc(dirTestWatcher.getTmpDir());
sun.security.krb5.Config.refresh();
// (2) Reset the default realm.
final Field defaultRealm = KerberosName.class.getDeclaredField("defaultRealm");
defaultRealm.setAccessible(true);
defaultRealm.set(null, KerberosUtil.getDefaultRealm());
// Create a DrillbitContext with service principal and keytab for DrillSpnegoLoginService
final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.HTTP_AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("spnego"))).withValue(ExecConstants.HTTP_SPNEGO_PRINCIPAL, ConfigValueFactory.fromAnyRef(spnegoHelper.SERVER_PRINCIPAL)).withValue(ExecConstants.HTTP_SPNEGO_KEYTAB, ConfigValueFactory.fromAnyRef(spnegoHelper.serverKeytab.toString())));
// Create mock objects for optionManager and AuthConfiguration
final SystemOptionManager optionManager = Mockito.mock(SystemOptionManager.class);
Mockito.when(optionManager.getOption(ExecConstants.ADMIN_USERS_VALIDATOR)).thenReturn(ExecConstants.ADMIN_USERS_VALIDATOR.DEFAULT_ADMIN_USERS);
Mockito.when(optionManager.getOption(ExecConstants.ADMIN_USER_GROUPS_VALIDATOR)).thenReturn(ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.DEFAULT_ADMIN_USER_GROUPS);
final DrillbitContext drillbitContext = Mockito.mock(DrillbitContext.class);
Mockito.when(drillbitContext.getConfig()).thenReturn(newConfig);
Mockito.when(drillbitContext.getOptionManager()).thenReturn(optionManager);
Authenticator.AuthConfiguration authConfiguration = Mockito.mock(Authenticator.AuthConfiguration.class);
spnegoAuthenticator = new DrillSpnegoAuthenticator("SPNEGO");
DrillSpnegoLoginService spnegoLoginService = new DrillSpnegoLoginService(drillbitContext);
Mockito.when(authConfiguration.getLoginService()).thenReturn(spnegoLoginService);
Mockito.when(authConfiguration.getIdentityService()).thenReturn(new DefaultIdentityService());
Mockito.when(authConfiguration.isSessionRenewedOnAuthentication()).thenReturn(true);
// Set the login service and identity service inside SpnegoAuthenticator
spnegoAuthenticator.setConfiguration(authConfiguration);
}
use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.
the class TestCustomTunnel method ensureRoundTripBytes.
@Test
public void ensureRoundTripBytes() throws Exception {
final DrillbitContext context = getDrillbitContext();
final TestCustomMessageHandler handler = new TestCustomMessageHandler(context.getEndpoint(), true);
context.getController().registerCustomHandler(1002, handler, DrillbitEndpoint.PARSER);
final ControlTunnel loopbackTunnel = context.getController().getTunnel(context.getEndpoint());
final CustomTunnel<DrillbitEndpoint, QueryId> tunnel = loopbackTunnel.getCustomTunnel(1002, DrillbitEndpoint.class, QueryId.PARSER);
buf1.retain();
CustomFuture<QueryId> future = tunnel.send(context.getEndpoint(), buf1);
assertEquals(expectedId, future.get());
byte[] actual = new byte[1024];
future.getBuffer().getBytes(0, actual);
future.getBuffer().release();
assertTrue(Arrays.equals(expected, actual));
}
Aggregations