commit a57284c03aec6151b23319c8aca7307ff5ae6c02 Author: thiruvel Date: Fri Feb 27 16:58:34 2015 -0800 HIVE-8696: HCatClientHMSImpl doesn't use a Retrying-HiveMetastoreClient diff --git a/hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HiveClientCache.java b/hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HiveClientCache.java index 11feaf2..aa95e41 100644 --- a/hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HiveClientCache.java +++ b/hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HiveClientCache.java @@ -79,7 +79,7 @@ private int getThreadId() { } public static IMetaStoreClient getNonCachedHiveClient(HiveConf hiveConf) throws MetaException { - return new HiveMetaStoreClient(hiveConf); + return RetryingMetaStoreClient.getProxy(hiveConf, HiveMetaStoreClient.class.getName()); } public HiveClientCache(HiveConf hiveConf) { @@ -219,7 +219,11 @@ private ICacheableMetaStoreClient getOrCreate(final HiveClientCacheKey cacheKey) return hiveCache.get(cacheKey, new Callable() { @Override public ICacheableMetaStoreClient call() throws MetaException { - return new CacheableHiveMetaStoreClient(cacheKey.getHiveConf(), timeout); + return + (ICacheableMetaStoreClient) RetryingMetaStoreClient.getProxy(cacheKey.getHiveConf(), + new Class[]{HiveConf.class, Integer.class}, + new Object[]{cacheKey.getHiveConf(), timeout}, + CacheableHiveMetaStoreClient.class.getName()); } }); } catch (ExecutionException e) { diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java index d04890b..cf6b6f4 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java @@ -54,7 +54,19 @@ private boolean localMetaStore; protected RetryingMetaStoreClient(HiveConf hiveConf, HiveMetaHookLoader hookLoader, - Class msClientClass) throws MetaException { + Class msClientClass) + throws MetaException { + + this(hiveConf, + new Class[] { HiveConf.class, HiveMetaHookLoader.class }, + new Object[] {hiveConf, hookLoader}, + msClientClass); + } + + protected RetryingMetaStoreClient(HiveConf hiveConf, Class[] constructorArgTypes, + Object[] constructorArgs, + Class msClientClass) + throws MetaException { this.retryLimit = hiveConf.getIntVar(HiveConf.ConfVars.METASTORETHRIFTFAILURERETRIES); this.retryDelaySeconds = hiveConf.getIntVar(HiveConf.ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY); @@ -65,18 +77,34 @@ protected RetryingMetaStoreClient(HiveConf hiveConf, HiveMetaHookLoader hookLoad localMetaStore = (msUri == null) || msUri.trim().isEmpty(); reloginExpiringKeytabUser(); - this.base = (IMetaStoreClient) MetaStoreUtils.newInstance(msClientClass, new Class[] { - HiveConf.class, HiveMetaHookLoader.class}, new Object[] {hiveConf, hookLoader}); + this.base = (IMetaStoreClient) MetaStoreUtils.newInstance(msClientClass, constructorArgTypes, constructorArgs); } public static IMetaStoreClient getProxy(HiveConf hiveConf, HiveMetaHookLoader hookLoader, - String mscClassName) throws MetaException { + String mscClassName) throws MetaException { + return getProxy(hiveConf, + new Class[]{HiveConf.class, HiveMetaHookLoader.class}, + new Object[]{hiveConf, hookLoader}, + mscClassName + ); + } + public static IMetaStoreClient getProxy(HiveConf hiveConf, String mscClassName) throws MetaException { + return getProxy(hiveConf, + new Class[]{HiveConf.class}, + new Object[]{hiveConf}, + mscClassName + ); + } + + public static IMetaStoreClient getProxy(HiveConf hiveConf, Class[] constructorArgTypes, + Object[] constructorArgs, + String mscClassName) throws MetaException { Class baseClass = (Class) MetaStoreUtils.getClass(mscClassName); - RetryingMetaStoreClient handler = new RetryingMetaStoreClient(hiveConf, hookLoader, baseClass); - + RetryingMetaStoreClient handler = + new RetryingMetaStoreClient(hiveConf, constructorArgTypes, constructorArgs, baseClass); return (IMetaStoreClient) Proxy.newProxyInstance(RetryingMetaStoreClient.class.getClassLoader(), baseClass.getInterfaces(), handler); }