public static IMetaStoreClient getHiveMetastoreClient(HiveConf hiveConf)
    throws MetaException, IOException {

    if (!HiveConf.getBoolVar(hiveConf, HiveConf.ConfVars.METASTORE_CLIENT_CACHE_ENABLED)){
      // If cache is disabled, don't use it.
      return HiveClientCache.getNonCachedHiveMetastoreClient(hiveConf);
    }

    // Singleton behaviour: create the cache instance if required.
    if (hiveClientCache == null) {
      synchronized (IMetaStoreClient.class) {
        if (hiveClientCache == null) {
          hiveClientCache = new HiveClientCache(hiveConf);
        }
      }
    }
    try {
      return hiveClientCache.get(hiveConf);
    } catch (LoginException e) {
      throw new IOException("Couldn't create hiveMetaStoreClient, Error getting UGI for user", e);
    }
  }
Get or create a hive client depending on whether it exits in cache or not
@param hiveConf The hive configuration
@return the client
@throws MetaException When HiveMetaStoreClient couldn't be created
@throws IOException
metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreUtils.java