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;
}
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();
}
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;
}
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());
}
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();
}
Aggregations