@Ignore("hangs indefinitely") @Test public void testHMSCBreakability() throws IOException, MetaException, LoginException, TException, AlreadyExistsException, InvalidObjectException, NoSuchObjectException, InterruptedException { LocalMetaServer metaServer = new LocalMetaServer(); metaServer.start(); final HiveClientCache cache = new HiveClientCache(1000); HiveClientCache.CacheableHiveMetaStoreClient client = (HiveClientCache.CacheableHiveMetaStoreClient) cache.get(metaServer.getHiveConf()); assertTrue(client.isOpen()); final String DB_NAME = "test_db"; final String LONG_TABLE_NAME = "long_table_name_" + new BigInteger(200, new Random()).toString(2); try { client.dropTable(DB_NAME, LONG_TABLE_NAME); } catch (Exception e) { } try { client.dropDatabase(DB_NAME); } catch (Exception e) { } client.createDatabase(new Database(DB_NAME, "", null, null)); List<FieldSchema> fields = new ArrayList<FieldSchema>(); fields.add(new FieldSchema("colname", serdeConstants.STRING_TYPE_NAME, "")); Table tbl = new Table(); tbl.setDbName(DB_NAME); tbl.setTableName(LONG_TABLE_NAME); StorageDescriptor sd = new StorageDescriptor(); sd.setCols(fields); tbl.setSd(sd); sd.setSerdeInfo(new SerDeInfo()); try { client.createTable(tbl); fail("Exception was expected while creating table with long name"); } catch (Exception e) { } assertFalse(client.isOpen()); metaServer.shutDown(); }
public HiveMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException, LoginException { final HiveClientCacheKey cacheKey = HiveClientCacheKey.fromHiveConf(hiveConf, getThreadId()); CacheableHiveMetaStoreClient hiveMetaStoreClient = null; synchronized (CACHE_TEARDOWN_LOCK) { hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } if (!hiveMetaStoreClient.isOpen()) { synchronized (CACHE_TEARDOWN_LOCK) { hiveCache.invalidate(cacheKey); hiveMetaStoreClient.close(); hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } } return hiveMetaStoreClient; }
HiveClientCache { public HiveMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException, LoginException { final HiveClientCacheKey cacheKey = HiveClientCacheKey.fromHiveConf(hiveConf, getThreadId()); CacheableHiveMetaStoreClient hiveMetaStoreClient = null; synchronized (CACHE_TEARDOWN_LOCK) { hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } if (!hiveMetaStoreClient.isOpen()) { synchronized (CACHE_TEARDOWN_LOCK) { hiveCache.invalidate(cacheKey); hiveMetaStoreClient.close(); hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } } return hiveMetaStoreClient; } }
HiveClientCache { public HiveMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException, LoginException { final HiveClientCacheKey cacheKey = HiveClientCacheKey.fromHiveConf(hiveConf, getThreadId()); CacheableHiveMetaStoreClient hiveMetaStoreClient = null; synchronized (CACHE_TEARDOWN_LOCK) { hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } if (!hiveMetaStoreClient.isOpen()) { synchronized (CACHE_TEARDOWN_LOCK) { hiveCache.invalidate(cacheKey); hiveMetaStoreClient.close(); hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } } return hiveMetaStoreClient; } HiveClientCache(HiveConf hiveConf);  HiveClientCache(final int timeout); }
HiveClientCache { public HiveMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException, LoginException { final HiveClientCacheKey cacheKey = HiveClientCacheKey.fromHiveConf(hiveConf, getThreadId()); CacheableHiveMetaStoreClient hiveMetaStoreClient = null; synchronized (CACHE_TEARDOWN_LOCK) { hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } if (!hiveMetaStoreClient.isOpen()) { synchronized (CACHE_TEARDOWN_LOCK) { hiveCache.invalidate(cacheKey); hiveMetaStoreClient.close(); hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } } return hiveMetaStoreClient; } HiveClientCache(HiveConf hiveConf);  HiveClientCache(final int timeout); static HiveMetaStoreClient getNonCachedHiveClient(HiveConf hiveConf); void cleanup(); HiveMetaStoreClient get(final HiveConf hiveConf); }
HiveClientCache { public HiveMetaStoreClient get(final HiveConf hiveConf) throws MetaException, IOException, LoginException { final HiveClientCacheKey cacheKey = HiveClientCacheKey.fromHiveConf(hiveConf, getThreadId()); CacheableHiveMetaStoreClient hiveMetaStoreClient = null; synchronized (CACHE_TEARDOWN_LOCK) { hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } if (!hiveMetaStoreClient.isOpen()) { synchronized (CACHE_TEARDOWN_LOCK) { hiveCache.invalidate(cacheKey); hiveMetaStoreClient.close(); hiveMetaStoreClient = getOrCreate(cacheKey); hiveMetaStoreClient.acquire(); } } return hiveMetaStoreClient; } HiveClientCache(HiveConf hiveConf);  HiveClientCache(final int timeout); static HiveMetaStoreClient getNonCachedHiveClient(HiveConf hiveConf); void cleanup(); HiveMetaStoreClient get(final HiveConf hiveConf); final static int DEFAULT_HIVE_CACHE_EXPIRY_TIME_SECONDS; }