use of org.apache.oozie.util.HCatURI in project oozie by apache.
the class HCatELFunctions method getURIFromResolved.
private static HCatURI getURIFromResolved(String dataInName, EventType type) {
final XLog LOG = XLog.getLog(HCatELFunctions.class);
StringBuilder uriTemplate = new StringBuilder();
ELEvaluator eval = ELEvaluator.getCurrent();
String uris;
if (type == EventType.input) {
uris = (String) eval.getVariable(".datain." + dataInName);
} else {
// type=output
uris = (String) eval.getVariable(".dataout." + dataInName);
}
if (uris != null) {
String[] uri = HCatURIParser.splitHCatUris(uris, HCAT_URI_PATTERN);
uriTemplate.append(uri[0]);
} else {
LOG.warn("URI is NULL");
return null;
}
LOG.info("uriTemplate [{0}] ", uriTemplate);
HCatURI hcatURI;
try {
hcatURI = new HCatURI(uriTemplate.toString());
} catch (URISyntaxException e) {
LOG.info("uriTemplate [{0}]. Reason [{1}]: ", uriTemplate, e);
throw new RuntimeException("HCat URI can't be parsed " + e);
}
return hcatURI;
}
use of org.apache.oozie.util.HCatURI 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);
}
}
use of org.apache.oozie.util.HCatURI in project oozie by apache.
the class HCatURIHandler method delete.
@Override
public void delete(URI uri, Configuration conf, String user) throws URIHandlerException {
HCatClientWithToken client = null;
HCatClient hCatClient = null;
try {
HCatURI hcatUri = new HCatURI(uri);
client = getHCatClient(uri, conf, user);
hCatClient = client.getHCatClient();
if (!hcatUri.getPartitionMap().isEmpty()) {
hCatClient.dropPartitions(hcatUri.getDb(), hcatUri.getTable(), hcatUri.getPartitionMap(), true);
} else {
hCatClient.dropTable(hcatUri.getDb(), hcatUri.getTable(), true);
}
} catch (URISyntaxException e) {
throw new HCatAccessorException(ErrorCode.E1501, e);
} catch (HCatException e) {
throw new HCatAccessorException(ErrorCode.E1501, e);
} finally {
closeQuietly(hCatClient, client != null ? client.getDelegationToken() : null, true);
}
}
use of org.apache.oozie.util.HCatURI in project oozie by apache.
the class HCatURIHandler method unregisterFromNotification.
@Override
public boolean unregisterFromNotification(URI uri, String actionID) {
HCatURI hcatURI;
try {
hcatURI = new HCatURI(uri);
} catch (URISyntaxException e) {
// Unexpected at this point
throw new RuntimeException(e);
}
PartitionDependencyManagerService pdmService = Services.get().get(PartitionDependencyManagerService.class);
return pdmService.removeMissingDependency(hcatURI, actionID);
}
use of org.apache.oozie.util.HCatURI in project oozie by apache.
the class HCatURIHandler method getMetastoreConnectURI.
private String getMetastoreConnectURI(URI uri) throws HCatAccessorException {
String metastoreURI;
// For unit tests
if (uri.getAuthority().equals("unittest-local")) {
metastoreURI = "";
} else {
// Hardcoding hcat to thrift mapping till support for webhcat(templeton)
// is added
HCatURI hCatURI;
try {
hCatURI = new HCatURI(uri.toString());
metastoreURI = hCatURI.getServerEndPointWithScheme("thrift");
} catch (URISyntaxException e) {
throw new HCatAccessorException(ErrorCode.E0902, e);
}
}
return metastoreURI;
}
Aggregations