use of org.apache.tephra.TransactionManager in project cdap by caskdata.
the class SparkTransactionHandlerTest method init.
@BeforeClass
public static void init() throws UnknownHostException {
txManager = new TransactionManager(new Configuration());
txManager.startAndWait();
txClient = new InMemoryTxSystemClient(txManager);
sparkTxHandler = new SparkTransactionHandler(txClient);
httpService = new SparkDriverHttpService("test", InetAddress.getLoopbackAddress().getCanonicalHostName(), sparkTxHandler);
httpService.startAndWait();
sparkTxClient = new SparkTransactionClient(httpService.getBaseURI());
}
use of org.apache.tephra.TransactionManager in project cdap by caskdata.
the class SparkTransactionHandlerTest method testFailureTransaction.
/**
* Tests the case where starting of transaction failed.
*/
@Test
public void testFailureTransaction() throws Exception {
TransactionManager txManager = new TransactionManager(new Configuration()) {
@Override
public Transaction startLong() {
throw new IllegalStateException("Cannot start long transaction");
}
};
txManager.startAndWait();
try {
SparkTransactionHandler txHandler = new SparkTransactionHandler(new InMemoryTxSystemClient(txManager));
SparkDriverHttpService httpService = new SparkDriverHttpService("test", InetAddress.getLoopbackAddress().getCanonicalHostName(), txHandler);
httpService.startAndWait();
try {
// Start a job
txHandler.jobStarted(1, ImmutableSet.of(2));
// Make a call to the stage transaction endpoint, it should throw TransactionFailureException
try {
new SparkTransactionClient(httpService.getBaseURI()).getTransaction(2, 1, TimeUnit.SECONDS);
Assert.fail("Should failed to get transaction");
} catch (TransactionFailureException e) {
// expected
}
// End the job
txHandler.jobEnded(1, false);
} finally {
httpService.stopAndWait();
}
} finally {
txManager.stopAndWait();
}
}
Aggregations