/** * Make a call to hive meta store and see if the client is still usable. Some calls where the user provides * invalid data renders the client unusable for future use (example: create a table with very long table name) * @return */ @Deprecated public boolean isOpen() { try { // Look for an unlikely database name and see if either MetaException or TException is thrown super.getDatabases("NonExistentDatabaseUsedForHealthCheck"); } catch (TException e) { return false; } return true; }
/** * Make a call to hive meta store and see if the client is still usable. Some calls where the user provides * invalid data renders the client unusable for future use (example: create a table with very long table name) * @return */ @Deprecated public boolean isOpen() { try { // Look for an unlikely database name and see if either MetaException or TException is thrown super.getDatabases("NonExistentDatabaseUsedForHealthCheck"); } catch (TException e) { return false; } return true; }
@Override public List<String> getDatabases(String databasePattern) throws TException { return getDatabases(getDefaultCatalog(conf), databasePattern); }
protected void testFilterForDb(boolean filterAtServer) throws Exception { // Skip this call when testing filter hook at HMS server because HMS server calls authorization // API for getDatabase(), and does not call filter hook if (!filterAtServer) { try { assertNotNull(client.getDatabase(DBNAME1)); fail("getDatabase() should fail with blocking mode"); } catch (NoSuchObjectException e) { // Excepted } } assertEquals(0, client.getDatabases("*").size()); assertEquals(0, client.getAllDatabases().size()); assertEquals(0, client.getDatabases(DBNAME1).size()); }
/** * The default configuration should be disable filtering at HMS server * Disable the HMS client side filtering in order to see HMS server filtering behavior * @throws Exception */ @Test public void testHMSServerWithoutFilter() throws Exception { MetastoreConf.setBoolVar(conf, ConfVars.METASTORE_CLIENT_FILTER_ENABLED, false); DBNAME1 = "db_testHMSServerWithoutFilter_1"; DBNAME2 = "db_testHMSServerWithoutFilter_2"; creatEnv(conf); assertNotNull(client.getTable(DBNAME1, TAB1)); assertEquals(2, client.getTables(DBNAME1, "*").size()); assertEquals(2, client.getAllTables(DBNAME1).size()); assertEquals(1, client.getTables(DBNAME1, TAB2).size()); assertEquals(0, client.getAllTables(DBNAME2).size()); assertNotNull(client.getDatabase(DBNAME1)); assertEquals(2, client.getDatabases("*testHMSServerWithoutFilter*").size()); assertEquals(1, client.getDatabases(DBNAME1).size()); assertNotNull(client.getPartition(DBNAME1, TAB2, "name=value1")); assertEquals(1, client.getPartitionsByNames(DBNAME1, TAB2, Lists.newArrayList("name=value1")).size()); }
/** * Disable filtering at HMS client * By default, the HMS server side filtering is diabled, so we can see HMS client filtering behavior * @throws Exception */ @Test public void testHMSClientWithoutFilter() throws Exception { MetastoreConf.setBoolVar(conf, ConfVars.METASTORE_CLIENT_FILTER_ENABLED, false); DBNAME1 = "db_testHMSClientWithoutFilter_1"; DBNAME2 = "db_testHMSClientWithoutFilter_2"; creatEnv(conf); assertNotNull(client.getTable(DBNAME1, TAB1)); assertEquals(2, client.getTables(DBNAME1, "*").size()); assertEquals(2, client.getAllTables(DBNAME1).size()); assertEquals(1, client.getTables(DBNAME1, TAB2).size()); assertEquals(0, client.getAllTables(DBNAME2).size()); assertNotNull(client.getDatabase(DBNAME1)); assertEquals(2, client.getDatabases("*testHMSClientWithoutFilter*").size()); assertEquals(1, client.getDatabases(DBNAME1).size()); assertNotNull(client.getPartition(DBNAME1, TAB2, "name=value1")); assertEquals(1, client.getPartitionsByNames(DBNAME1, TAB2, Lists.newArrayList("name=value1")).size()); }
warehouse.getDatabasePath(db2).toString(), db2.getLocationUri()); List<String> dbs = client.getDatabases(".*");
/** * Make a call to hive meta store and see if the client is still usable. Some calls where the user provides * invalid data renders the client unusable for future use (example: create a table with very long table name) * @return */ public boolean isOpen() { try { // Look for an unlikely database name and see if either MetaException or TException is thrown super.getDatabases("NonExistentDatabaseUsedForHealthCheck"); } catch (TException e) { return false; } return true; }
/** * Make a call to hive meta store and see if the client is still usable. Some calls where the user provides * invalid data renders the client unusable for future use (example: create a table with very long table name) * @return */ public boolean isOpen() { try { // Look for an unlikely database name and see if either MetaException or TException is thrown super.getDatabases("NonExistentDatabaseUsedForHealthCheck"); } catch (TException e) { return false; } return true; }
/** * Make a call to hive meta store and see if the client is still usable. Some calls where the user provides * invalid data renders the client unusable for future use (example: create a table with very long table name) * @return */ public boolean isOpen() { try { // Look for an unlikely database name and see if either MetaException or TException is thrown super.getDatabases("NonExistentDatabaseUsedForHealthCheck"); } catch (TException e) { return false; } return true; }
/** * Make a call to hive meta store and see if the client is still usable. Some calls where the user provides * invalid data renders the client unusable for future use (example: create a table with very long table name) * @return */ @Deprecated public boolean isOpen() { try { // Look for an unlikely database name and see if either MetaException or TException is thrown super.getDatabases("NonExistentDatabaseUsedForHealthCheck"); } catch (TException e) { return false; } return true; }
@Override public List<String> getDatabases(String databasePattern) throws MetaException { return filterDatabases(super.getDatabases(databasePattern)); }