use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method createEverySecondSchq.
private void createEverySecondSchq(ScheduledQueryKey schqKey) throws MetaException, TException {
ScheduledQuery schq = createScheduledQuery(schqKey);
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testDeleteNonExistent.
@Test(expected = NoSuchObjectException.class)
public void testDeleteNonExistent() throws Exception {
ScheduledQuery schq = createScheduledQuery(createKey("nonexistent", "nsdel"));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.DROP);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testDisabledMaintenance.
@Test
public void testDisabledMaintenance() throws MetaException, TException {
try {
MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, false);
ObjectStore objStore = new ObjectStore();
objStore.setConf(metaStore.getConf());
thrown.expect(MetaException.class);
thrown.expectMessage(Matchers.contains(ConfVars.SCHEDULED_QUERIES_ENABLED.getVarname()));
objStore.scheduledQueryMaintenance(new ScheduledQueryMaintenanceRequest());
} finally {
MetastoreConf.setBoolVar(metaStore.getConf(), ConfVars.SCHEDULED_QUERIES_ENABLED, true);
}
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testCreate.
@Test
public void testCreate() throws Exception {
ScheduledQuery schq = createScheduledQuery(createKey("create", "c1"));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
ScheduledQuery schq2 = client.getScheduledQuery(new ScheduledQueryKey("create", "c1"));
// next execution is set by remote
schq.setNextExecution(schq2.getNextExecution());
assertEquals(schq2, schq);
}
use of org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest in project hive by apache.
the class TestMetastoreScheduledQueries method testExclusivePoll.
@Test
public void testExclusivePoll() throws Exception {
try {
ObjectStoreTestHook.instance = new ObjectStoreTestHook() {
@Override
public void scheduledQueryPoll() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
};
ScheduledQuery schq = createScheduledQuery(new ScheduledQueryKey("q1", "exclusive"));
ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
r.setScheduledQuery(schq);
client.scheduledQueryMaintenance(r);
// wait 1 sec for next execution
Thread.sleep(1000);
ExecutorService pool = Executors.newCachedThreadPool();
Future<ScheduledQueryPollResponse> f1 = pool.submit(new AsyncPollCall("exclusive"));
Future<ScheduledQueryPollResponse> f2 = pool.submit(new AsyncPollCall("exclusive"));
ScheduledQueryPollResponse resp1 = f1.get();
ScheduledQueryPollResponse resp2 = f2.get();
assertTrue(resp1.isSetQuery() ^ resp2.isSetQuery());
pool.shutdown();
} finally {
ObjectStoreTestHook.instance = null;
}
}
Aggregations