Search in sources :

Example 1 with Msck

use of org.apache.hadoop.hive.metastore.Msck in project hive by apache.

the class TestMsckCreatePartitionsInBatches method setupClass.

@BeforeClass
public static void setupClass() throws HiveException, MetaException {
    hiveConf = new HiveConf(TestMsckCreatePartitionsInBatches.class);
    hiveConf.setIntVar(ConfVars.HIVE_MSCK_REPAIR_BATCH_SIZE, 5);
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    SessionState.start(hiveConf);
    try {
        db = new HiveMetaStoreClient(hiveConf);
    } catch (MetaException e) {
        throw new HiveException(e);
    }
    msck = new Msck(false, false);
    msck.init(Msck.getMsckConf(hiveConf));
}
Also used : HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Msck(org.apache.hadoop.hive.metastore.Msck) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) BeforeClass(org.junit.BeforeClass)

Example 2 with Msck

use of org.apache.hadoop.hive.metastore.Msck in project hive by apache.

the class TestMsckDropPartitionsInBatches method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    hiveConf = new HiveConf(TestMsckCreatePartitionsInBatches.class);
    hiveConf.setIntVar(ConfVars.HIVE_MSCK_REPAIR_BATCH_SIZE, 5);
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    SessionState.start(hiveConf);
    db = new HiveMetaStoreClient(hiveConf);
    msck = new Msck(false, false);
    msck.init(Msck.getMsckConf(hiveConf));
}
Also used : HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Msck(org.apache.hadoop.hive.metastore.Msck) BeforeClass(org.junit.BeforeClass)

Example 3 with Msck

use of org.apache.hadoop.hive.metastore.Msck in project hive by apache.

the class MsckOperation method execute.

@Override
public int execute() throws HiveException, IOException, TException {
    try {
        Msck msck = new Msck(false, false);
        msck.init(Msck.getMsckConf(context.getDb().getConf()));
        msck.updateExpressionProxy(getProxyClass(context.getDb().getConf()));
        TableName tableName = HiveTableName.of(desc.getTableName());
        long partitionExpirySeconds = -1L;
        try (HiveMetaStoreClient msc = new HiveMetaStoreClient(context.getConf())) {
            boolean msckEnablePartitionRetention = MetastoreConf.getBoolVar(context.getConf(), MetastoreConf.ConfVars.MSCK_REPAIR_ENABLE_PARTITION_RETENTION);
            if (msckEnablePartitionRetention) {
                Table table = msc.getTable(SessionState.get().getCurrentCatalog(), tableName.getDb(), tableName.getTable());
                String qualifiedTableName = Warehouse.getCatalogQualifiedTableName(table);
                partitionExpirySeconds = PartitionManagementTask.getRetentionPeriodInSeconds(table);
                LOG.info("{} - Retention period ({}s) for partition is enabled for MSCK REPAIR..", qualifiedTableName, partitionExpirySeconds);
            }
        }
        MsckInfo msckInfo = new MsckInfo(SessionState.get().getCurrentCatalog(), tableName.getDb(), tableName.getTable(), desc.getFilterExp(), desc.getResFile(), desc.isRepairPartitions(), desc.isAddPartitions(), desc.isDropPartitions(), partitionExpirySeconds);
        return msck.repair(msckInfo);
    } catch (MetaException e) {
        LOG.error("Unable to create msck instance.", e);
        return 1;
    } catch (SemanticException e) {
        LOG.error("Msck failed.", e);
        return 1;
    }
}
Also used : HiveTableName(org.apache.hadoop.hive.ql.parse.HiveTableName) TableName(org.apache.hadoop.hive.common.TableName) MsckInfo(org.apache.hadoop.hive.metastore.MsckInfo) HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) Table(org.apache.hadoop.hive.metastore.api.Table) Msck(org.apache.hadoop.hive.metastore.Msck) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException)

Aggregations

HiveMetaStoreClient (org.apache.hadoop.hive.metastore.HiveMetaStoreClient)3 Msck (org.apache.hadoop.hive.metastore.Msck)3 HiveConf (org.apache.hadoop.hive.conf.HiveConf)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 BeforeClass (org.junit.BeforeClass)2 TableName (org.apache.hadoop.hive.common.TableName)1 MsckInfo (org.apache.hadoop.hive.metastore.MsckInfo)1 Table (org.apache.hadoop.hive.metastore.api.Table)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 HiveTableName (org.apache.hadoop.hive.ql.parse.HiveTableName)1 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)1