PartitionTask(String dbName, String tblName, String authName, List<String> partNames) { this.dbName = safeIntern(dbName); this.tblName = safeIntern(tblName); this.authName = safeIntern(authName); this.partNames = partNames; }
DbTask(String dbName) { //Database names are case insensitive this.dbName = safeIntern(dbName.toLowerCase()); databaseCount.inc(); }
ObjectMapping(String authObject, String path) { Set<String> values = Collections.singleton(safeIntern(path)); objects = ImmutableMap.of(authObject, values); }
TableTask(Database db, List<String> tableNames) { dbName = safeIntern(db.getName()); this.tableNames = tableNames; }
String tableName = safeIntern(tbl.getTableName().toLowerCase()); String authzObject = (dbName + "." + tableName).intern(); List<String> tblPartNames = results.add(threadPool.submit(partTask)); String tblPath = safeIntern(pathFromURI(tbl.getSd().getLocation())); if (tblPath == null) { continue;
@Override ObjectMapping doTask() throws Exception { HMSClient c = null; try (HMSClient client = clientFactory.connect()) { c = client; Database db = client.getClient().getDatabase(dbName); if (!dbName.equalsIgnoreCase(db.getName())) { LOGGER.warn("Database name {} does not match {}", db.getName(), dbName); return emptyObjectMapping; } List<String> allTblStr = client.getClient().getAllTables(dbName); // Count total number of tables tableCount.inc(allTblStr.size()); for (int i = 0; i < allTblStr.size(); i += maxTablesPerCall) { List<String> tablesToFetch = allTblStr.subList(i, Math.min(i + maxTablesPerCall, allTblStr.size())); Callable<CallResult> tableTask = new TableTask(db, tablesToFetch); results.add(threadPool.submit(tableTask)); } String dbPath = safeIntern(pathFromURI(db.getLocationUri())); return (dbPath != null) ? new ObjectMapping(dbName, dbPath) : emptyObjectMapping; } catch (Exception e) { if (c != null) { c.invalidate(); } throw e; } } }