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