Search in sources :

Example 1 with TransactionStateStorage

use of org.apache.tephra.persist.TransactionStateStorage in project cdap by caskdata.

the class HiveExploreServiceStopTest method testServiceStop.

@Test
public void testServiceStop() throws Exception {
    ExploreService exploreService = injector.getInstance(ExploreService.class);
    Set<Long> beforeTxns = transactionManager.getCurrentState().getInProgress().keySet();
    exploreService.execute(NAMESPACE_ID, "show tables");
    Set<Long> queryTxns = Sets.difference(transactionManager.getCurrentState().getInProgress().keySet(), beforeTxns);
    Assert.assertFalse(queryTxns.isEmpty());
    // Stop all services so that explore service gets stopped.
    stopServices();
    // Make sure that the transaction got closed
    TransactionStateStorage transactionStateStorage = injector.getInstance(TransactionStateStorage.class);
    TransactionSnapshot latestSnapshot = transactionStateStorage.getLatestSnapshot();
    Assert.assertEquals(ImmutableSet.<Long>of(), Sets.intersection(queryTxns, latestSnapshot.getInProgress().keySet()).immutableCopy());
}
Also used : TransactionSnapshot(org.apache.tephra.persist.TransactionSnapshot) TransactionStateStorage(org.apache.tephra.persist.TransactionStateStorage) Test(org.junit.Test)

Aggregations

TransactionSnapshot (org.apache.tephra.persist.TransactionSnapshot)1 TransactionStateStorage (org.apache.tephra.persist.TransactionStateStorage)1 Test (org.junit.Test)1