From 7e34a285868b61716d081978ac29b322ce9640d5 Mon Sep 17 00:00:00 2001 From: Alexander Kolbasov Date: Thu, 20 Sep 2018 11:37:54 -0700 Subject: [PATCH 1/1] HIVE-20189: Separate metastore client code into its own module --- .../llap/daemon/impl/FunctionLocalizer.java | 1 - metastore/pom.xml | 5 + standalone-metastore/metastore-client/pom.xml | 42 +++ .../hive/metastore/HiveMetaStoreClient.java | 318 +++++++++--------- .../metastore/RetryingMetaStoreClient.java | 0 standalone-metastore/metastore-server/pom.xml | 7 +- standalone-metastore/pom.xml | 1 + 7 files changed, 213 insertions(+), 161 deletions(-) create mode 100644 standalone-metastore/metastore-client/pom.xml rename standalone-metastore/{metastore-common => metastore-client}/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (89%) rename standalone-metastore/{metastore-common => metastore-client}/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java (100%) diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/FunctionLocalizer.java b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/FunctionLocalizer.java index 2a6ef3a246..b4ae035b73 100644 --- a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/FunctionLocalizer.java +++ b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/FunctionLocalizer.java @@ -33,7 +33,6 @@ import org.apache.hadoop.hive.metastore.api.Function; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.ResourceUri; -import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.ql.exec.FunctionRegistry; import org.apache.hadoop.hive.ql.exec.FunctionTask; import org.apache.hadoop.hive.ql.exec.Utilities; diff --git a/metastore/pom.xml b/metastore/pom.xml index a75ab97ae7..7446edf063 100644 --- a/metastore/pom.xml +++ b/metastore/pom.xml @@ -48,6 +48,11 @@ org.apache.hive hive-standalone-metastore-common ${project.version} + + + org.apache.hive + hive-standalone-metastore-client + ${project.version} javolution diff --git a/standalone-metastore/metastore-client/pom.xml b/standalone-metastore/metastore-client/pom.xml new file mode 100644 index 0000000000..f30872a7eb --- /dev/null +++ b/standalone-metastore/metastore-client/pom.xml @@ -0,0 +1,42 @@ + + + + hive-standalone-metastore + org.apache.hive + 4.0.0-SNAPSHOT + + 4.0.0 + + hive-standalone-metastore-client + Hive Metastore Client + + + + org.apache.hive + hive-standalone-metastore-common + 4.0.0-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + none + + single + + + + + + + + \ No newline at end of file diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java similarity index 89% rename from standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java rename to standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index a2ec09f715..3bc683455d 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -487,7 +487,7 @@ public void alter_table(String catName, String dbName, String tbl_name, Table ne @Override public void renamePartition(final String dbname, final String tableName, final List part_vals, final Partition newPart) throws TException { - renamePartition(getDefaultCatalog(conf), dbname, tableName, part_vals, newPart, null); + renamePartition(MetaStoreUtils.getDefaultCatalog(conf), dbname, tableName, part_vals, newPart, null); } @Override @@ -740,7 +740,7 @@ public Partition add_partition(Partition new_part) throws TException { public Partition add_partition(Partition new_part, EnvironmentContext envContext) throws TException { if (new_part != null && !new_part.isSetCatName()) { - new_part.setCatName(getDefaultCatalog(conf)); + new_part.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } Partition p = client.add_partition_with_environment_context(new_part, envContext); return deepCopy(p); @@ -760,7 +760,7 @@ public int add_partitions(List new_parts) throws TException { throw new MetaException("Partitions cannot be null."); } if (new_parts != null && !new_parts.isEmpty() && !new_parts.get(0).isSetCatName()) { - final String defaultCat = getDefaultCatalog(conf); + final String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); new_parts.forEach(p -> p.setCatName(defaultCat)); } return client.add_partitions(new_parts); @@ -778,12 +778,12 @@ public int add_partitions(List new_parts) throws TException { Partition part = parts.get(0); // Have to set it for each partition too if (!part.isSetCatName()) { - final String defaultCat = getDefaultCatalog(conf); + final String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); parts.forEach(p -> p.setCatName(defaultCat)); } AddPartitionsRequest req = new AddPartitionsRequest( part.getDbName(), part.getTableName(), parts, ifNotExists); - req.setCatName(part.isSetCatName() ? part.getCatName() : getDefaultCatalog(conf)); + req.setCatName(part.isSetCatName() ? part.getCatName() : MetaStoreUtils.getDefaultCatalog(conf)); req.setNeedResult(needResults); AddPartitionsResult result = client.add_partitions_req(req); return needResults ? filterHook.filterPartitions(result.getPartitions()) : null; @@ -795,7 +795,7 @@ public int add_partitions_pspec(PartitionSpecProxy partitionSpec) throws TExcept throw new MetaException("PartitionSpec cannot be null."); } if (partitionSpec.getCatName() == null) { - partitionSpec.setCatName(getDefaultCatalog(conf)); + partitionSpec.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.add_partitions_pspec(partitionSpec.toPartitionSpec()); } @@ -803,19 +803,19 @@ public int add_partitions_pspec(PartitionSpecProxy partitionSpec) throws TExcept @Override public Partition appendPartition(String db_name, String table_name, List part_vals) throws TException { - return appendPartition(getDefaultCatalog(conf), db_name, table_name, part_vals); + return appendPartition(MetaStoreUtils.getDefaultCatalog(conf), db_name, table_name, part_vals); } @Override public Partition appendPartition(String dbName, String tableName, String partName) throws TException { - return appendPartition(getDefaultCatalog(conf), dbName, tableName, partName); + return appendPartition(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, partName); } @Override public Partition appendPartition(String catName, String dbName, String tableName, String name) throws TException { - Partition p = client.append_partition_by_name(prependCatalogToDbName( + Partition p = client.append_partition_by_name(MetaStoreUtils.prependCatalogToDbName( catName, dbName, conf), tableName, name); return deepCopy(p); } @@ -823,7 +823,7 @@ public Partition appendPartition(String catName, String dbName, String tableName @Override public Partition appendPartition(String catName, String dbName, String tableName, List partVals) throws TException { - Partition p = client.append_partition(prependCatalogToDbName( + Partition p = client.append_partition(MetaStoreUtils.prependCatalogToDbName( catName, dbName, conf), tableName, partVals); return deepCopy(p); } @@ -831,7 +831,7 @@ public Partition appendPartition(String catName, String dbName, String tableName @Deprecated public Partition appendPartition(String dbName, String tableName, List partVals, EnvironmentContext ec) throws TException { - return client.append_partition_with_environment_context(prependCatalogToDbName(dbName, conf), + return client.append_partition_with_environment_context(MetaStoreUtils.prependCatalogToDbName(dbName, conf), tableName, partVals, ec).deepCopy(); } @@ -846,16 +846,16 @@ public Partition appendPartition(String dbName, String tableName, List p public Partition exchange_partition(Map partitionSpecs, String sourceDb, String sourceTable, String destDb, String destinationTableName) throws TException { - return exchange_partition(partitionSpecs, getDefaultCatalog(conf), sourceDb, sourceTable, - getDefaultCatalog(conf), destDb, destinationTableName); + return exchange_partition(partitionSpecs, MetaStoreUtils.getDefaultCatalog(conf), sourceDb, sourceTable, + MetaStoreUtils.getDefaultCatalog(conf), destDb, destinationTableName); } @Override public Partition exchange_partition(Map partitionSpecs, String sourceCat, String sourceDb, String sourceTable, String destCat, String destDb, String destTableName) throws TException { - return client.exchange_partition(partitionSpecs, prependCatalogToDbName(sourceCat, sourceDb, conf), - sourceTable, prependCatalogToDbName(destCat, destDb, conf), destTableName); + return client.exchange_partition(partitionSpecs, MetaStoreUtils.prependCatalogToDbName(sourceCat, sourceDb, conf), + sourceTable, MetaStoreUtils.prependCatalogToDbName(destCat, destDb, conf), destTableName); } /** @@ -869,8 +869,8 @@ public Partition exchange_partition(Map partitionSpecs, String s public List exchange_partitions(Map partitionSpecs, String sourceDb, String sourceTable, String destDb, String destinationTableName) throws TException { - return exchange_partitions(partitionSpecs, getDefaultCatalog(conf), sourceDb, sourceTable, - getDefaultCatalog(conf), destDb, destinationTableName); + return exchange_partitions(partitionSpecs, MetaStoreUtils.getDefaultCatalog(conf), sourceDb, sourceTable, + MetaStoreUtils.getDefaultCatalog(conf), destDb, destinationTableName); } @Override @@ -878,7 +878,7 @@ public Partition exchange_partition(Map partitionSpecs, String s String dbName, String tableName, List partNames, List colNames, String validWriteIdList) throws NoSuchObjectException, MetaException, TException { - return getPartitionColumnStatistics(getDefaultCatalog(conf), dbName, tableName, + return getPartitionColumnStatistics(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, partNames, colNames, validWriteIdList); } @@ -898,7 +898,7 @@ public Partition exchange_partition(Map partitionSpecs, String s public AggrStats getAggrColStatsFor(String dbName, String tblName, List colNames, List partNames, String writeIdList) throws NoSuchObjectException, MetaException, TException { - return getAggrColStatsFor(getDefaultCatalog(conf), dbName, tblName, colNames, + return getAggrColStatsFor(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, colNames, partNames, writeIdList); } @Override @@ -919,8 +919,8 @@ public AggrStats getAggrColStatsFor(String catName, String dbName, String tblNam public List exchange_partitions(Map partitionSpecs, String sourceCat, String sourceDb, String sourceTable, String destCat, String destDb, String destTableName) throws TException { - return client.exchange_partitions(partitionSpecs, prependCatalogToDbName(sourceCat, sourceDb, conf), - sourceTable, prependCatalogToDbName(destCat, destDb, conf), destTableName); + return client.exchange_partitions(partitionSpecs, MetaStoreUtils.prependCatalogToDbName(sourceCat, sourceDb, conf), + sourceTable, MetaStoreUtils.prependCatalogToDbName(destCat, destDb, conf), destTableName); } @Override @@ -942,7 +942,7 @@ public void validatePartitionNameCharacters(List partVals) public void createDatabase(Database db) throws AlreadyExistsException, InvalidObjectException, MetaException, TException { if (!db.isSetCatalogName()) { - db.setCatalogName(getDefaultCatalog(conf)); + db.setCatalogName(MetaStoreUtils.getDefaultCatalog(conf)); } client.create_database(db); } @@ -963,7 +963,7 @@ public void createTable(Table tbl) throws AlreadyExistsException, public void createTable(Table tbl, EnvironmentContext envContext) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException { if (!tbl.isSetCatName()) { - tbl.setCatName(getDefaultCatalog(conf)); + tbl.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } HiveMetaHook hook = getHook(tbl); if (hook != null) { @@ -1000,7 +1000,7 @@ public void createTableWithConstraints(Table tbl, MetaException, NoSuchObjectException, TException { if (!tbl.isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); tbl.setCatName(defaultCat); if (primaryKeys != null) { primaryKeys.forEach(pk -> pk.setCatName(defaultCat)); @@ -1044,7 +1044,7 @@ public void createTableWithConstraints(Table tbl, @Override public void dropConstraint(String dbName, String tableName, String constraintName) throws TException { - dropConstraint(getDefaultCatalog(conf), dbName, tableName, constraintName); + dropConstraint(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, constraintName); } @Override @@ -1058,7 +1058,7 @@ public void dropConstraint(String catName, String dbName, String tableName, Stri @Override public void addPrimaryKey(List primaryKeyCols) throws TException { if (!primaryKeyCols.isEmpty() && !primaryKeyCols.get(0).isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); primaryKeyCols.forEach(pk -> pk.setCatName(defaultCat)); } client.add_primary_key(new AddPrimaryKeyRequest(primaryKeyCols)); @@ -1067,7 +1067,7 @@ public void addPrimaryKey(List primaryKeyCols) throws TException @Override public void addForeignKey(List foreignKeyCols) throws TException { if (!foreignKeyCols.isEmpty() && !foreignKeyCols.get(0).isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); foreignKeyCols.forEach(fk -> fk.setCatName(defaultCat)); } client.add_foreign_key(new AddForeignKeyRequest(foreignKeyCols)); @@ -1077,7 +1077,7 @@ public void addForeignKey(List foreignKeyCols) throws TException public void addUniqueConstraint(List uniqueConstraintCols) throws NoSuchObjectException, MetaException, TException { if (!uniqueConstraintCols.isEmpty() && !uniqueConstraintCols.get(0).isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); uniqueConstraintCols.forEach(uc -> uc.setCatName(defaultCat)); } client.add_unique_constraint(new AddUniqueConstraintRequest(uniqueConstraintCols)); @@ -1087,7 +1087,7 @@ public void addUniqueConstraint(List uniqueConstraintCols) public void addNotNullConstraint(List notNullConstraintCols) throws NoSuchObjectException, MetaException, TException { if (!notNullConstraintCols.isEmpty() && !notNullConstraintCols.get(0).isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); notNullConstraintCols.forEach(nn -> nn.setCatName(defaultCat)); } client.add_not_null_constraint(new AddNotNullConstraintRequest(notNullConstraintCols)); @@ -1097,7 +1097,7 @@ public void addNotNullConstraint(List notNullConstraintCol public void addDefaultConstraint(List defaultConstraints) throws NoSuchObjectException, MetaException, TException { if (!defaultConstraints.isEmpty() && !defaultConstraints.get(0).isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); defaultConstraints.forEach(def -> def.setCatName(defaultCat)); } client.add_default_constraint(new AddDefaultConstraintRequest(defaultConstraints)); @@ -1107,7 +1107,7 @@ public void addDefaultConstraint(List defaultConstraints) public void addCheckConstraint(List checkConstraints) throws NoSuchObjectException, MetaException, TException { if (!checkConstraints.isEmpty() && !checkConstraints.get(0).isSetCatName()) { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); checkConstraints.forEach(cc -> cc.setCatName(defaultCat)); } client.add_check_constraint(new AddCheckConstraintRequest(checkConstraints)); @@ -1138,19 +1138,19 @@ public boolean createType(Type type) throws AlreadyExistsException, @Override public void dropDatabase(String name) throws NoSuchObjectException, InvalidOperationException, MetaException, TException { - dropDatabase(getDefaultCatalog(conf), name, true, false, false); + dropDatabase(MetaStoreUtils.getDefaultCatalog(conf), name, true, false, false); } @Override public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) throws NoSuchObjectException, InvalidOperationException, MetaException, TException { - dropDatabase(getDefaultCatalog(conf), name, deleteData, ignoreUnknownDb, false); + dropDatabase(MetaStoreUtils.getDefaultCatalog(conf), name, deleteData, ignoreUnknownDb, false); } @Override public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb, boolean cascade) throws NoSuchObjectException, InvalidOperationException, MetaException, TException { - dropDatabase(getDefaultCatalog(conf), name, deleteData, ignoreUnknownDb, cascade); + dropDatabase(MetaStoreUtils.getDefaultCatalog(conf), name, deleteData, ignoreUnknownDb, cascade); } @Override @@ -1166,7 +1166,7 @@ public void dropDatabase(String catalogName, String dbName, boolean deleteData, return; } - String dbNameWithCatalog = prependCatalogToDbName(catalogName, dbName, conf); + String dbNameWithCatalog = MetaStoreUtils.prependCatalogToDbName(catalogName, dbName, conf); if (cascade) { // Note that this logic may drop some of the tables of the database @@ -1222,7 +1222,7 @@ public void dropDatabase(String catalogName, String dbName, boolean deleteData, */ private void dropDatabaseCascadePerTable(String catName, String dbName, List tableList, boolean deleteData, int maxBatchSize) throws TException { - String dbNameWithCatalog = prependCatalogToDbName(catName, dbName, conf); + String dbNameWithCatalog = MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf); for (Table table : new TableIterable(this, catName, dbName, tableList, maxBatchSize)) { boolean success = false; HiveMetaHook hook = getHook(table); @@ -1255,7 +1255,7 @@ private void dropDatabaseCascadePerTable(String catName, String dbName, List tableList, boolean deleteData) throws TException { - String dbNameWithCatalog = prependCatalogToDbName(catName, dbName, conf); + String dbNameWithCatalog = MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf); List tables = getTableObjectsByName(catName, dbName, tableList); boolean success = false; try { @@ -1291,13 +1291,13 @@ private void dropDatabaseCascadePerDb(String catName, String dbName, List part_vals, EnvironmentContext env_context) throws TException { - return client.drop_partition_with_environment_context(prependCatalogToDbName(db_name, conf), + return client.drop_partition_with_environment_context(MetaStoreUtils.prependCatalogToDbName(db_name, conf), tbl_name, part_vals, true, env_context); } @Deprecated public boolean dropPartition(String dbName, String tableName, String partName, boolean dropData, EnvironmentContext ec) throws TException { - return client.drop_partition_by_name_with_environment_context(prependCatalogToDbName(dbName, conf), + return client.drop_partition_by_name_with_environment_context(MetaStoreUtils.prependCatalogToDbName(dbName, conf), tableName, partName, dropData, ec); } @Deprecated public boolean dropPartition(String dbName, String tableName, List partVals) throws TException { - return client.drop_partition(prependCatalogToDbName(dbName, conf), tableName, partVals, true); + return client.drop_partition(MetaStoreUtils.prependCatalogToDbName(dbName, conf), tableName, partVals, true); } @Override public boolean dropPartition(String db_name, String tbl_name, List part_vals, boolean deleteData) throws TException { - return dropPartition(getDefaultCatalog(conf), db_name, tbl_name, part_vals, + return dropPartition(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals, PartitionDropOptions.instance().deleteData(deleteData)); } @@ -1348,7 +1348,7 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, @Override public boolean dropPartition(String db_name, String tbl_name, List part_vals, PartitionDropOptions options) throws TException { - return dropPartition(getDefaultCatalog(conf), db_name, tbl_name, part_vals, options); + return dropPartition(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals, options); } @Override @@ -1365,7 +1365,7 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, } } } - return client.drop_partition_with_environment_context(prependCatalogToDbName( + return client.drop_partition_with_environment_context(MetaStoreUtils.prependCatalogToDbName( catName, db_name, conf), tbl_name, part_vals, options.deleteData, options.purgeData ? getEnvironmentContextWithIfPurgeSet() : null); } @@ -1375,7 +1375,7 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, List> partExprs, PartitionDropOptions options) throws TException { - return dropPartitions(getDefaultCatalog(conf), dbName, tblName, partExprs, options); + return dropPartitions(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, partExprs, options); } @Override @@ -1383,7 +1383,7 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, List> partExprs, boolean deleteData, boolean ifExists, boolean needResult) throws NoSuchObjectException, MetaException, TException { - return dropPartitions(getDefaultCatalog(conf), dbName, tblName, partExprs, + return dropPartitions(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, partExprs, PartitionDropOptions.instance() .deleteData(deleteData) .ifExists(ifExists) @@ -1396,7 +1396,7 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, List> partExprs, boolean deleteData, boolean ifExists) throws NoSuchObjectException, MetaException, TException { // By default, we need the results from dropPartitions(); - return dropPartitions(getDefaultCatalog(conf), dbName, tblName, partExprs, + return dropPartitions(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, partExprs, PartitionDropOptions.instance() .deleteData(deleteData) .ifExists(ifExists)); @@ -1431,18 +1431,18 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, public void dropTable(String dbname, String name, boolean deleteData, boolean ignoreUnknownTab) throws MetaException, TException, NoSuchObjectException, UnsupportedOperationException { - dropTable(getDefaultCatalog(conf), dbname, name, deleteData, ignoreUnknownTab, null); + dropTable(MetaStoreUtils.getDefaultCatalog(conf), dbname, name, deleteData, ignoreUnknownTab, null); } @Override public void dropTable(String dbname, String name, boolean deleteData, boolean ignoreUnknownTab, boolean ifPurge) throws TException { - dropTable(getDefaultCatalog(conf), dbname, name, deleteData, ignoreUnknownTab, ifPurge); + dropTable(MetaStoreUtils.getDefaultCatalog(conf), dbname, name, deleteData, ignoreUnknownTab, ifPurge); } @Override public void dropTable(String dbname, String name) throws TException { - dropTable(getDefaultCatalog(conf), dbname, name, true, true, null); + dropTable(MetaStoreUtils.getDefaultCatalog(conf), dbname, name, true, true, null); } @Override @@ -1521,13 +1521,13 @@ public void dropTable(String catName, String dbname, String name, boolean delete @Override public void truncateTable(String dbName, String tableName, List partNames, String validWriteIds, long writeId) throws TException { - truncateTableInternal(getDefaultCatalog(conf), + truncateTableInternal(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, partNames, validWriteIds, writeId); } @Override public void truncateTable(String dbName, String tableName, List partNames) throws TException { - truncateTableInternal(getDefaultCatalog(conf), dbName, tableName, partNames, null, -1); + truncateTableInternal(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, partNames, null, -1); } @Override @@ -1540,7 +1540,7 @@ private void truncateTableInternal(String catName, String dbName, String tableNa List partNames, String validWriteIds, long writeId) throws MetaException, TException { TruncateTableRequest req = new TruncateTableRequest( - prependCatalogToDbName(catName, dbName, conf), tableName); + MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName); req.setPartNames(partNames); req.setValidWriteIdList(validWriteIds); req.setWriteId(writeId); @@ -1592,61 +1592,61 @@ public boolean dropType(String type) throws NoSuchObjectException, MetaException @Override public List getDatabases(String databasePattern) throws TException { - return getDatabases(getDefaultCatalog(conf), databasePattern); + return getDatabases(MetaStoreUtils.getDefaultCatalog(conf), databasePattern); } @Override public List getDatabases(String catName, String databasePattern) throws TException { - return filterHook.filterDatabases(client.get_databases(prependCatalogToDbName( + return filterHook.filterDatabases(client.get_databases(MetaStoreUtils.prependCatalogToDbName( catName, databasePattern, conf))); } @Override public List getAllDatabases() throws TException { - return getAllDatabases(getDefaultCatalog(conf)); + return getAllDatabases(MetaStoreUtils.getDefaultCatalog(conf)); } @Override public List getAllDatabases(String catName) throws TException { - return filterHook.filterDatabases(client.get_databases(prependCatalogToDbName(catName, null, conf))); + return filterHook.filterDatabases(client.get_databases(MetaStoreUtils.prependCatalogToDbName(catName, null, conf))); } @Override public List listPartitions(String db_name, String tbl_name, short max_parts) throws TException { - return listPartitions(getDefaultCatalog(conf), db_name, tbl_name, max_parts); + return listPartitions(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, max_parts); } @Override public List listPartitions(String catName, String db_name, String tbl_name, int max_parts) throws TException { - List parts = client.get_partitions(prependCatalogToDbName(catName, db_name, conf), + List parts = client.get_partitions(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, shrinkMaxtoShort(max_parts)); return deepCopyPartitions(filterHook.filterPartitions(parts)); } @Override public PartitionSpecProxy listPartitionSpecs(String dbName, String tableName, int maxParts) throws TException { - return listPartitionSpecs(getDefaultCatalog(conf), dbName, tableName, maxParts); + return listPartitionSpecs(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, maxParts); } @Override public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, String tableName, int maxParts) throws TException { return PartitionSpecProxy.Factory.get(filterHook.filterPartitionSpecs( - client.get_partitions_pspec(prependCatalogToDbName(catName, dbName, conf), tableName, maxParts))); + client.get_partitions_pspec(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, maxParts))); } @Override public List listPartitions(String db_name, String tbl_name, List part_vals, short max_parts) throws TException { - return listPartitions(getDefaultCatalog(conf), db_name, tbl_name, part_vals, max_parts); + return listPartitions(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals, max_parts); } @Override public List listPartitions(String catName, String db_name, String tbl_name, List part_vals, int max_parts) throws TException { - List parts = client.get_partitions_ps(prependCatalogToDbName(catName, db_name, conf), + List parts = client.get_partitions_ps(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, part_vals, shrinkMaxtoShort(max_parts)); return deepCopyPartitions(filterHook.filterPartitions(parts)); } @@ -1655,7 +1655,7 @@ public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, Stri public List listPartitionsWithAuthInfo(String db_name, String tbl_name, short max_parts, String user_name, List group_names) throws TException { - return listPartitionsWithAuthInfo(getDefaultCatalog(conf), db_name, tbl_name, max_parts, user_name, + return listPartitionsWithAuthInfo(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, max_parts, user_name, group_names); } @@ -1663,7 +1663,7 @@ public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, Stri public List listPartitionsWithAuthInfo(String catName, String dbName, String tableName, int maxParts, String userName, List groupNames) throws TException { - List parts = client.get_partitions_with_auth(prependCatalogToDbName(catName, + List parts = client.get_partitions_with_auth(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, shrinkMaxtoShort(maxParts), userName, groupNames); return deepCopyPartitions(filterHook.filterPartitions(parts)); } @@ -1673,7 +1673,7 @@ public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, Stri List part_vals, short max_parts, String user_name, List group_names) throws TException { - return listPartitionsWithAuthInfo(getDefaultCatalog(conf), db_name, tbl_name, part_vals, max_parts, + return listPartitionsWithAuthInfo(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals, max_parts, user_name, group_names); } @@ -1682,7 +1682,7 @@ public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, Stri List partialPvals, int maxParts, String userName, List groupNames) throws TException { - List parts = client.get_partitions_ps_with_auth(prependCatalogToDbName(catName, + List parts = client.get_partitions_ps_with_auth(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, partialPvals, shrinkMaxtoShort(maxParts), userName, groupNames); return deepCopyPartitions(filterHook.filterPartitions(parts)); } @@ -1690,13 +1690,13 @@ public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, Stri @Override public List listPartitionsByFilter(String db_name, String tbl_name, String filter, short max_parts) throws TException { - return listPartitionsByFilter(getDefaultCatalog(conf), db_name, tbl_name, filter, max_parts); + return listPartitionsByFilter(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, filter, max_parts); } @Override public List listPartitionsByFilter(String catName, String db_name, String tbl_name, String filter, int max_parts) throws TException { - List parts =client.get_partitions_by_filter(prependCatalogToDbName( + List parts =client.get_partitions_by_filter(MetaStoreUtils.prependCatalogToDbName( catName, db_name, conf), tbl_name, filter, shrinkMaxtoShort(max_parts)); return deepCopyPartitions(filterHook.filterPartitions(parts)); } @@ -1705,7 +1705,7 @@ public PartitionSpecProxy listPartitionSpecs(String catName, String dbName, Stri public PartitionSpecProxy listPartitionSpecsByFilter(String db_name, String tbl_name, String filter, int max_parts) throws TException { - return listPartitionSpecsByFilter(getDefaultCatalog(conf), db_name, tbl_name, filter, max_parts); + return listPartitionSpecsByFilter(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, filter, max_parts); } @Override @@ -1713,7 +1713,7 @@ public PartitionSpecProxy listPartitionSpecsByFilter(String catName, String db_n String tbl_name, String filter, int max_parts) throws TException { return PartitionSpecProxy.Factory.get(filterHook.filterPartitionSpecs( - client.get_part_specs_by_filter(prependCatalogToDbName(catName, db_name, conf), tbl_name, filter, + client.get_part_specs_by_filter(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, filter, max_parts))); } @@ -1721,7 +1721,7 @@ public PartitionSpecProxy listPartitionSpecsByFilter(String catName, String db_n public boolean listPartitionsByExpr(String db_name, String tbl_name, byte[] expr, String default_partition_name, short max_parts, List result) throws TException { - return listPartitionsByExpr(getDefaultCatalog(conf), db_name, tbl_name, expr, + return listPartitionsByExpr(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, expr, default_partition_name, max_parts, result); } @@ -1758,39 +1758,39 @@ public boolean listPartitionsByExpr(String catName, String db_name, String tbl_n @Override public Database getDatabase(String name) throws TException { - return getDatabase(getDefaultCatalog(conf), name); + return getDatabase(MetaStoreUtils.getDefaultCatalog(conf), name); } @Override public Database getDatabase(String catalogName, String databaseName) throws TException { - Database d = client.get_database(prependCatalogToDbName(catalogName, databaseName, conf)); + Database d = client.get_database(MetaStoreUtils.prependCatalogToDbName(catalogName, databaseName, conf)); return deepCopy(filterHook.filterDatabase(d)); } @Override public Partition getPartition(String db_name, String tbl_name, List part_vals) throws TException { - return getPartition(getDefaultCatalog(conf), db_name, tbl_name, part_vals); + return getPartition(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals); } @Override public Partition getPartition(String catName, String dbName, String tblName, List partVals) throws TException { - Partition p = client.get_partition(prependCatalogToDbName(catName, dbName, conf), tblName, partVals); + Partition p = client.get_partition(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tblName, partVals); return deepCopy(filterHook.filterPartition(p)); } @Override public List getPartitionsByNames(String db_name, String tbl_name, List part_names) throws TException { - return getPartitionsByNames(getDefaultCatalog(conf), db_name, tbl_name, part_names); + return getPartitionsByNames(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_names); } @Override public List getPartitionsByNames(String catName, String db_name, String tbl_name, List part_names) throws TException { List parts = - client.get_partitions_by_names(prependCatalogToDbName(catName, db_name, conf), tbl_name, part_names); + client.get_partitions_by_names(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, part_names); return deepCopyPartitions(filterHook.filterPartitions(parts)); } @@ -1798,7 +1798,7 @@ public Partition getPartition(String catName, String dbName, String tblName, public PartitionValuesResponse listPartitionValues(PartitionValuesRequest request) throws MetaException, TException, NoSuchObjectException { if (!request.isSetCatName()) { - request.setCatName(getDefaultCatalog(conf)); + request.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_partition_values(request); } @@ -1807,7 +1807,7 @@ public PartitionValuesResponse listPartitionValues(PartitionValuesRequest reques public Partition getPartitionWithAuthInfo(String db_name, String tbl_name, List part_vals, String user_name, List group_names) throws TException { - return getPartitionWithAuthInfo(getDefaultCatalog(conf), db_name, tbl_name, part_vals, + return getPartitionWithAuthInfo(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals, user_name, group_names); } @@ -1815,14 +1815,14 @@ public Partition getPartitionWithAuthInfo(String db_name, String tbl_name, public Partition getPartitionWithAuthInfo(String catName, String dbName, String tableName, List pvals, String userName, List groupNames) throws TException { - Partition p = client.get_partition_with_auth(prependCatalogToDbName(catName, dbName, conf), tableName, + Partition p = client.get_partition_with_auth(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, pvals, userName, groupNames); return deepCopy(filterHook.filterPartition(p)); } @Override public Table getTable(String dbname, String name) throws TException { - return getTable(getDefaultCatalog(conf), dbname, name); + return getTable(MetaStoreUtils.getDefaultCatalog(conf), dbname, name); } @Override @@ -1848,7 +1848,7 @@ public Table getTable(String catName, String dbName, String tableName, @Override public List
getTableObjectsByName(String dbName, List tableNames) throws TException { - return getTableObjectsByName(getDefaultCatalog(conf), dbName, tableNames); + return getTableObjectsByName(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableNames); } @Override @@ -1871,7 +1871,7 @@ public Materialization getMaterializationInvalidationInfo(CreationMetadata cm, S @Override public void updateCreationMetadata(String dbName, String tableName, CreationMetadata cm) throws MetaException, InvalidOperationException, UnknownDBException, TException { - client.update_creation_metadata(getDefaultCatalog(conf), dbName, tableName, cm); + client.update_creation_metadata(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, cm); } @Override @@ -1885,14 +1885,14 @@ public void updateCreationMetadata(String catName, String dbName, String tableNa @Override public List listTableNamesByFilter(String dbName, String filter, short maxTables) throws TException { - return listTableNamesByFilter(getDefaultCatalog(conf), dbName, filter, maxTables); + return listTableNamesByFilter(MetaStoreUtils.getDefaultCatalog(conf), dbName, filter, maxTables); } @Override public List listTableNamesByFilter(String catName, String dbName, String filter, int maxTables) throws TException { return filterHook.filterTableNames(catName, dbName, - client.get_table_names_by_filter(prependCatalogToDbName(catName, dbName, conf), filter, + client.get_table_names_by_filter(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), filter, shrinkMaxtoShort(maxTables))); } @@ -1911,7 +1911,7 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE @Override public List getTables(String dbname, String tablePattern) throws MetaException { try { - return getTables(getDefaultCatalog(conf), dbname, tablePattern); + return getTables(MetaStoreUtils.getDefaultCatalog(conf), dbname, tablePattern); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } @@ -1922,13 +1922,13 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE public List getTables(String catName, String dbName, String tablePattern) throws TException { return filterHook.filterTableNames(catName, dbName, - client.get_tables(prependCatalogToDbName(catName, dbName, conf), tablePattern)); + client.get_tables(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tablePattern)); } @Override public List getTables(String dbname, String tablePattern, TableType tableType) throws MetaException { try { - return getTables(getDefaultCatalog(conf), dbname, tablePattern, tableType); + return getTables(MetaStoreUtils.getDefaultCatalog(conf), dbname, tablePattern, tableType); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } @@ -1939,13 +1939,13 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE public List getTables(String catName, String dbName, String tablePattern, TableType tableType) throws TException { return filterHook.filterTableNames(catName, dbName, - client.get_tables_by_type(prependCatalogToDbName(catName, dbName, conf), tablePattern, + client.get_tables_by_type(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tablePattern, tableType.toString())); } @Override public List getMaterializedViewsForRewriting(String dbName) throws TException { - return getMaterializedViewsForRewriting(getDefaultCatalog(conf), dbName); + return getMaterializedViewsForRewriting(MetaStoreUtils.getDefaultCatalog(conf), dbName); } @Override @@ -1953,7 +1953,7 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE throws MetaException { try { return filterHook.filterTableNames(catName, dbname, - client.get_materialized_views_for_rewriting(prependCatalogToDbName(catName, dbname, conf))); + client.get_materialized_views_for_rewriting(MetaStoreUtils.prependCatalogToDbName(catName, dbname, conf))); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } @@ -1964,7 +1964,7 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE public List getTableMeta(String dbPatterns, String tablePatterns, List tableTypes) throws MetaException { try { - return getTableMeta(getDefaultCatalog(conf), dbPatterns, tablePatterns, tableTypes); + return getTableMeta(MetaStoreUtils.getDefaultCatalog(conf), dbPatterns, tablePatterns, tableTypes); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } @@ -1974,14 +1974,14 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE @Override public List getTableMeta(String catName, String dbPatterns, String tablePatterns, List tableTypes) throws TException { - return filterHook.filterTableMetas(catName,dbPatterns,client.get_table_meta(prependCatalogToDbName( + return filterHook.filterTableMetas(catName,dbPatterns,client.get_table_meta(MetaStoreUtils.prependCatalogToDbName( catName, dbPatterns, conf), tablePatterns, tableTypes)); } @Override public List getAllTables(String dbname) throws MetaException { try { - return getAllTables(getDefaultCatalog(conf), dbname); + return getAllTables(MetaStoreUtils.getDefaultCatalog(conf), dbname); } catch (Exception e) { MetaStoreUtils.logAndThrowMetaException(e); } @@ -1991,12 +1991,12 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE @Override public List getAllTables(String catName, String dbName) throws TException { return filterHook.filterTableNames(catName, dbName, client.get_all_tables( - prependCatalogToDbName(catName, dbName, conf))); + MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf))); } @Override public boolean tableExists(String databaseName, String tableName) throws TException { - return tableExists(getDefaultCatalog(conf), databaseName, tableName); + return tableExists(MetaStoreUtils.getDefaultCatalog(conf), databaseName, tableName); } @Override @@ -2014,54 +2014,54 @@ public boolean tableExists(String catName, String dbName, String tableName) thro @Override public List listPartitionNames(String dbName, String tblName, short max) throws NoSuchObjectException, MetaException, TException { - return listPartitionNames(getDefaultCatalog(conf), dbName, tblName, max); + return listPartitionNames(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, max); } @Override public List listPartitionNames(String catName, String dbName, String tableName, int maxParts) throws TException { return filterHook.filterPartitionNames(catName, dbName, tableName, - client.get_partition_names(prependCatalogToDbName(catName, dbName, conf), tableName, shrinkMaxtoShort(maxParts))); + client.get_partition_names(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, shrinkMaxtoShort(maxParts))); } @Override public List listPartitionNames(String db_name, String tbl_name, List part_vals, short max_parts) throws TException { - return listPartitionNames(getDefaultCatalog(conf), db_name, tbl_name, part_vals, max_parts); + return listPartitionNames(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, part_vals, max_parts); } @Override public List listPartitionNames(String catName, String db_name, String tbl_name, List part_vals, int max_parts) throws TException { return filterHook.filterPartitionNames(catName, db_name, tbl_name, - client.get_partition_names_ps(prependCatalogToDbName(catName, db_name, conf), tbl_name, + client.get_partition_names_ps(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, part_vals, shrinkMaxtoShort(max_parts))); } @Override public int getNumPartitionsByFilter(String db_name, String tbl_name, String filter) throws TException { - return getNumPartitionsByFilter(getDefaultCatalog(conf), db_name, tbl_name, filter); + return getNumPartitionsByFilter(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, filter); } @Override public int getNumPartitionsByFilter(String catName, String dbName, String tableName, String filter) throws TException { - return client.get_num_partitions_by_filter(prependCatalogToDbName(catName, dbName, conf), tableName, + return client.get_num_partitions_by_filter(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, filter); } @Override public void alter_partition(String dbName, String tblName, Partition newPart) throws InvalidOperationException, MetaException, TException { - alter_partition(getDefaultCatalog(conf), dbName, tblName, newPart, null); + alter_partition(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, newPart, null); } @Override public void alter_partition(String dbName, String tblName, Partition newPart, EnvironmentContext environmentContext) throws InvalidOperationException, MetaException, TException { - alter_partition(getDefaultCatalog(conf), dbName, tblName, newPart, environmentContext); + alter_partition(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, newPart, environmentContext); } @Override @@ -2090,14 +2090,14 @@ public void alter_partition(String catName, String dbName, String tblName, Parti public void alter_partitions(String dbName, String tblName, List newParts) throws TException { alter_partitions( - getDefaultCatalog(conf), dbName, tblName, newParts, new EnvironmentContext(), null, -1); + MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, newParts, new EnvironmentContext(), null, -1); } @Override public void alter_partitions(String dbName, String tblName, List newParts, EnvironmentContext environmentContext) throws TException { alter_partitions( - getDefaultCatalog(conf), dbName, tblName, newParts, environmentContext, null, -1); + MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, newParts, environmentContext, null, -1); } @Override @@ -2105,7 +2105,7 @@ public void alter_partitions(String dbName, String tblName, List newP EnvironmentContext environmentContext, String writeIdList, long writeId) throws InvalidOperationException, MetaException, TException { - alter_partitions(getDefaultCatalog(conf), + alter_partitions(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, newParts, environmentContext, writeIdList, writeId); } @@ -2128,30 +2128,30 @@ public void alter_partitions(String catName, String dbName, String tblName, @Override public void alterDatabase(String dbName, Database db) throws TException { - alterDatabase(getDefaultCatalog(conf), dbName, db); + alterDatabase(MetaStoreUtils.getDefaultCatalog(conf), dbName, db); } @Override public void alterDatabase(String catName, String dbName, Database newDb) throws TException { - client.alter_database(prependCatalogToDbName(catName, dbName, conf), newDb); + client.alter_database(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), newDb); } @Override public List getFields(String db, String tableName) throws TException { - return getFields(getDefaultCatalog(conf), db, tableName); + return getFields(MetaStoreUtils.getDefaultCatalog(conf), db, tableName); } @Override public List getFields(String catName, String db, String tableName) throws TException { - List fields = client.get_fields(prependCatalogToDbName(catName, db, conf), tableName); + List fields = client.get_fields(MetaStoreUtils.prependCatalogToDbName(catName, db, conf), tableName); return deepCopyFieldSchemas(fields); } @Override public List getPrimaryKeys(PrimaryKeysRequest req) throws TException { if (!req.isSetCatName()) { - req.setCatName(getDefaultCatalog(conf)); + req.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_primary_keys(req).getPrimaryKeys(); } @@ -2160,7 +2160,7 @@ public void alterDatabase(String catName, String dbName, Database newDb) throws public List getForeignKeys(ForeignKeysRequest req) throws MetaException, NoSuchObjectException, TException { if (!req.isSetCatName()) { - req.setCatName(getDefaultCatalog(conf)); + req.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_foreign_keys(req).getForeignKeys(); } @@ -2169,7 +2169,7 @@ public void alterDatabase(String catName, String dbName, Database newDb) throws public List getUniqueConstraints(UniqueConstraintsRequest req) throws MetaException, NoSuchObjectException, TException { if (!req.isSetCatName()) { - req.setCatName(getDefaultCatalog(conf)); + req.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_unique_constraints(req).getUniqueConstraints(); } @@ -2178,7 +2178,7 @@ public void alterDatabase(String catName, String dbName, Database newDb) throws public List getNotNullConstraints(NotNullConstraintsRequest req) throws MetaException, NoSuchObjectException, TException { if (!req.isSetCatName()) { - req.setCatName(getDefaultCatalog(conf)); + req.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_not_null_constraints(req).getNotNullConstraints(); } @@ -2187,7 +2187,7 @@ public void alterDatabase(String catName, String dbName, Database newDb) throws public List getDefaultConstraints(DefaultConstraintsRequest req) throws MetaException, NoSuchObjectException, TException { if (!req.isSetCatName()) { - req.setCatName(getDefaultCatalog(conf)); + req.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_default_constraints(req).getDefaultConstraints(); } @@ -2196,7 +2196,7 @@ public void alterDatabase(String catName, String dbName, Database newDb) throws public List getCheckConstraints(CheckConstraintsRequest req) throws MetaException, NoSuchObjectException, TException { if (!req.isSetCatName()) { - req.setCatName(getDefaultCatalog(conf)); + req.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_check_constraints(req).getCheckConstraints(); } @@ -2205,7 +2205,7 @@ public void alterDatabase(String catName, String dbName, Database newDb) throws @Override public boolean updateTableColumnStatistics(ColumnStatistics statsObj) throws TException { if (!statsObj.getStatsDesc().isSetCatName()) { - statsObj.getStatsDesc().setCatName(getDefaultCatalog(conf)); + statsObj.getStatsDesc().setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } // Note: currently this method doesn't set txn properties and thus won't work on txn tables. SetPartitionsStatsRequest req = new SetPartitionsStatsRequest(); @@ -2217,7 +2217,7 @@ public boolean updateTableColumnStatistics(ColumnStatistics statsObj) throws TEx @Override public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) throws TException { if (!statsObj.getStatsDesc().isSetCatName()) { - statsObj.getStatsDesc().setCatName(getDefaultCatalog(conf)); + statsObj.getStatsDesc().setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } // Note: currently this method doesn't set txn properties and thus won't work on txn tables. SetPartitionsStatsRequest req = new SetPartitionsStatsRequest(); @@ -2228,7 +2228,7 @@ public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) throws @Override public boolean setPartitionColumnStatistics(SetPartitionsStatsRequest request) throws TException { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); for (ColumnStatistics stats : request.getColStats()) { if (!stats.getStatsDesc().isSetCatName()) { stats.getStatsDesc().setCatName(defaultCat); @@ -2250,7 +2250,7 @@ public void flushCache() { @Override public List getTableColumnStatistics(String dbName, String tableName, List colNames) throws TException { - return getTableColumnStatistics(getDefaultCatalog(conf), dbName, tableName, colNames); + return getTableColumnStatistics(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, colNames); } @Override @@ -2266,7 +2266,7 @@ public void flushCache() { public List getTableColumnStatistics(String dbName, String tableName, List colNames, String validWriteIdList) throws TException { - return getTableColumnStatistics(getDefaultCatalog(conf), dbName, tableName, colNames, + return getTableColumnStatistics(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, colNames, validWriteIdList); } @@ -2285,7 +2285,7 @@ public void flushCache() { public Map> getPartitionColumnStatistics( String dbName, String tableName, List partNames, List colNames) throws TException { - return getPartitionColumnStatistics(getDefaultCatalog(conf), dbName, tableName, partNames, colNames); + return getPartitionColumnStatistics(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, partNames, colNames); } @Override @@ -2301,7 +2301,7 @@ public void flushCache() { @Override public boolean deletePartitionColumnStatistics(String dbName, String tableName, String partName, String colName) throws TException { - return deletePartitionColumnStatistics(getDefaultCatalog(conf), dbName, tableName, partName, + return deletePartitionColumnStatistics(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, partName, colName); } @@ -2309,26 +2309,26 @@ public boolean deletePartitionColumnStatistics(String dbName, String tableName, public boolean deletePartitionColumnStatistics(String catName, String dbName, String tableName, String partName, String colName) throws TException { - return client.delete_partition_column_statistics(prependCatalogToDbName(catName, dbName, conf), + return client.delete_partition_column_statistics(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, partName, colName); } @Override public boolean deleteTableColumnStatistics(String dbName, String tableName, String colName) throws TException { - return deleteTableColumnStatistics(getDefaultCatalog(conf), dbName, tableName, colName); + return deleteTableColumnStatistics(MetaStoreUtils.getDefaultCatalog(conf), dbName, tableName, colName); } @Override public boolean deleteTableColumnStatistics(String catName, String dbName, String tableName, String colName) throws TException { - return client.delete_table_column_statistics(prependCatalogToDbName(catName, dbName, conf), + return client.delete_table_column_statistics(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tableName, colName); } @Override public List getSchema(String db, String tableName) throws TException { - return getSchema(getDefaultCatalog(conf), db, tableName); + return getSchema(MetaStoreUtils.getDefaultCatalog(conf), db, tableName); } @Override @@ -2341,7 +2341,7 @@ public boolean deleteTableColumnStatistics(String catName, String dbName, String envCxt = new EnvironmentContext(props); } - List fields = client.get_schema_with_environment_context(prependCatalogToDbName( + List fields = client.get_schema_with_environment_context(MetaStoreUtils.prependCatalogToDbName( catName, db, conf), tableName, envCxt); return deepCopyFieldSchemas(fields); } @@ -2354,13 +2354,13 @@ public String getConfigValue(String name, String defaultValue) @Override public Partition getPartition(String db, String tableName, String partName) throws TException { - return getPartition(getDefaultCatalog(conf), db, tableName, partName); + return getPartition(MetaStoreUtils.getDefaultCatalog(conf), db, tableName, partName); } @Override public Partition getPartition(String catName, String dbName, String tblName, String name) throws TException { - Partition p = client.get_partition_by_name(prependCatalogToDbName(catName, dbName, conf), tblName, + Partition p = client.get_partition_by_name(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), tblName, name); return deepCopy(filterHook.filterPartition(p)); } @@ -2563,7 +2563,7 @@ public GetRoleGrantsForPrincipalResponse get_role_grants_for_principal( @Override public boolean grant_privileges(PrivilegeBag privileges) throws MetaException, TException { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); for (HiveObjectPrivilege priv : privileges.getPrivileges()) { if (!priv.getHiveObject().isSetCatName()) { priv.getHiveObject().setCatName(defaultCat); @@ -2598,7 +2598,7 @@ public boolean revoke_role(String roleName, String userName, @Override public boolean revoke_privileges(PrivilegeBag privileges, boolean grantOption) throws MetaException, TException { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); for (HiveObjectPrivilege priv : privileges.getPrivileges()) { if (!priv.getHiveObject().isSetCatName()) { priv.getHiveObject().setCatName(defaultCat); @@ -2619,7 +2619,7 @@ public boolean revoke_privileges(PrivilegeBag privileges, boolean grantOption) t public boolean refresh_privileges(HiveObjectRef objToRefresh, String authorizer, PrivilegeBag grantPrivileges) throws MetaException, TException { - String defaultCat = getDefaultCatalog(conf); + String defaultCat = MetaStoreUtils.getDefaultCatalog(conf); objToRefresh.setCatName(defaultCat); if (grantPrivileges.getPrivileges() != null) { @@ -2645,7 +2645,7 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, String userName, List groupNames) throws MetaException, TException { if (!hiveObject.isSetCatName()) { - hiveObject.setCatName(getDefaultCatalog(conf)); + hiveObject.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_privilege_set(hiveObject, userName, groupNames); } @@ -2655,7 +2655,7 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, PrincipalType principalType, HiveObjectRef hiveObject) throws MetaException, TException { if (!hiveObject.isSetCatName()) { - hiveObject.setCatName(getDefaultCatalog(conf)); + hiveObject.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.list_privileges(principalName, principalType, hiveObject); } @@ -2951,7 +2951,7 @@ public void compact(String dbname, String tableName, String partitionName, Comp throws TException { CompactionRequest cr = new CompactionRequest(); if (dbname == null) { - cr.setDbname(DEFAULT_DATABASE_NAME); + cr.setDbname(Warehouse.DEFAULT_DATABASE_NAME); } else { cr.setDbname(dbname); } @@ -2974,7 +2974,7 @@ public CompactionResponse compact2(String dbname, String tableName, String parti Map tblproperties) throws TException { CompactionRequest cr = new CompactionRequest(); if (dbname == null) { - cr.setDbname(DEFAULT_DATABASE_NAME); + cr.setDbname(Warehouse.DEFAULT_DATABASE_NAME); } else { cr.setDbname(dbname); } @@ -3064,7 +3064,7 @@ public CurrentNotificationEventId getCurrentNotificationEventId() throws TExcept public NotificationEventsCountResponse getNotificationEventsCount(NotificationEventsCountRequest rqst) throws TException { if (!rqst.isSetCatName()) { - rqst.setCatName(getDefaultCatalog(conf)); + rqst.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.get_notification_events_count(rqst); } @@ -3073,7 +3073,7 @@ public NotificationEventsCountResponse getNotificationEventsCount(NotificationEv @Override public FireEventResponse fireListenerEvent(FireEventRequest rqst) throws TException { if (!rqst.isSetCatName()) { - rqst.setCatName(getDefaultCatalog(conf)); + rqst.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } return client.fire_listener_event(rqst); } @@ -3122,14 +3122,14 @@ public synchronized Object invoke(Object proxy, Method method, Object [] args) @Override public void markPartitionForEvent(String db_name, String tbl_name, Map partKVs, PartitionEventType eventType) throws TException { - markPartitionForEvent(getDefaultCatalog(conf), db_name, tbl_name, partKVs, eventType); + markPartitionForEvent(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, partKVs, eventType); } @Override public void markPartitionForEvent(String catName, String db_name, String tbl_name, Map partKVs, PartitionEventType eventType) throws TException { - client.markPartitionForEvent(prependCatalogToDbName(catName, db_name, conf), tbl_name, partKVs, + client.markPartitionForEvent(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, partKVs, eventType); } @@ -3137,14 +3137,14 @@ public void markPartitionForEvent(String catName, String db_name, String tbl_nam @Override public boolean isPartitionMarkedForEvent(String db_name, String tbl_name, Map partKVs, PartitionEventType eventType) throws TException { - return isPartitionMarkedForEvent(getDefaultCatalog(conf), db_name, tbl_name, partKVs, eventType); + return isPartitionMarkedForEvent(MetaStoreUtils.getDefaultCatalog(conf), db_name, tbl_name, partKVs, eventType); } @Override public boolean isPartitionMarkedForEvent(String catName, String db_name, String tbl_name, Map partKVs, PartitionEventType eventType) throws TException { - return client.isPartitionMarkedForEvent(prependCatalogToDbName(catName, db_name, conf), tbl_name, + return client.isPartitionMarkedForEvent(MetaStoreUtils.prependCatalogToDbName(catName, db_name, conf), tbl_name, partKVs, eventType); } @@ -3154,7 +3154,7 @@ public void createFunction(Function func) throws TException { throw new MetaException("Function cannot be null."); } if (!func.isSetCatName()) { - func.setCatName(getDefaultCatalog(conf)); + func.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } client.create_function(func); } @@ -3162,43 +3162,43 @@ public void createFunction(Function func) throws TException { @Override public void alterFunction(String dbName, String funcName, Function newFunction) throws TException { - alterFunction(getDefaultCatalog(conf), dbName, funcName, newFunction); + alterFunction(MetaStoreUtils.getDefaultCatalog(conf), dbName, funcName, newFunction); } @Override public void alterFunction(String catName, String dbName, String funcName, Function newFunction) throws TException { - client.alter_function(prependCatalogToDbName(catName, dbName, conf), funcName, newFunction); + client.alter_function(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), funcName, newFunction); } @Override public void dropFunction(String dbName, String funcName) throws TException { - dropFunction(getDefaultCatalog(conf), dbName, funcName); + dropFunction(MetaStoreUtils.getDefaultCatalog(conf), dbName, funcName); } @Override public void dropFunction(String catName, String dbName, String funcName) throws TException { - client.drop_function(prependCatalogToDbName(catName, dbName, conf), funcName); + client.drop_function(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), funcName); } @Override public Function getFunction(String dbName, String funcName) throws TException { - return getFunction(getDefaultCatalog(conf), dbName, funcName); + return getFunction(MetaStoreUtils.getDefaultCatalog(conf), dbName, funcName); } @Override public Function getFunction(String catName, String dbName, String funcName) throws TException { - return deepCopy(client.get_function(prependCatalogToDbName(catName, dbName, conf), funcName)); + return deepCopy(client.get_function(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), funcName)); } @Override public List getFunctions(String dbName, String pattern) throws TException { - return getFunctions(getDefaultCatalog(conf), dbName, pattern); + return getFunctions(MetaStoreUtils.getDefaultCatalog(conf), dbName, pattern); } @Override public List getFunctions(String catName, String dbName, String pattern) throws TException { - return client.get_functions(prependCatalogToDbName(catName, dbName, conf), pattern); + return client.get_functions(MetaStoreUtils.prependCatalogToDbName(catName, dbName, conf), pattern); } @Override @@ -3214,14 +3214,14 @@ protected void create_table_with_environment_context(Table tbl, EnvironmentConte protected void drop_table_with_environment_context(String catName, String dbname, String name, boolean deleteData, EnvironmentContext envContext) throws TException { - client.drop_table_with_environment_context(prependCatalogToDbName(catName, dbname, conf), + client.drop_table_with_environment_context(MetaStoreUtils.prependCatalogToDbName(catName, dbname, conf), name, deleteData, envContext); } @Override public AggrStats getAggrColStatsFor(String dbName, String tblName, List colNames, List partNames) throws NoSuchObjectException, MetaException, TException { - return getAggrColStatsFor(getDefaultCatalog(conf), dbName, tblName, colNames, partNames); + return getAggrColStatsFor(MetaStoreUtils.getDefaultCatalog(conf), dbName, tblName, colNames, partNames); } @Override @@ -3538,7 +3538,7 @@ public void createOrDropTriggerToPoolMapping(String resourcePlanName, String tri @Override public void createISchema(ISchema schema) throws TException { if (!schema.isSetCatName()) { - schema.setCatName(getDefaultCatalog(conf)); + schema.setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } client.create_ischema(schema); } @@ -3561,7 +3561,7 @@ public void dropISchema(String catName, String dbName, String name) throws TExce @Override public void addSchemaVersion(SchemaVersion schemaVersion) throws TException { if (!schemaVersion.getSchema().isSetCatName()) { - schemaVersion.getSchema().setCatName(getDefaultCatalog(conf)); + schemaVersion.getSchema().setCatName(MetaStoreUtils.getDefaultCatalog(conf)); } client.add_schema_version(schemaVersion); } diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java b/standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java similarity index 100% rename from standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java rename to standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java diff --git a/standalone-metastore/metastore-server/pom.xml b/standalone-metastore/metastore-server/pom.xml index 02446415ad..5e4025c2d9 100644 --- a/standalone-metastore/metastore-server/pom.xml +++ b/standalone-metastore/metastore-server/pom.xml @@ -17,7 +17,12 @@ org.apache.hive hive-standalone-metastore-common - 4.0.0-SNAPSHOT + ${project.version} + + + org.apache.hive + hive-standalone-metastore-client + ${project.version} diff --git a/standalone-metastore/pom.xml b/standalone-metastore/pom.xml index 4ff92b3aa5..ea30f9ef57 100644 --- a/standalone-metastore/pom.xml +++ b/standalone-metastore/pom.xml @@ -20,6 +20,7 @@ metastore-common metastore-server metastore-tools + metastore-client org.apache -- 2.19.1