/** * This constructor is meant for Hive internal use only. * Please use getProxy(HiveConf conf, HiveMetaHookLoader hookLoader) for external purpose. */ public static IMetaStoreClient getProxy(Configuration hiveConf, Class<?>[] constructorArgTypes, Object[] constructorArgs, String mscClassName) throws MetaException { return getProxy(hiveConf, constructorArgTypes, constructorArgs, null, mscClassName); }
public static IMetaStoreClient getNonCachedHiveMetastoreClient(HiveConf hiveConf) throws MetaException { return RetryingMetaStoreClient.getProxy(hiveConf, true); }
public static IMetaStoreClient getNonCachedHiveMetastoreClient(HiveConf hiveConf) throws MetaException { return RetryingMetaStoreClient.getProxy(hiveConf, true); }
public static IMetaStoreClient getProxy(Configuration hiveConf, HiveMetaHookLoader hookLoader, ConcurrentHashMap<String, Long> metaCallTimeMap, String mscClassName, boolean allowEmbedded) throws MetaException { return getProxy(hiveConf, new Class[] {Configuration.class, HiveMetaHookLoader.class, Boolean.class}, new Object[] {hiveConf, hookLoader, allowEmbedded}, metaCallTimeMap, mscClassName ); }
public static IMetaStoreClient getProxy( Configuration hiveConf, boolean allowEmbedded) throws MetaException { return getProxy(hiveConf, new Class[]{Configuration.class, HiveMetaHookLoader.class, Boolean.class}, new Object[]{hiveConf, null, allowEmbedded}, null, HiveMetaStoreClient.class.getName() ); }
private IMetaStoreClient createMetaStoreClient() throws MetaException { HiveMetaHookLoader hookLoader = new HiveMetaHookLoader() { @Override public HiveMetaHook getHook(Table tbl) throws MetaException { if (tbl == null) { return null; } try { HiveStorageHandler storageHandler = HiveUtils.getStorageHandler(hiveConf, tbl.getParameters().get(META_TABLE_STORAGE)); return storageHandler == null ? null : storageHandler.getMetaHook(); } catch (HiveException e) { LOG.error(e.toString()); throw new MetaException("Failed to get storage handler: " + e); } } }; return RetryingMetaStoreClient.getProxy(hiveConf, hookLoader, HiveMetaStoreClient.class.getName()); }
@Override public ICacheableMetaStoreClient call() throws MetaException { // This is called from HCat, so always allow embedded metastore (as was the default). return (ICacheableMetaStoreClient) RetryingMetaStoreClient.getProxy(cacheKey.getHiveConf(), new Class<?>[]{HiveConf.class, Integer.class, Boolean.class}, new Object[]{cacheKey.getHiveConf(), timeout, true}, CacheableHiveMetaStoreClient.class.getName()); } });
@Override public ICacheableMetaStoreClient call() throws MetaException { // This is called from HCat, so always allow embedded metastore (as was the default). return (ICacheableMetaStoreClient) RetryingMetaStoreClient.getProxy(cacheKey.getHiveConf(), new Class<?>[]{HiveConf.class, Integer.class, Boolean.class}, new Object[]{cacheKey.getHiveConf(), timeout, true}, CacheableHiveMetaStoreClient.class.getName()); } });
/** * Creates a metastore client. Currently it creates only JDBC based client as * File based store support is removed * * @returns a Meta Store Client * @throws HiveMetaException * if a working client can't be created */ private IMetaStoreClient createMetaStoreClient(boolean allowEmbedded) throws MetaException { HiveMetaHookLoader hookLoader = new HiveMetaHookLoader() { @Override public HiveMetaHook getHook( org.apache.hadoop.hive.metastore.api.Table tbl) throws MetaException { HiveStorageHandler storageHandler = createStorageHandler(tbl); return storageHandler == null ? null : storageHandler.getMetaHook(); } }; if (conf.getBoolVar(ConfVars.METASTORE_FASTPATH)) { return new SessionHiveMetaStoreClient(conf, hookLoader, allowEmbedded); } else { return RetryingMetaStoreClient.getProxy(conf, hookLoader, metaCallTimeMap, SessionHiveMetaStoreClient.class.getName(), allowEmbedded); } }
private static IMetaStoreClient getHMS(HiveConf conf) { UserGroupInformation loggedInUser = null; try { loggedInUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { LOG.warn("Unable to get logged in user via UGI. err: {}", e.getMessage()); } boolean secureMode = loggedInUser != null && loggedInUser.hasKerberosCredentials(); if (secureMode) { MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.USE_THRIFT_SASL, true); } try { LOG.info("Creating metastore client for {}", "PreUpgradeTool"); return RetryingMetaStoreClient.getProxy(conf, true); } catch (MetaException e) { throw new RuntimeException("Error connecting to Hive Metastore URI: " + conf.getVar(HiveConf.ConfVars.METASTOREURIS) + ". " + e.getMessage(), e); } } /**
private static IMetaStoreClient getHMS(HiveConf conf) { UserGroupInformation loggedInUser = null; try { loggedInUser = UserGroupInformation.getLoginUser(); } catch (IOException e) { LOG.warn("Unable to get logged in user via UGI. err: {}", e.getMessage()); } boolean secureMode = loggedInUser != null && loggedInUser.hasKerberosCredentials(); if (secureMode) { conf.setBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL, true); } try { LOG.info("Creating metastore client for {}", "PreUpgradeTool"); /* I'd rather call return RetryingMetaStoreClient.getProxy(conf, true) which calls HiveMetaStoreClient(HiveConf, Boolean) which exists in (at least) 2.1.0.2.6.5.0-292 and later but not in 2.1.0.2.6.0.3-8 (the HDP 2.6 release) i.e. RetryingMetaStoreClient.getProxy(conf, true) is broken in 2.6.0*/ return RetryingMetaStoreClient.getProxy(conf, new Class[]{HiveConf.class, HiveMetaHookLoader.class, Boolean.class}, new Object[]{conf, getHookLoader(), Boolean.TRUE}, null, HiveMetaStoreClient.class.getName()); } catch (MetaException e) { throw new RuntimeException("Error connecting to Hive Metastore URI: " + conf.getVar(HiveConf.ConfVars.METASTOREURIS) + ". " + e.getMessage(), e); } }
return new SessionHiveMetaStoreClient(conf, hookLoader, allowEmbedded); } else { return RetryingMetaStoreClient.getProxy(conf, hookLoader, metaCallTimeMap, SessionHiveMetaStoreClient.class.getName(), allowEmbedded);
@Test public void testRetriableClientWithConnLifetime() throws Exception { Configuration newConf = MetastoreConf.newMetastoreConf(new Configuration(this.conf)); MetastoreConf.setTimeVar(newConf, ConfVars.CLIENT_SOCKET_LIFETIME, 4, TimeUnit.SECONDS); MetaStoreTestUtils.setConfForStandloneMode(newConf); long timeout = 5 * 1000; // Lets use a timeout more than the socket lifetime to simulate a reconnect // Test a normal retriable client IMetaStoreClient client = RetryingMetaStoreClient.getProxy(newConf, getHookLoader(), HiveMetaStoreClient.class.getName()); client.getAllDatabases(); client.close(); // Connect after the lifetime, there should not be any failures client = RetryingMetaStoreClient.getProxy(newConf, getHookLoader(), HiveMetaStoreClient.class.getName()); Thread.sleep(timeout); client.getAllDatabases(); client.close(); }
/** * This constructor is meant for Hive internal use only. * Please use getProxy(HiveConf hiveConf, HiveMetaHookLoader hookLoader) for external purpose. */ public static IMetaStoreClient getProxy(HiveConf hiveConf, Class<?>[] constructorArgTypes, Object[] constructorArgs, String mscClassName) throws MetaException { return getProxy(hiveConf, constructorArgTypes, constructorArgs, null, mscClassName); }
public static IMetaStoreClient getProxy(HiveConf hiveConf, HiveMetaHookLoader hookLoader, Map<String, Long> metaCallTimeMap, String mscClassName) throws MetaException { return getProxy(hiveConf, new Class[] {HiveConf.class, HiveMetaHookLoader.class}, new Object[] {hiveConf, hookLoader}, metaCallTimeMap, mscClassName ); }
/** * This constructor is meant for Hive internal use only. * Please use getProxy(HiveConf hiveConf, HiveMetaHookLoader hookLoader) for external purpose. */ public static IMetaStoreClient getProxy(HiveConf hiveConf, Class<?>[] constructorArgTypes, Object[] constructorArgs, String mscClassName) throws MetaException { return getProxy(hiveConf, constructorArgTypes, constructorArgs, null, mscClassName); }
public static IMetaStoreClient getProxy(HiveConf hiveConf, HiveMetaHookLoader hookLoader, String mscClassName) throws MetaException { return getProxy(hiveConf, hookLoader, null, mscClassName); }
public static IMetaStoreClient getProxy(HiveConf hiveConf) throws MetaException { return getProxy(hiveConf, new Class[]{HiveConf.class}, new Object[]{hiveConf}, null, HiveMetaStoreClient.class.getName() ); }
@Override public ICacheableMetaStoreClient call() throws MetaException { // This is called from HCat, so always allow embedded metastore (as was the default). return (ICacheableMetaStoreClient) RetryingMetaStoreClient.getProxy(cacheKey.getHiveConf(), new Class<?>[]{HiveConf.class, Integer.class, Boolean.class}, new Object[]{cacheKey.getHiveConf(), timeout, true}, CacheableHiveMetaStoreClient.class.getName()); } });
@Override public ICacheableMetaStoreClient call() throws MetaException { return (ICacheableMetaStoreClient) RetryingMetaStoreClient.getProxy(cacheKey.getHiveConf(), new Class<?>[]{HiveConf.class, Integer.class}, new Object[]{cacheKey.getHiveConf(), timeout}, CacheableHiveMetaStoreClient.class.getName()); } });