Search in sources :

Example 1 with ConnectionFailureException

use of org.apache.hive.hcatalog.api.ConnectionFailureException in project oozie by apache.

the class HCatURIHandler method exists.

private boolean exists(URI uri, HCatClient client, boolean closeClient) throws HCatAccessorException {
    try {
        boolean flag;
        HCatURI hcatURI = new HCatURI(uri.toString());
        if (!hcatURI.getPartitionMap().isEmpty()) {
            List<HCatPartition> partitions = client.getPartitions(hcatURI.getDb(), hcatURI.getTable(), hcatURI.getPartitionMap());
            flag = partitions != null && !partitions.isEmpty();
        } else {
            List<String> tables = client.listTableNamesByPattern(hcatURI.getDb(), hcatURI.getTable());
            flag = tables != null && !tables.isEmpty();
        }
        return (flag);
    } catch (ConnectionFailureException e) {
        throw new HCatAccessorException(ErrorCode.E1501, e);
    } catch (HCatException e) {
        throw new HCatAccessorException(ErrorCode.E0902, e);
    } catch (URISyntaxException e) {
        throw new HCatAccessorException(ErrorCode.E0902, e);
    } finally {
        closeQuietly(client, null, closeClient);
    }
}
Also used : ConnectionFailureException(org.apache.hive.hcatalog.api.ConnectionFailureException) HCatException(org.apache.hive.hcatalog.common.HCatException) URISyntaxException(java.net.URISyntaxException) HCatURI(org.apache.oozie.util.HCatURI) HCatAccessorException(org.apache.oozie.service.HCatAccessorException) HCatPartition(org.apache.hive.hcatalog.api.HCatPartition)

Example 2 with ConnectionFailureException

use of org.apache.hive.hcatalog.api.ConnectionFailureException in project oozie by apache.

the class HCatLauncherURIHandler method delete.

@Override
public boolean delete(URI uri, Configuration conf) throws LauncherException {
    HCatClient client = getHCatClient(uri, conf);
    try {
        HCatURI hcatURI = new HCatURI(uri.toString());
        if (!hcatURI.getPartitionMap().isEmpty()) {
            client.dropPartitions(hcatURI.getDb(), hcatURI.getTable(), hcatURI.getPartitionMap(), true);
        } else {
            client.dropTable(hcatURI.getDb(), hcatURI.getTable(), true);
        }
        System.out.println("Dropped partitions for " + uri);
        return true;
    } catch (ConnectionFailureException e) {
        throw new LauncherException("Error trying to drop " + uri, e);
    } catch (HCatException e) {
        throw new LauncherException("Error trying to drop " + uri, e);
    } catch (URISyntaxException e) {
        throw new LauncherException("Error trying to drop " + uri, e);
    } finally {
        closeQuietly(client);
    }
}
Also used : HCatClient(org.apache.hive.hcatalog.api.HCatClient) ConnectionFailureException(org.apache.hive.hcatalog.api.ConnectionFailureException) HCatException(org.apache.hive.hcatalog.common.HCatException) URISyntaxException(java.net.URISyntaxException) HCatURI(org.apache.oozie.util.HCatURI)

Aggregations

URISyntaxException (java.net.URISyntaxException)2 ConnectionFailureException (org.apache.hive.hcatalog.api.ConnectionFailureException)2 HCatException (org.apache.hive.hcatalog.common.HCatException)2 HCatURI (org.apache.oozie.util.HCatURI)2 HCatClient (org.apache.hive.hcatalog.api.HCatClient)1 HCatPartition (org.apache.hive.hcatalog.api.HCatPartition)1 HCatAccessorException (org.apache.oozie.service.HCatAccessorException)1