Search in sources :

Example 1 with PhoenixStoragePluginConfig

use of org.apache.drill.exec.store.phoenix.PhoenixStoragePluginConfig in project drill by apache.

the class SecuredPhoenixBaseTest method startSecuredDrillCluster.

private static void startSecuredDrillCluster() throws Exception {
    logFixture = LogFixture.builder().toConsole().logger(QueryServerEnvironment.class, CURRENT_LOG_LEVEL).logger(SecuredPhoenixBaseTest.class, CURRENT_LOG_LEVEL).logger(KerberosFactory.class, CURRENT_LOG_LEVEL).logger(Krb5LoginModule.class, CURRENT_LOG_LEVEL).logger(QueryServer.class, CURRENT_LOG_LEVEL).logger(ServerAuthenticationHandler.class, CURRENT_LOG_LEVEL).build();
    Map.Entry<String, File> user1 = environment.getUser(1);
    Map.Entry<String, File> user2 = environment.getUser(2);
    Map.Entry<String, File> user3 = environment.getUser(3);
    // until DirTestWatcher ClassRule is implemented for JUnit5
    dirTestWatcher.start(SecuredPhoenixTestSuite.class);
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.USER_AUTHENTICATION_ENABLED, true).configProperty(ExecConstants.USER_AUTHENTICATOR_IMPL, UserAuthenticatorTestImpl.TYPE).configNonStringProperty(ExecConstants.AUTHENTICATION_MECHANISMS, Lists.newArrayList("kerberos")).configProperty(ExecConstants.IMPERSONATION_ENABLED, true).configProperty(ExecConstants.BIT_AUTHENTICATION_ENABLED, true).configProperty(ExecConstants.BIT_AUTHENTICATION_MECHANISM, "kerberos").configProperty(ExecConstants.SERVICE_PRINCIPAL, HBaseKerberosUtils.getPrincipalForTesting()).configProperty(ExecConstants.SERVICE_KEYTAB_LOCATION, environment.getServiceKeytab().getAbsolutePath()).configClientProperty(DrillProperties.SERVICE_PRINCIPAL, HBaseKerberosUtils.getPrincipalForTesting()).configClientProperty(DrillProperties.USER, user1.getKey()).configClientProperty(DrillProperties.KEYTAB, user1.getValue().getAbsolutePath());
    startCluster(builder);
    Properties user2ClientProperties = new Properties();
    user2ClientProperties.setProperty(DrillProperties.SERVICE_PRINCIPAL, HBaseKerberosUtils.getPrincipalForTesting());
    user2ClientProperties.setProperty(DrillProperties.USER, user2.getKey());
    user2ClientProperties.setProperty(DrillProperties.KEYTAB, user2.getValue().getAbsolutePath());
    cluster.addClientFixture(user2ClientProperties);
    Properties user3ClientProperties = new Properties();
    user3ClientProperties.setProperty(DrillProperties.SERVICE_PRINCIPAL, HBaseKerberosUtils.getPrincipalForTesting());
    user3ClientProperties.setProperty(DrillProperties.USER, user3.getKey());
    user3ClientProperties.setProperty(DrillProperties.KEYTAB, user3.getValue().getAbsolutePath());
    cluster.addClientFixture(user3ClientProperties);
    Map<String, Object> phoenixProps = new HashMap<>();
    phoenixProps.put("phoenix.query.timeoutMs", 90000);
    phoenixProps.put("phoenix.query.keepAliveMs", "30000");
    phoenixProps.put("phoenix.queryserver.withRemoteUserExtractor", true);
    StoragePluginRegistry registry = cluster.drillbit().getContext().getStorage();
    final String doAsUrl = String.format(getUrlTemplate(), "$user");
    logger.debug("Phoenix Query Server URL: {}", environment.getPqsUrl());
    PhoenixStoragePluginConfig config = new PhoenixStoragePluginConfig(null, 0, null, null, doAsUrl, null, phoenixProps);
    config.setEnabled(true);
    registry.put(PhoenixStoragePluginConfig.NAME + "123", config);
}
Also used : PhoenixStoragePluginConfig(org.apache.drill.exec.store.phoenix.PhoenixStoragePluginConfig) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) HashMap(java.util.HashMap) KerberosFactory(org.apache.drill.exec.rpc.security.kerberos.KerberosFactory) QueryServer(org.apache.phoenix.queryserver.server.QueryServer) SecuredPhoenixTestSuite.initPhoenixQueryServer(org.apache.drill.exec.store.phoenix.secured.SecuredPhoenixTestSuite.initPhoenixQueryServer) DrillProperties(org.apache.drill.common.config.DrillProperties) Properties(java.util.Properties) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 DrillProperties (org.apache.drill.common.config.DrillProperties)1 KerberosFactory (org.apache.drill.exec.rpc.security.kerberos.KerberosFactory)1 StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)1 PhoenixStoragePluginConfig (org.apache.drill.exec.store.phoenix.PhoenixStoragePluginConfig)1 SecuredPhoenixTestSuite.initPhoenixQueryServer (org.apache.drill.exec.store.phoenix.secured.SecuredPhoenixTestSuite.initPhoenixQueryServer)1 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)1 QueryServer (org.apache.phoenix.queryserver.server.QueryServer)1