/** * Helper functions to convert IOException to MetaException */ public static FileSystem getFs(Path f, Configuration conf) throws MetaException { try { return f.getFileSystem(conf); } catch (IOException e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** * @param location * @return array of FileStatus objects corresponding to the files * making up the passed storage description */ public List<FileStatus> getFileStatusesForLocation(String location) throws MetaException { try { Path path = new Path(location); FileSystem fileSys = path.getFileSystem(conf); return FileUtils.getFileStatusRecurse(path, -1, fileSys); } catch (IOException ioe) { MetaStoreUtils.logAndThrowMetaException(ioe); } return null; }
@Override public List<String> getAllTables(String dbname) throws MetaException { try { return getAllTables(getDefaultCatalog(conf), dbname); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
public boolean isDir(Path f) throws MetaException { FileSystem fs; try { fs = getFs(f); FileStatus fstatus = fs.getFileStatus(f); if (!fstatus.isDir()) { return false; } } catch (FileNotFoundException e) { return false; } catch (IOException e) { MetaStoreUtils.logAndThrowMetaException(e); } return true; }
@Override public List<String> getTables(String dbname, String tablePattern) throws MetaException { try { return getTables(getDefaultCatalog(conf), dbname, tablePattern); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
public boolean mkdirs(Path f) throws MetaException { FileSystem fs; try { fs = getFs(f); return FileUtils.mkdir(fs, f); } catch (IOException e) { MetaStoreUtils.logAndThrowMetaException(e); } return false; }
@Override public List<TableMeta> getTableMeta(String dbPatterns, String tablePatterns, List<String> tableTypes) throws MetaException { try { return getTableMeta(getDefaultCatalog(conf), dbPatterns, tablePatterns, tableTypes); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
@Override public List<String> getTables(String dbname, String tablePattern, TableType tableType) throws MetaException { try { return getTables(getDefaultCatalog(conf), dbname, tablePattern, tableType); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** * @param db database * @param table table * @return array of FileStatus objects corresponding to the files making up the passed * unpartitioned table */ public List<FileStatus> getFileStatusesForUnpartitionedTable(Database db, Table table) throws MetaException { Path tablePath = getDnsPath(new Path(table.getSd().getLocation())); try { FileSystem fileSys = tablePath.getFileSystem(conf); return FileUtils.getFileStatusRecurse(tablePath, -1, fileSys); } catch (IOException ioe) { MetaStoreUtils.logAndThrowMetaException(ioe); } return null; }
@Override public List<String> getMaterializedViewsForRewriting(String catName, String dbname) throws MetaException { try { List<String> views = client.get_materialized_views_for_rewriting(prependCatalogToDbName(catName, dbname, conf)); return FilterUtils.filterTableNamesIfEnabled(isClientFilterEnabled, filterHook, catName, dbname, views); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
public boolean renameDir(Path sourcePath, Path destPath, boolean needCmRecycle) throws MetaException { try { if (needCmRecycle) { // Copy the source files to cmroot. As the client will move the source files to another // location, we should make a copy of the files to cmroot instead of moving it. cm.recycle(sourcePath, RecycleType.COPY, true); } FileSystem srcFs = getFs(sourcePath); FileSystem destFs = getFs(destPath); return FileUtils.rename(srcFs, destFs, sourcePath, destPath); } catch (Exception ex) { MetaStoreUtils.logAndThrowMetaException(ex); } return false; }
/** {@inheritDoc} */ @Override public List<String> getAllDatabases() throws MetaException { try { return filterHook.filterDatabases(client.get_all_databases()); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** {@inheritDoc} */ @Override public List<String> getTables(String dbname, String tablePattern) throws MetaException { try { return filterHook.filterTableNames(null, dbname, client.get_tables(dbname, tablePattern)); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** {@inheritDoc} */ @Override public List<String> getMaterializedViewsForRewriting(String dbname) throws MetaException { try { return filterHook.filterTableNames(null, dbname, client.get_materialized_views_for_rewriting(dbname)); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** {@inheritDoc} */ @Override public List<String> getDatabases(String databasePattern) throws MetaException { try { return filterHook.filterDatabases(client.get_databases(databasePattern)); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
@Override public List<TableMeta> getTableMeta(String dbPatterns, String tablePatterns, List<String> tableTypes) throws MetaException { try { return filterNames(client.get_table_meta(dbPatterns, tablePatterns, tableTypes)); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** {@inheritDoc} */ @Override public List<String> getAllTables(String dbname) throws MetaException { try { return filterHook.filterTableNames(null, dbname, client.get_all_tables(dbname)); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
/** {@inheritDoc} */ @Override public List<String> getTables(String dbname, String tablePattern, TableType tableType) throws MetaException { try { return filterHook.filterTableNames(null, dbname, client.get_tables_by_type(dbname, tablePattern, tableType.toString())); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } return null; }
@Override public boolean grant_privileges(final PrivilegeBag privileges) throws TException { incrementCounter("grant_privileges"); firePreEvent(new PreAuthorizationCallEvent(this)); Boolean ret; try { ret = getMS().grantPrivileges(privileges); } catch (MetaException e) { throw e; } catch (InvalidObjectException | NoSuchObjectException e) { ret = false; MetaStoreUtils.logAndThrowMetaException(e); } catch (Exception e) { throw new TException(e); } return ret; }
public boolean revoke_privileges(final PrivilegeBag privileges, boolean grantOption) throws TException { incrementCounter("revoke_privileges"); firePreEvent(new PreAuthorizationCallEvent(this)); Boolean ret; try { ret = getMS().revokePrivileges(privileges, grantOption); } catch (MetaException e) { throw e; } catch (InvalidObjectException | NoSuchObjectException e) { ret = false; MetaStoreUtils.logAndThrowMetaException(e); } catch (Exception e) { throw new TException(e); } return ret; }