Search in sources :

Example 16 with HCatURI

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;
}
Also used : XLog(org.apache.oozie.util.XLog) URISyntaxException(java.net.URISyntaxException) ELEvaluator(org.apache.oozie.util.ELEvaluator) HCatURI(org.apache.oozie.util.HCatURI)

Example 17 with 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);
    }
}
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)

Example 18 with HCatURI

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);
    }
}
Also used : HCatClient(org.apache.hive.hcatalog.api.HCatClient) HCatException(org.apache.hive.hcatalog.common.HCatException) URISyntaxException(java.net.URISyntaxException) HCatURI(org.apache.oozie.util.HCatURI) HCatAccessorException(org.apache.oozie.service.HCatAccessorException)

Example 19 with HCatURI

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);
}
Also used : URISyntaxException(java.net.URISyntaxException) HCatURI(org.apache.oozie.util.HCatURI) PartitionDependencyManagerService(org.apache.oozie.service.PartitionDependencyManagerService)

Example 20 with HCatURI

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;
}
Also used : URISyntaxException(java.net.URISyntaxException) HCatURI(org.apache.oozie.util.HCatURI) HCatAccessorException(org.apache.oozie.service.HCatAccessorException)

Aggregations

HCatURI (org.apache.oozie.util.HCatURI)38 URISyntaxException (java.net.URISyntaxException)16 Test (org.junit.Test)13 PartitionDependencyManagerService (org.apache.oozie.service.PartitionDependencyManagerService)11 HCatAccessorService (org.apache.oozie.service.HCatAccessorService)8 ELEvaluator (org.apache.oozie.util.ELEvaluator)6 URI (java.net.URI)5 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 HCatException (org.apache.hive.hcatalog.common.HCatException)4 HCatAccessorException (org.apache.oozie.service.HCatAccessorException)4 Map (java.util.Map)3 HCatClient (org.apache.hive.hcatalog.api.HCatClient)3 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 Cache (net.sf.ehcache.Cache)2 Element (net.sf.ehcache.Element)2 ConnectionFailureException (org.apache.hive.hcatalog.api.ConnectionFailureException)2 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)2