Search in sources :

Example 1 with ScheduledQuery

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

the class ScheduledQueryAnalyzer method interpretAstNode.

private ScheduledQuery interpretAstNode(ASTNode ast) throws SemanticException {
    // child0 is the schedule name
    String scheduleName = ast.getChild(0).getText();
    String clusterNamespace = conf.getVar(ConfVars.HIVE_SCHEDULED_QUERIES_NAMESPACE);
    LOG.info("scheduled query namespace:" + clusterNamespace);
    ScheduledQueryKey key = new ScheduledQueryKey(scheduleName, clusterNamespace);
    ScheduledQuery ret = new ScheduledQuery(key);
    // child 1..n are arguments/options/etc
    for (int i = 1; i < ast.getChildCount(); i++) {
        processScheduledQueryAstNode(ret, (ASTNode) ast.getChild(i));
    }
    return ret;
}
Also used : ScheduledQueryKey(org.apache.hadoop.hive.metastore.api.ScheduledQueryKey) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery)

Example 2 with ScheduledQuery

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

the class ScheduledQueryAnalyzer method composeOverlayObject.

/**
 * Composes an overlay object.
 *
 * Output is a flattened view of the input objects.
 * having the value from the first one which has it defined from the overlays.
 */
private ScheduledQuery composeOverlayObject(ScheduledQuery... overlays) {
    ScheduledQuery ret = new ScheduledQuery();
    _Fields[] q = ScheduledQuery._Fields.values();
    for (_Fields field : q) {
        for (ScheduledQuery o : overlays) {
            if (o.isSet(field)) {
                ret.setFieldValue(field, o.getFieldValue(field));
                break;
            }
        }
    }
    return ret;
}
Also used : ScheduledQuery._Fields(org.apache.hadoop.hive.metastore.api.ScheduledQuery._Fields) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery)

Example 3 with ScheduledQuery

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

the class ScheduledQueryAnalyzer method fillScheduledQuery.

private ScheduledQuery fillScheduledQuery(ScheduledQueryMaintenanceRequestType type, ScheduledQuery schqChanges) throws SemanticException {
    if (type == ScheduledQueryMaintenanceRequestType.CREATE) {
        return composeOverlayObject(schqChanges, buildEmptySchq());
    } else {
        try {
            ScheduledQuery schqStored = db.getMSC().getScheduledQuery(schqChanges.getScheduleKey());
            if (schqChanges.isSetUser()) {
                // in case the user will change; we have to run an authorization check beforehand
                checkAuthorization(type, schqStored);
            }
            // clear the next execution time
            schqStored.setNextExecutionIsSet(false);
            return composeOverlayObject(schqChanges, schqStored);
        } catch (TException e) {
            throw new SemanticException("unable to get Scheduled query" + e);
        }
    }
}
Also used : TException(org.apache.thrift.TException) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery)

Example 4 with ScheduledQuery

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

the class QTestScheduledQueryCleaner method clearScheduledQueries.

private void clearScheduledQueries(HiveConf conf) {
    if (System.getenv(QTestUtil.QTEST_LEAVE_FILES) != null) {
        return;
    }
    Set<String> scheduledQueries = ScheduledQueryCreationRegistryHook.getSchedules();
    for (String name : scheduledQueries) {
        ScheduledQueryMaintenanceRequest request = new ScheduledQueryMaintenanceRequest();
        request.setType(ScheduledQueryMaintenanceRequestType.DROP);
        ScheduledQuery schq = new ScheduledQuery();
        schq.setScheduleKey(new ScheduledQueryKey(name, conf.getVar(ConfVars.HIVE_SCHEDULED_QUERIES_NAMESPACE)));
        request.setScheduledQuery(schq);
        try {
            // propagate new conf to meta store
            Hive db = Hive.get(conf);
            db.getMSC().scheduledQueryMaintenance(request);
            db.close(false);
        } catch (Exception e) {
            LOG.error("Can't remove scheduled query: " + name + " " + e.getMessage());
        }
    }
    scheduledQueries.clear();
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) ScheduledQueryMaintenanceRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest) ScheduledQueryKey(org.apache.hadoop.hive.metastore.api.ScheduledQueryKey) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery)

Example 5 with ScheduledQuery

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

the class MScheduledQuery method toThrift.

public static ScheduledQuery toThrift(MScheduledQuery s) {
    ScheduledQuery ret = new ScheduledQuery();
    ret.setScheduleKey(new ScheduledQueryKey(s.scheduleName, s.clusterNamespace));
    ret.setEnabled(s.enabled);
    ret.setSchedule(s.schedule);
    ret.setUser(s.user);
    ret.setQuery(s.query);
    ret.setNextExecution(s.nextExecution);
    return ret;
}
Also used : ScheduledQueryKey(org.apache.hadoop.hive.metastore.api.ScheduledQueryKey) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery)

Aggregations

ScheduledQuery (org.apache.hadoop.hive.metastore.api.ScheduledQuery)23 ScheduledQueryMaintenanceRequest (org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest)13 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)11 Test (org.junit.Test)11 ScheduledQueryKey (org.apache.hadoop.hive.metastore.api.ScheduledQueryKey)10 ScheduledQueryPollRequest (org.apache.hadoop.hive.metastore.api.ScheduledQueryPollRequest)5 ScheduledQueryPollResponse (org.apache.hadoop.hive.metastore.api.ScheduledQueryPollResponse)5 MScheduledExecution (org.apache.hadoop.hive.metastore.model.MScheduledExecution)4 PersistenceManager (javax.jdo.PersistenceManager)3 ObjectStore (org.apache.hadoop.hive.metastore.ObjectStore)2 ScheduledQueryProgressInfo (org.apache.hadoop.hive.metastore.api.ScheduledQueryProgressInfo)2 TException (org.apache.thrift.TException)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 JDOObjectNotFoundException (javax.jdo.JDOObjectNotFoundException)1 Query (javax.jdo.Query)1 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)1 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)1