use of org.apache.hadoop.hive.metastore.api.ScheduledQuery._Fields in project hive by apache.
the class TestMetastoreScheduledQueries method createScheduledQuery.
private ScheduledQuery createScheduledQuery(ScheduledQueryKey key) {
ScheduledQuery schq = new ScheduledQuery();
schq.setScheduleKey(key);
schq.setEnabled(true);
schq.setSchedule("* * * * * ? *");
schq.setUser("user");
schq.setQuery("select 1");
return schq;
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQuery._Fields 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.ScheduledQuery._Fields in project hive by apache.
the class TestMetastoreScheduledQueries method createScheduledQuery2.
private ScheduledQuery createScheduledQuery2(ScheduledQueryKey key) {
ScheduledQuery schq = new ScheduledQuery();
schq.setScheduleKey(key);
schq.setEnabled(true);
schq.setSchedule("* * * 22 * ? *");
schq.setUser("user22");
schq.setQuery("select 12");
return schq;
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQuery._Fields 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.ScheduledQuery._Fields 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);
}
Aggregations