Search in sources :

Example 1 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class QueryTestUtil method setupScalarReplacementOption.

/**
   * Set up the options to test the scalar replacement retry option (see
   * ClassTransformer.java). Scalar replacement rewrites bytecode to replace
   * value holders (essentially boxed values) with their member variables as
   * locals. There is still one pattern that doesn't work, and occasionally new
   * ones are introduced. This can be used in tests that exercise failing patterns.
   *
   * <p>This also flushes the compiled code cache.
   *
   * @param drillbit the drillbit
   * @param srOption the scalar replacement option value to use
   * @return the original scalar replacement option setting (so it can be restored)
   */
@SuppressWarnings("resource")
public static OptionValue setupScalarReplacementOption(final Drillbit drillbit, final ClassTransformer.ScalarReplacementOption srOption) {
    // set the system option
    final DrillbitContext drillbitContext = drillbit.getContext();
    final OptionManager optionManager = drillbitContext.getOptionManager();
    final OptionValue originalOptionValue = optionManager.getOption(ClassTransformer.SCALAR_REPLACEMENT_OPTION);
    final OptionValue newOptionValue = OptionValue.createString(OptionValue.OptionType.SYSTEM, ClassTransformer.SCALAR_REPLACEMENT_OPTION, srOption.name().toLowerCase());
    optionManager.setOption(newOptionValue);
    // flush the code cache
    drillbitContext.getCompiler().flushCache();
    return originalOptionValue;
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) OptionValue(org.apache.drill.exec.server.options.OptionValue) OptionManager(org.apache.drill.exec.server.options.OptionManager)

Example 2 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class QueryTestUtil method restoreScalarReplacementOption.

/**
   * Restore the original scalar replacement option returned from
   * setupScalarReplacementOption().
   *
   * <p>This also flushes the compiled code cache.
   *
   * @param drillbit the drillbit
   * @param srOption the scalar replacement option value to use
   */
public static void restoreScalarReplacementOption(final Drillbit drillbit, final OptionValue srOption) {
    @SuppressWarnings("resource") final DrillbitContext drillbitContext = drillbit.getContext();
    @SuppressWarnings("resource") final OptionManager optionManager = drillbitContext.getOptionManager();
    optionManager.setOption(srOption);
    // flush the code cache
    drillbitContext.getCompiler().flushCache();
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) OptionManager(org.apache.drill.exec.server.options.OptionManager)

Example 3 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class TestDynamicUDFSupport method spyFunctionImplementationRegistry.

private FunctionImplementationRegistry spyFunctionImplementationRegistry() {
    DrillbitContext drillbitContext = getDrillbitContext();
    FunctionImplementationRegistry spy = spy(drillbitContext.getFunctionImplementationRegistry());
    Deencapsulation.setField(drillbitContext, "functionRegistry", spy);
    return spy;
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Example 4 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class DrillRoot method getClusterInfoJSON.

@SuppressWarnings("resource")
@GET
@Path("/cluster.json")
@Produces(MediaType.APPLICATION_JSON)
public ClusterInfo getClusterInfoJSON() {
    final Collection<DrillbitInfo> drillbits = Sets.newTreeSet();
    final Collection<String> mismatchedVersions = Sets.newTreeSet();
    final DrillbitContext dbContext = work.getContext();
    final DrillbitEndpoint currentDrillbit = dbContext.getEndpoint();
    final String currentVersion = currentDrillbit.getVersion();
    final DrillConfig config = dbContext.getConfig();
    final boolean userEncryptionEnabled = config.getBoolean(ExecConstants.USER_ENCRYPTION_SASL_ENABLED) || config.getBoolean(ExecConstants.USER_SSL_ENABLED);
    final boolean bitEncryptionEnabled = config.getBoolean(ExecConstants.BIT_ENCRYPTION_SASL_ENABLED);
    OptionManager optionManager = work.getContext().getOptionManager();
    final boolean isUserLoggedIn = AuthDynamicFeature.isUserLoggedIn(sc);
    final boolean shouldShowAdminInfo = isUserLoggedIn && ((DrillUserPrincipal) sc.getUserPrincipal()).isAdminUser();
    for (DrillbitEndpoint endpoint : work.getContext().getAvailableBits()) {
        final DrillbitInfo drillbit = new DrillbitInfo(endpoint, isDrillbitsTheSame(currentDrillbit, endpoint), currentVersion.equals(endpoint.getVersion()));
        if (!drillbit.isVersionMatch()) {
            mismatchedVersions.add(drillbit.getVersion());
        }
        drillbits.add(drillbit);
    }
    // For all other cases the user info need-not or should-not be displayed
    if (shouldShowAdminInfo) {
        final String processUser = ImpersonationUtil.getProcessUserName();
        final String processUserGroups = Joiner.on(", ").join(ImpersonationUtil.getProcessUserGroupNames());
        String adminUsers = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
        String adminUserGroups = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
        logger.debug("Admin info: user: " + adminUsers + " user group: " + adminUserGroups + " userLoggedIn " + isUserLoggedIn + " shouldShowAdminInfo: " + shouldShowAdminInfo);
        return new ClusterInfo(drillbits, currentVersion, mismatchedVersions, userEncryptionEnabled, bitEncryptionEnabled, shouldShowAdminInfo, QueueInfo.build(dbContext.getResourceManager()), processUser, processUserGroups, adminUsers, adminUserGroups, authEnabled.get());
    }
    return new ClusterInfo(drillbits, currentVersion, mismatchedVersions, userEncryptionEnabled, bitEncryptionEnabled, shouldShowAdminInfo, QueueInfo.build(dbContext.getResourceManager()), authEnabled.get());
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) DrillConfig(org.apache.drill.common.config.DrillConfig) OptionManager(org.apache.drill.exec.server.options.OptionManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class QueryTestUtil method restoreScalarReplacementOption.

/**
 * Restore the original scalar replacement option returned from
 * setupScalarReplacementOption().
 *
 * <p>This also flushes the compiled code cache.
 *
 * @param drillbit the drillbit
 * @param srOption the scalar replacement option value to use
 */
public static void restoreScalarReplacementOption(final Drillbit drillbit, final String srOption) {
    @SuppressWarnings("resource") final DrillbitContext drillbitContext = drillbit.getContext();
    @SuppressWarnings("resource") final OptionManager optionManager = drillbitContext.getOptionManager();
    optionManager.setLocalOption(ClassTransformer.SCALAR_REPLACEMENT_OPTION, srOption);
    // flush the code cache
    drillbitContext.getCompiler().flushCache();
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) OptionManager(org.apache.drill.exec.server.options.OptionManager) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager)

Aggregations

DrillbitContext (org.apache.drill.exec.server.DrillbitContext)137 Test (org.junit.Test)96 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)86 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)80 UserClientConnection (org.apache.drill.exec.rpc.UserClientConnection)78 FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)77 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)72 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)72 SimpleRootExec (org.apache.drill.exec.physical.impl.SimpleRootExec)44 OperatorTest (org.apache.drill.categories.OperatorTest)39 ExecTest (org.apache.drill.exec.ExecTest)35 SchemaPath (org.apache.drill.common.expression.SchemaPath)32 DrillConfig (org.apache.drill.common.config.DrillConfig)28 ValueVector (org.apache.drill.exec.vector.ValueVector)17 Ignore (org.junit.Ignore)14 IntVector (org.apache.drill.exec.vector.IntVector)13 SecurityTest (org.apache.drill.categories.SecurityTest)12 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)12 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)12 SystemOptionManager (org.apache.drill.exec.server.options.SystemOptionManager)12