Search in sources :

Example 6 with ScheduledQuery

use of org.apache.hadoop.hive.metastore.api.ScheduledQuery 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
        }
    }
}
Also used : ObjectStore(org.apache.hadoop.hive.metastore.ObjectStore) ScheduledQueryPollRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryPollRequest) MScheduledExecution(org.apache.hadoop.hive.metastore.model.MScheduledExecution) JDOObjectNotFoundException(javax.jdo.JDOObjectNotFoundException) PersistenceManager(javax.jdo.PersistenceManager) ScheduledQueryPollResponse(org.apache.hadoop.hive.metastore.api.ScheduledQueryPollResponse) ScheduledQueryMaintenanceRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest) ScheduledQueryKey(org.apache.hadoop.hive.metastore.api.ScheduledQueryKey) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

Example 7 with ScheduledQuery

use of org.apache.hadoop.hive.metastore.api.ScheduledQuery 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;
}
Also used : ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery)

Example 8 with ScheduledQuery

use of org.apache.hadoop.hive.metastore.api.ScheduledQuery 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);
}
Also used : ScheduledQueryPollRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryPollRequest) ScheduledQueryMaintenanceRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

Example 9 with ScheduledQuery

use of org.apache.hadoop.hive.metastore.api.ScheduledQuery 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);
}
Also used : ScheduledQueryMaintenanceRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest) ScheduledQueryKey(org.apache.hadoop.hive.metastore.api.ScheduledQueryKey) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

Example 10 with ScheduledQuery

use of org.apache.hadoop.hive.metastore.api.ScheduledQuery 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);
}
Also used : ScheduledQueryMaintenanceRequest(org.apache.hadoop.hive.metastore.api.ScheduledQueryMaintenanceRequest) ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

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