public synchronized void init(HiveConf hiveConf, Map<String, String> confOverlay) { // Null HiveConf is passed in jdbc driver side code since driver side is supposed to be // independent of conf object. Create new HiveConf object here in this case. if (hiveConf == null) { hiveConf = new HiveConf(); } // Set the specific parameters if needed if (confOverlay != null && !confOverlay.isEmpty()) { // apply overlay query specific settings, if any for (Map.Entry<String, String> confEntry : confOverlay.entrySet()) { try { hiveConf.set(confEntry.getKey(), confEntry.getValue()); } catch (IllegalArgumentException e) { throw new RuntimeException("Error applying statement specific settings", e); } } } cliService.init(hiveConf); cliService.start(); super.init(hiveConf); }
public FakeEmbeddedThriftBinaryCLIService(HiveConf hiveConf) { super(new CLIService(null, true), null); isEmbedded = true; cliService.init(hiveConf); cliService.start(); }
private CLIService getService(HiveConf conf) { conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory"); CLIService service = new CLIService(null, true); service.init(conf); service.start(); return service; } }
public CLIService getService() { HiveConf conf = new HiveConf(); conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory"); CLIService service = new CLIService(null, true); service.init(conf); service.start(); return service; } }
/** * Test setting {@link HiveConf.ConfVars}} config parameter * HIVE_SERVER2_ENABLE_DOAS for unsecure mode */ public void testDoAsSetting(){ HiveConf hconf = new HiveConf(); hconf .setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory"); assertTrue("default value of hive server2 doAs should be true", hconf.getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS)); CLIService cliService = new CLIService(null, true); cliService.init(hconf); ThriftCLIService tcliService = new ThriftBinaryCLIService(cliService, null); tcliService.init(hconf); TProcessorFactory procFactory = PlainSaslHelper.getPlainProcessorFactory(tcliService); assertEquals("doAs enabled processor for unsecure mode", procFactory.getProcessor(null).getClass(), TSetIpAddressProcessor.class); } }
@Test public void testSessionImpl() throws Exception { HiveConf hiveConf = new HiveConf(); hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER.getDefaultValue()); hiveConf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME, SampleHiveSessionImpl.class.getName()); hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, false); CLIService cliService = new CLIService(null, true); cliService.init(hiveConf); ThriftBinaryCLIService service = new ThriftBinaryCLIService(cliService, null); service.init(hiveConf); ThriftCLIServiceClient client = new ThriftCLIServiceClient(service); SessionHandle sessionHandle = null; sessionHandle = client.openSession("tom", "password"); assertEquals(SampleHiveSessionImpl.class.getName(), service.getHiveConf().getVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME)); HiveSession session = cliService.getSessionManager().getSession(sessionHandle); assertEquals(SampleHiveSessionImpl.MAGIC_RETURN_VALUE, session.getNoOperationTime()); client.closeSession(sessionHandle); }
@Test public void testSessionImplWithUGI() throws Exception { HiveConf hiveConf = new HiveConf(); hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER.getDefaultValue()); hiveConf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_WITH_UGI_CLASSNAME, SampleHiveSessionImplWithUGI.class.getName()); hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, true); CLIService cliService = new CLIService(null, true); cliService.init(hiveConf); ThriftBinaryCLIService service = new ThriftBinaryCLIService(cliService, null); service.init(hiveConf); ThriftCLIServiceClient client = new ThriftCLIServiceClient(service); SessionHandle sessionHandle = null; sessionHandle = client.openSession("tom", "password"); assertEquals(SampleHiveSessionImplWithUGI.class.getName(), service.getHiveConf().getVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_WITH_UGI_CLASSNAME)); HiveSession session = cliService.getSessionManager().getSession(sessionHandle); assertEquals(SampleHiveSessionImplWithUGI.MAGIC_RETURN_VALUE, session.getNoOperationTime()); client.closeSession(sessionHandle); }
@Override public synchronized void init(HiveConf hiveConf) { cliService.init(hiveConf); cliService.start(); super.init(hiveConf); }
@Override public synchronized void init(HiveConf hiveConf) { cliService.init(hiveConf); cliService.start(); super.init(hiveConf); }
public synchronized void init(HiveConf hiveConf, Map<String, String> confOverlay) { // Null HiveConf is passed in jdbc driver side code since driver side is supposed to be // independent of conf object. Create new HiveConf object here in this case. if (hiveConf == null) { hiveConf = new HiveConf(); } // Set the specific parameters if needed if (confOverlay != null && !confOverlay.isEmpty()) { // apply overlay query specific settings, if any for (Map.Entry<String, String> confEntry : confOverlay.entrySet()) { try { hiveConf.set(confEntry.getKey(), confEntry.getValue()); } catch (IllegalArgumentException e) { throw new RuntimeException("Error applying statement specific settings", e); } } } cliService.init(hiveConf); cliService.start(); super.init(hiveConf); }
@Override protected void startUp() throws Exception { LOG.info("Starting {}...", BaseHiveExploreService.class.getSimpleName()); setupSparkConf(); cliService.init(createHiveConf()); cliService.start(); metastoreClientsExecutorService.scheduleWithFixedDelay( new Runnable() { @Override public void run() { Reference<? extends Supplier<IMetaStoreClient>> ref = metastoreClientReferenceQueue.poll(); while (ref != null) { IMetaStoreClient client = metastoreClientReferences.remove(ref); if (client != null) { closeMetastoreClient(client); } ref = metastoreClientReferenceQueue.poll(); } } }, METASTORE_CLIENT_CLEANUP_PERIOD, METASTORE_CLIENT_CLEANUP_PERIOD, TimeUnit.SECONDS); // Schedule the cache cleanup scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { @Override public void run() { runCacheCleanup(); } }, cleanupJobSchedule, cleanupJobSchedule, TimeUnit.SECONDS ); }
@Override protected void startUp() throws Exception { LOG.info("Starting {}...", BaseHiveExploreService.class.getSimpleName()); setupSparkConf(); cliService.init(createHiveConf()); cliService.start(); metastoreClientsExecutorService.scheduleWithFixedDelay( new Runnable() { @Override public void run() { Reference<? extends Supplier<IMetaStoreClient>> ref = metastoreClientReferenceQueue.poll(); while (ref != null) { IMetaStoreClient client = metastoreClientReferences.remove(ref); if (client != null) { closeMetastoreClient(client); } ref = metastoreClientReferenceQueue.poll(); } } }, METASTORE_CLIENT_CLEANUP_PERIOD, METASTORE_CLIENT_CLEANUP_PERIOD, TimeUnit.SECONDS); // Schedule the cache cleanup scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { @Override public void run() { runCacheCleanup(); } }, cleanupJobSchedule, cleanupJobSchedule, TimeUnit.SECONDS ); }
@BeforeClass public void setup() throws Exception { /** * Test Setup - * Static test.jar containing ClassLoaderTestClass.class attached to DB1 * No static jar attached to 'default' DB * test2.jar containing ClassLoaderTestClass2.class added to session via addResource */ // Create test databases and tables LensServerTestUtil.createTestDatabaseResources(new String[]{DB1}, conf); conf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME, LensSessionImpl.class.getName()); conf.set(LensConfConstants.DATABASE_RESOURCE_DIR, "target/resources"); CLIService cliService = new CLIService(null); cliService.init(conf); sessionService = new HiveSessionService(cliService); sessionService.init(conf); UserConfigLoaderFactory.init(conf); cliService.start(); sessionService.start(); }
conf.setLong(LensConfConstants.SESSION_TIMEOUT_SECONDS, 1L); CLIService cliService = new CLIService(null); cliService.init(conf); HiveSessionService lensService = new HiveSessionService(cliService); lensService.init(conf);
conf.setInt(LensConfConstants.SESSION_EXPIRY_SERVICE_INTERVAL_IN_SECS, 1); CLIService cliService = new CLIService(null); cliService.init(conf); HiveSessionService lensService = new HiveSessionService(cliService); lensService.init(conf);