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);
}
}
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);
}
}
Aggregations