Search in sources :

Example 1 with HiveWrapper

use of org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper in project hive by apache.

the class ReplDumpTask method dumpTable.

private void dumpTable(String dbName, String tblName, Path dbRoot) throws Exception {
    try {
        Hive db = getHive();
        HiveWrapper.Tuple<Table> tuple = new HiveWrapper(db, dbName).table(tblName);
        TableSpec tableSpec = new TableSpec(tuple.object);
        TableExport.Paths exportPaths = new TableExport.Paths(work.astRepresentationForErrorMsg, dbRoot, tblName, conf, true);
        String distCpDoAsUser = conf.getVar(HiveConf.ConfVars.HIVE_DISTCP_DOAS_USER);
        // by default for all other objects this is false
        tuple.replicationSpec.setIsReplace(true);
        new TableExport(exportPaths, tableSpec, tuple.replicationSpec, db, distCpDoAsUser, conf).write();
        replLogger.tableLog(tblName, tableSpec.tableHandle.getTableType());
    } catch (InvalidTableException te) {
        // Bootstrap dump shouldn't fail if the table is dropped/renamed while dumping it.
        // Just log a debug message and skip it.
        LOG.debug(te.getMessage());
    }
}
Also used : TableExport(org.apache.hadoop.hive.ql.parse.repl.dump.TableExport) Hive(org.apache.hadoop.hive.ql.metadata.Hive) TableSpec(org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.TableSpec) Table(org.apache.hadoop.hive.ql.metadata.Table) HiveWrapper(org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper) InvalidTableException(org.apache.hadoop.hive.ql.metadata.InvalidTableException)

Example 2 with HiveWrapper

use of org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper in project hive by apache.

the class ReplDumpTask method dumpDbMetadata.

private Path dumpDbMetadata(String dbName, Path dumpRoot) throws Exception {
    Path dbRoot = new Path(dumpRoot, dbName);
    // TODO : instantiating FS objects are generally costly. Refactor
    FileSystem fs = dbRoot.getFileSystem(conf);
    Path dumpPath = new Path(dbRoot, EximUtil.METADATA_NAME);
    HiveWrapper.Tuple<Database> database = new HiveWrapper(getHive(), dbName).database();
    EximUtil.createDbExportDump(fs, dumpPath, database.object, database.replicationSpec);
    return dbRoot;
}
Also used : Path(org.apache.hadoop.fs.Path) HiveWrapper(org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper) FileSystem(org.apache.hadoop.fs.FileSystem) Database(org.apache.hadoop.hive.metastore.api.Database)

Aggregations

HiveWrapper (org.apache.hadoop.hive.ql.parse.repl.dump.HiveWrapper)2 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 Database (org.apache.hadoop.hive.metastore.api.Database)1 Hive (org.apache.hadoop.hive.ql.metadata.Hive)1 InvalidTableException (org.apache.hadoop.hive.ql.metadata.InvalidTableException)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1 TableSpec (org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.TableSpec)1 TableExport (org.apache.hadoop.hive.ql.parse.repl.dump.TableExport)1