Search in sources :

Example 21 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStore method addPartitions.

@Override
public boolean addPartitions(String dbName, String tblName, List<Partition> parts) throws InvalidObjectException, MetaException {
    boolean commit = false;
    openTransaction();
    try {
        List<Partition> partsCopy = new ArrayList<Partition>();
        for (int i = 0; i < parts.size(); i++) {
            Partition partCopy = parts.get(i).deepCopy();
            partCopy.setDbName(HiveStringUtils.normalizeIdentifier(partCopy.getDbName()));
            partCopy.setTableName(HiveStringUtils.normalizeIdentifier(partCopy.getTableName()));
            partsCopy.add(i, partCopy);
        }
        getHBase().putPartitions(partsCopy);
        commit = true;
        return true;
    } catch (IOException e) {
        LOG.error("Unable to add partitions", e);
        throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) ArrayList(java.util.ArrayList) IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 22 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStore method addIndex.

@Override
public boolean addIndex(Index index) throws InvalidObjectException, MetaException {
    boolean commit = false;
    openTransaction();
    try {
        index.setDbName(HiveStringUtils.normalizeIdentifier(index.getDbName()));
        index.setOrigTableName(HiveStringUtils.normalizeIdentifier(index.getOrigTableName()));
        index.setIndexName(HiveStringUtils.normalizeIdentifier(index.getIndexName()));
        index.setIndexTableName(HiveStringUtils.normalizeIdentifier(index.getIndexTableName()));
        getHBase().putIndex(index);
        commit = true;
    } catch (IOException e) {
        LOG.error("Unable to create index ", e);
        throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
    return commit;
}
Also used : IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 23 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStore method getPartition.

@Override
public Partition getPartition(String dbName, String tableName, List<String> part_vals) throws MetaException, NoSuchObjectException {
    boolean commit = false;
    openTransaction();
    try {
        Partition part = getHBase().getPartition(HiveStringUtils.normalizeIdentifier(dbName), HiveStringUtils.normalizeIdentifier(tableName), part_vals);
        if (part == null) {
            throw new NoSuchObjectException("Unable to find partition " + partNameForErrorMsg(dbName, tableName, part_vals));
        }
        commit = true;
        return part;
    } catch (IOException e) {
        LOG.error("Unable to get partition", e);
        throw new MetaException("Error reading partition " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 24 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStore method updateMasterKey.

@Override
public void updateMasterKey(Integer seqNo, String key) throws NoSuchObjectException, MetaException {
    boolean commit = false;
    openTransaction();
    try {
        if (getHBase().getMasterKey(seqNo) == null) {
            throw new NoSuchObjectException("No key found with keyId: " + seqNo);
        }
        getHBase().putMasterKey(seqNo, key);
        commit = true;
    } catch (IOException e) {
        LOG.error("Unable to update master key", e);
        throw new MetaException("Failed updating master key, " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 25 with MetaException

use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.

the class HBaseStore method getTableMeta.

@Override
public List<TableMeta> getTableMeta(String dbNames, String tableNames, List<String> tableTypes) throws MetaException {
    boolean commit = false;
    openTransaction();
    try {
        List<TableMeta> metas = new ArrayList<>();
        for (String dbName : getDatabases(dbNames)) {
            for (Table table : getTableObjectsByName(dbName, getTableNamesInTx(dbName, tableNames))) {
                if (tableTypes == null || tableTypes.contains(table.getTableType())) {
                    TableMeta metaData = new TableMeta(table.getDbName(), table.getTableName(), table.getTableType());
                    metaData.setComments(table.getParameters().get("comment"));
                    metas.add(metaData);
                }
            }
        }
        commit = true;
        return metas;
    } catch (Exception e) {
        LOG.error("Unable to get tables ", e);
        throw new MetaException("Unable to get tables, " + e.getMessage());
    } finally {
        commitOrRoleBack(commit);
    }
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) ArrayList(java.util.ArrayList) TableMeta(org.apache.hadoop.hive.metastore.api.TableMeta) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) InvalidInputException(org.apache.hadoop.hive.metastore.api.InvalidInputException) InvalidPartitionException(org.apache.hadoop.hive.metastore.api.InvalidPartitionException) UnknownDBException(org.apache.hadoop.hive.metastore.api.UnknownDBException) UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException) TException(org.apache.thrift.TException) UnknownPartitionException(org.apache.hadoop.hive.metastore.api.UnknownPartitionException) IOException(java.io.IOException) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

MetaException (org.apache.hadoop.hive.metastore.api.MetaException)318 IOException (java.io.IOException)123 ArrayList (java.util.ArrayList)95 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)74 TException (org.apache.thrift.TException)67 Table (org.apache.hadoop.hive.metastore.api.Table)59 Partition (org.apache.hadoop.hive.metastore.api.Partition)57 SQLException (java.sql.SQLException)55 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)53 Path (org.apache.hadoop.fs.Path)45 Connection (java.sql.Connection)36 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)34 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)32 Statement (java.sql.Statement)31 Test (org.junit.Test)30 List (java.util.List)25 Database (org.apache.hadoop.hive.metastore.api.Database)25 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)25 ResultSet (java.sql.ResultSet)22 UnknownDBException (org.apache.hadoop.hive.metastore.api.UnknownDBException)22