use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest 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.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testCleanup.
@Test
public void testCleanup() throws Exception {
String namespace = "cleanup";
ObjectStore objStore = new ObjectStore();
objStore.setConf(metaStore.getConf());
objStore.deleteScheduledExecutions(0);
ScheduledQuery schq = createScheduledQuery(new ScheduledQueryKey("q1", namespace));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
objStore.scheduledQueryMaintenance(r);
Thread.sleep(1000);
ScheduledQueryPollRequest request = new ScheduledQueryPollRequest(namespace);
ScheduledQueryPollResponse pollResult = objStore.scheduledQueryPoll(request);
try (PersistenceManager pm = PersistenceManagerProvider.getPersistenceManager()) {
MScheduledExecution q = pm.getObjectById(MScheduledExecution.class, pollResult.getExecutionId());
assertEquals(QueryState.INITED, q.getState());
}
Thread.sleep(1000);
objStore.deleteScheduledExecutions(0);
try (PersistenceManager pm = PersistenceManagerProvider.getPersistenceManager()) {
try {
pm.getObjectById(MScheduledExecution.class, pollResult.getExecutionId());
fail("The execution is expected to be deleted at this point...");
} catch (JDOObjectNotFoundException e) {
// expected
}
}
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testNormalDeleteWithExec.
@Test
public void testNormalDeleteWithExec() throws Exception {
String testCaseNS = "delwithexec";
// insert
ScheduledQuery schq = createScheduledQuery(createKey("del2", testCaseNS));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
// wait 2 sec to have the query exection
Thread.sleep(2000);
// invoke poll to create a dependent execution
ScheduledQueryPollRequest pollRequest = new ScheduledQueryPollRequest(testCaseNS);
client.scheduledQueryPoll(pollRequest);
// delete scheduled query
r.setType(ScheduledQueryMaintenanceRequestType.DROP);
client.scheduledQueryMaintenance(r);
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testUpdate.
@Test
public void testUpdate() throws Exception {
ScheduledQuery schq = createScheduledQuery(createKey("update", "ns1"));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
r.setType(ScheduledQueryMaintenanceRequestType.ALTER);
ScheduledQuery schq2 = createScheduledQuery2(createKey("update", "ns1"));
schq2.getScheduleKey().setClusterNamespace("ns1");
r.setScheduledQuery(schq2);
client.scheduledQueryMaintenance(r);
ScheduledQuery schq3 = client.getScheduledQuery(new ScheduledQueryKey("update", "ns1"));
// next execution is set by remote
schq2.setNextExecution(schq3.getNextExecution());
assertEquals(schq2, schq3);
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testNormalDelete.
@Test
public void testNormalDelete() throws Exception {
ScheduledQuery schq = createScheduledQuery(createKey("q1", "nsdel"));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
r.setType(ScheduledQueryMaintenanceRequestType.DROP);
client.scheduledQueryMaintenance(r);
}
Aggregations