Search in sources :

Example 1 with DrillConfig

use of org.apache.drill.common.config.DrillConfig in project drill by apache.

the class TestEvaluationVisitor method x.

@Test
public void x() throws Exception {
    DrillConfig c = DrillConfig.create();
    FunctionImplementationRegistry reg = new FunctionImplementationRegistry(c);
    EvaluationVisitor v = new EvaluationVisitor(reg);
    CodeGenerator<?> g = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, reg, null);
    SchemaPath path = (SchemaPath) getExpr("a.b[4][2].c[6]");
    TypedFieldId id = //
    TypedFieldId.newBuilder().addId(//
    1).addId(//
    3).remainder(//
    path.getRootSegment()).intermediateType(Types.optional(MinorType.MAP)).finalType(//
    Types.repeated(MinorType.MAP)).hyper().withIndex().build();
    ValueVectorReadExpression e = new ValueVectorReadExpression(id);
    TypedFieldId outId = //
    TypedFieldId.newBuilder().addId(//
    1).finalType(//
    Types.repeated(MinorType.MAP)).intermediateType(//
    Types.repeated(MinorType.MAP)).build();
    ValueVectorWriteExpression e2 = new ValueVectorWriteExpression(outId, e, true);
    v.addExpr(e2, g.getRoot());
    logger.debug(g.generateAndGet());
}
Also used : ValueVectorReadExpression(org.apache.drill.exec.expr.ValueVectorReadExpression) EvaluationVisitor(org.apache.drill.exec.expr.EvaluationVisitor) DrillConfig(org.apache.drill.common.config.DrillConfig) SchemaPath(org.apache.drill.common.expression.SchemaPath) TypedFieldId(org.apache.drill.exec.record.TypedFieldId) ValueVectorWriteExpression(org.apache.drill.exec.expr.ValueVectorWriteExpression) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) Test(org.junit.Test)

Example 2 with DrillConfig

use of org.apache.drill.common.config.DrillConfig in project drill by apache.

the class TestBitBitKerberos method successEncryptionChunkMode.

@Test
public void successEncryptionChunkMode(@Injectable WorkerBee bee, @Injectable final WorkEventBus workBus) throws Exception {
    newConfig = new DrillConfig(config.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(BootStrapContext.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(BootStrapContext.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())), false);
    updateTestCluster(1, newConfig);
    new NonStrictExpectations() {

        {
            workBus.getFragmentManagerIfExists((FragmentHandle) any);
            result = manager;
            workBus.getFragmentManager((FragmentHandle) any);
            result = manager;
        }
    };
    DataConnectionConfig config = new DataConnectionConfig(c1.getAllocator(), c1, new DataServerRequestHandler(workBus, bee));
    DataServer server = new DataServer(config);
    port = server.bind(port, true);
    DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build();
    DataConnectionManager connectionManager = new DataConnectionManager(ep, config);
    DataTunnel tunnel = new DataTunnel(connectionManager);
    AtomicLong max = new AtomicLong(0);
    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(c1.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);
}
Also used : FragmentWritableBatch(org.apache.drill.exec.record.FragmentWritableBatch) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) AtomicLong(java.util.concurrent.atomic.AtomicLong) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) DrillConfig(org.apache.drill.common.config.DrillConfig) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 3 with DrillConfig

use of org.apache.drill.common.config.DrillConfig in project drill by apache.

the class TestBitRpc method testConnectionBackpressure.

@Test
public void testConnectionBackpressure(@Injectable WorkerBee bee, @Injectable final WorkEventBus workBus) throws Exception {
    DrillConfig config1 = DrillConfig.create();
    final BootStrapContext c = new BootStrapContext(config1, ClassPathScanner.fromPrescan(config1));
    DrillConfig config2 = DrillConfig.create();
    BootStrapContext c2 = new BootStrapContext(config2, ClassPathScanner.fromPrescan(config2));
    final FragmentContext fcon = new MockUp<FragmentContext>() {

        BufferAllocator getAllocator() {
            return c.getAllocator();
        }
    }.getMockInstance();
    final FragmentManager fman = new MockUp<FragmentManager>() {

        int v = 0;

        @Mock
        boolean handle(IncomingDataBatch batch) throws FragmentSetupException, IOException {
            try {
                v++;
                if (v % 10 == 0) {
                    System.out.println("sleeping.");
                    Thread.sleep(3000);
                }
            } catch (InterruptedException e) {
            }
            RawFragmentBatch rfb = batch.newRawFragmentBatch(c.getAllocator());
            rfb.sendOk();
            rfb.release();
            return true;
        }

        public FragmentContext getFragmentContext() {
            return fcon;
        }
    }.getMockInstance();
    new NonStrictExpectations() {

        {
            workBus.getFragmentManagerIfExists((FragmentHandle) any);
            result = fman;
            workBus.getFragmentManager((FragmentHandle) any);
            result = fman;
        }
    };
    int port = 1234;
    DataConnectionConfig config = new DataConnectionConfig(c.getAllocator(), c, new DataServerRequestHandler(workBus, bee));
    DataServer server = new DataServer(config);
    port = server.bind(port, true);
    DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build();
    DataConnectionManager manager = new DataConnectionManager(ep, config);
    DataTunnel tunnel = new DataTunnel(manager);
    AtomicLong max = new AtomicLong(0);
    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(c.getAllocator(), 5000)));
        System.out.println(System.currentTimeMillis() - t1);
    // System.out.println("sent.");
    }
    System.out.println(String.format("Max time: %d", max.get()));
    assertTrue(max.get() > 2700);
    Thread.sleep(5000);
}
Also used : FragmentContext(org.apache.drill.exec.ops.FragmentContext) FragmentWritableBatch(org.apache.drill.exec.record.FragmentWritableBatch) Mock(mockit.Mock) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) DrillConfig(org.apache.drill.common.config.DrillConfig) RawFragmentBatch(org.apache.drill.exec.record.RawFragmentBatch) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException) IOException(java.io.IOException) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) BufferAllocator(org.apache.drill.exec.memory.BufferAllocator) FragmentManager(org.apache.drill.exec.work.fragment.FragmentManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) BootStrapContext(org.apache.drill.exec.server.BootStrapContext) NonStrictExpectations(mockit.NonStrictExpectations) ExecTest(org.apache.drill.exec.ExecTest) Test(org.junit.Test)

Example 4 with DrillConfig

use of org.apache.drill.common.config.DrillConfig in project drill by apache.

the class TestCustomUserAuthenticator method setupCluster.

@BeforeClass
public static void setupCluster() {
    // Create a new DrillConfig which has user authentication enabled and authenticator set to
    // UserAuthenticatorTestImpl.
    final Properties props = cloneDefaultTestConfigProperties();
    final DrillConfig newConfig = new DrillConfig(DrillConfig.create(props).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef("true")).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)), false);
    final Properties connectionProps = new Properties();
    connectionProps.setProperty(DrillProperties.USER, "anonymous");
    connectionProps.setProperty(DrillProperties.PASSWORD, "anything works!");
    updateTestCluster(3, newConfig, connectionProps);
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) Properties(java.util.Properties) DrillProperties(org.apache.drill.common.config.DrillProperties) BeforeClass(org.junit.BeforeClass)

Example 5 with DrillConfig

use of org.apache.drill.common.config.DrillConfig in project drill by apache.

the class StoragePlugins method main.

public static void main(String[] args) throws Exception {
    DrillConfig config = DrillConfig.create();
    ScanResult scanResult = ClassPathScanner.fromPrescan(config);
    LogicalPlanPersistence lpp = new LogicalPlanPersistence(config, scanResult);
    String data = Resources.toString(Resources.getResource("storage-engines.json"), Charsets.UTF_8);
    StoragePlugins se = lpp.getMapper().readValue(data, StoragePlugins.class);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    lpp.getMapper().writeValue(System.out, se);
    lpp.getMapper().writeValue(os, se);
    se = lpp.getMapper().readValue(new ByteArrayInputStream(os.toByteArray()), StoragePlugins.class);
    System.out.println(se);
}
Also used : ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) DrillConfig(org.apache.drill.common.config.DrillConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence)

Aggregations

DrillConfig (org.apache.drill.common.config.DrillConfig)249 Test (org.junit.Test)165 Properties (java.util.Properties)89 SecurityTest (org.apache.drill.categories.SecurityTest)88 DrillProperties (org.apache.drill.common.config.DrillProperties)77 NonTransientRpcException (org.apache.drill.exec.rpc.NonTransientRpcException)32 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)29 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)28 BeforeClass (org.junit.BeforeClass)25 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)23 SaslException (javax.security.sasl.SaslException)20 RpcException (org.apache.drill.exec.rpc.RpcException)20 Drillbit (org.apache.drill.exec.server.Drillbit)20 DrillbitStartupException (org.apache.drill.exec.exception.DrillbitStartupException)18 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)17 BaseTest (org.apache.drill.test.BaseTest)17 ExecTest (org.apache.drill.exec.ExecTest)14 IOException (java.io.IOException)12 IcebergMetastore (org.apache.drill.metastore.iceberg.IcebergMetastore)12 File (java.io.File)10